1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 16:13:18 +00:00
musix-oss/events/clientEvents/ready.js

49 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
const DBL = require("dblapi.js");
module.exports = {
name: 'ready',
async execute(client, Discord) {
2020-03-03 20:24:41 +00:00
const debugChannel = await client.channels.fetch(client.config.debug_channel);
client.debug_channel = debugChannel
2020-02-05 20:02:53 +00:00
const remoteMusixGuildsData = await client.funcs.dbget('guilds', null, client);
remoteMusixGuildsData.forEach(guildData => {
client.global.db.guilds[guildData.id] = guildData.d;
});
2020-02-20 20:31:03 +00:00
if (client.config.devMode) {
console.log('dev mode');
2020-02-19 09:24:26 +00:00
client.guilds.cache.forEach(guild => {
2020-02-05 20:02:53 +00:00
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,
2020-02-20 20:31:03 +00:00
startPlaying: client.config.startPlaying,
2020-03-03 20:24:41 +00:00
bass: client.config.bass,
2020-02-05 20:02:53 +00:00
};
});
}
2020-03-13 20:31:04 +00:00
console.log(`- DB Set - Shard: ${client.shard.ids} -`);
2020-02-05 20:02:53 +00:00
client.user.setActivity(`@${client.user.username} help | 🎶`, { type: 'LISTENING' });
2020-02-13 03:24:30 +00:00
client.user.setStatus('online');
2020-02-13 03:38:40 +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) {
2020-02-27 06:32:06 +00:00
dbl.on('posted', () => {
console.log('Server count posted!');
});
2020-02-05 20:02:53 +00:00
dbl.on('error', error => {
console.log('Error with DBL: ' + error);
2020-02-27 06:32:06 +00:00
});
2020-02-05 20:02:53 +00:00
dbl.postStats(client.guilds.size);
}
2020-03-13 20:31:04 +00:00
console.log(`- Activated - Shard: ${client.shard.ids} -`);
2020-02-05 20:02:53 +00:00
setInterval(async () => {
2020-03-19 14:45:05 +00:00
client.funcs.saveDB(client);
if (client.config.dblApi && !client.config.devMode) dbl.postStats(client.guilds.cache.size);
2020-02-05 20:02:53 +00:00
}, 1800000);
setInterval(() => {
client.funcs.ffmpeg(client, Discord);
}, 7200000);
}
}