2020-02-05 20:02:53 +00:00
|
|
|
const DBL = require("dblapi.js");
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'ready',
|
|
|
|
async execute(client, Discord) {
|
|
|
|
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
|
|
|
|
remoteMusixGuildsData.forEach(guildData => {
|
|
|
|
client.global.db.guilds[guildData.id] = guildData.d;
|
|
|
|
});
|
|
|
|
if (client.devMode) {
|
|
|
|
client.guilds.forEach(guild => {
|
|
|
|
client.global.db.guilds[guild.id] = {
|
|
|
|
prefix: client.config.prefix,
|
|
|
|
defaultVolume: client.config.defaultVolume,
|
|
|
|
permissions: client.config.permissions,
|
|
|
|
dj: client.config.dj,
|
|
|
|
djrole: client.config.djrole,
|
|
|
|
startPlaying: client.config.startPlaying
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
console.log('- DB Set -');
|
|
|
|
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
|
2020-02-13 03:24:30 +00:00
|
|
|
client.user.setStatus('online');
|
2020-02-12 19:48:44 +00:00
|
|
|
const dbl = new DBL(client.config.dblkey, client);
|
2020-02-05 20:02:53 +00:00
|
|
|
if (client.config.dblApi && !client.config.devMode) {
|
|
|
|
dbl.on('error', error => {
|
|
|
|
console.log('Error with DBL: ' + error);
|
|
|
|
})
|
|
|
|
dbl.postStats(client.guilds.size);
|
|
|
|
}
|
|
|
|
console.log('- Activated -');
|
|
|
|
setInterval(async () => {
|
|
|
|
if (client.config.saveDB && !client.config.devMode) {
|
2020-02-12 19:59:36 +00:00
|
|
|
console.log('DB saved');
|
2020-02-05 20:02:53 +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
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (client.config.dblApi && !client.config.devMode) dbl.postStats(client.guilds.size);
|
|
|
|
}, 1800000);
|
|
|
|
setInterval(() => {
|
|
|
|
client.funcs.ffmpeg(client, Discord);
|
|
|
|
}, 7200000);
|
|
|
|
}
|
|
|
|
}
|