1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 08:10:18 +00:00
musix-oss/events/ready.js

49 lines
2.2 KiB
JavaScript
Raw Normal View History

2019-09-15 06:18:33 +00:00
module.exports = {
name: 'ready',
2019-10-10 13:43:04 +00:00
async execute(client, dbl) {
2019-09-15 06:18:33 +00:00
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
2019-10-12 15:06:27 +00:00
const remoteMusixPlaylistsData = await client.funcs.dbget('playlists', null, client);
2019-09-15 06:18:33 +00:00
remoteMusixGuildsData.forEach(guildData => {
2019-10-11 08:48:50 +00:00
client.global.db.guilds[guildData.id] = guildData.d;
2019-09-15 06:18:33 +00:00
});
2019-10-12 15:06:27 +00:00
remoteMusixPlaylistsData.forEach(guildData => {
client.global.db.playlists[guildData.id] = guildData.d;
});
2019-10-10 13:43:04 +00:00
console.log('- DB Set -');
2019-10-31 21:32:47 +00:00
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
client.user.setStatus('dnd');
2019-10-16 11:20:49 +00:00
dbl.postStats(client.guilds.size);
2019-10-10 13:43:04 +00:00
console.log('- Activated -');
2019-11-11 13:55:32 +00:00
let status = [`${client.guilds.size} guilds!`, `@${client.user.username} help | 🎶`];
2019-10-22 15:28:15 +00:00
let i = 0;
setInterval(() => {
if (i == status.length) {
i = 0;
}
client.user.setActivity(status[i], { type: 'LISTENING' });
i++;
2019-11-03 07:55:54 +00:00
users = 0;
2019-10-22 15:42:37 +00:00
}, 30000);
2019-09-15 06:18:33 +00:00
setInterval(async () => {
2019-11-11 13:55:32 +00:00
client.guilds.forEach(guild => {
client.db.collection('guilds').doc(guild.id).set({
prefix: client.global.db.guilds[guild.id].prefix,
defaultVolume: client.global.db.guilds[guild.id].defaultVolume,
permissions: client.global.db.guilds[guild.id].permissions,
premium: client.global.db.guilds[guild.id].premium,
dj: client.global.db.guilds[guild.id].dj,
djrole: client.global.db.guilds[guild.id].djrole,
startPlaying: client.global.db.guilds[guild.id].startPlaying
2019-11-05 17:28:03 +00:00
});
2019-11-11 13:55:32 +00:00
if (client.global.db.guilds[guild.id].premium) {
client.db.collection('playlists').doc(guild.id).set({
songs: client.global.db.playlists[guild.id].songs,
saved: client.global.db.playlists[guild.id].saved,
});
}
});
dbl.postStats(client.guilds.size);
2019-10-12 14:40:00 +00:00
}, 1800000);
2019-09-15 06:18:33 +00:00
}
2019-10-22 15:42:37 +00:00
}