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

54 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-09-15 06:18:33 +00:00
module.exports = {
name: 'ready',
2024-02-09 09:53:30 +00:00
async execute(client) {
2019-10-31 21:32:47 +00:00
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
2024-02-09 09:53:30 +00:00
client.user.setStatus('online');
2019-10-10 13:43:04 +00:00
console.log('- Activated -');
2024-02-09 09:53:30 +00:00
client.guilds.cache.forEach(guild => {
client.global.db.guilds[guild.id] = {
prefix: client.config.prefix,
defaultVolume: 50,
permissions: false,
premium: false,
dj: false,
djrole: null,
startPlaying: true
};
});
if(client.config.firebase.serviceAccount){
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
const remoteMusixPlaylistsData = await client.funcs.dbget('playlists', null, client);
remoteMusixGuildsData.forEach(guildData => {
client.global.db.guilds[guildData.id] = guildData.d;
});
remoteMusixPlaylistsData.forEach(guildData => {
client.global.db.playlists[guildData.id] = guildData.d;
2019-11-11 13:55:32 +00:00
});
2024-02-09 09:53:30 +00:00
console.log('- DB Set -');
setInterval(async () => {
client.guilds.cache.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
});
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,
});
}
});
}, 1800000);
}
2019-09-15 06:18:33 +00:00
}
2019-10-22 15:42:37 +00:00
}