eximiabots-radiox/src/client/events/ready.js

87 lines
2.9 KiB
JavaScript
Raw Normal View History

const fetch = require('node-fetch');
2020-03-02 19:38:42 +00:00
module.exports = {
name: 'ready',
2021-08-28 08:07:47 +00:00
async execute(client) {
2020-03-09 11:17:47 +00:00
console.log('RadioX ' + client.config.version);
2021-01-07 03:29:42 +00:00
console.log('Internet Radio to your Discord guild');
console.log('(c)2020-2021 EximiaBots by Warén Group');
2021-08-22 15:48:40 +00:00
console.log('');
2020-03-09 11:17:47 +00:00
2021-08-31 10:53:23 +00:00
/*DEVELOPERS*/
2021-08-31 10:59:38 +00:00
client.funcs.logger('Developers', 'List');
client.developers = "";
2020-03-09 11:17:47 +00:00
let user = "";
2021-06-08 09:01:56 +00:00
for (let i = 0; i < client.config.devId.length; i++) {
2020-03-09 11:17:47 +00:00
user = await client.users.fetch(client.config.devId[i]);
2021-08-31 10:59:38 +00:00
console.log(" - " + user.tag);
2020-03-09 11:17:47 +00:00
if (i == client.config.devId.length - 1) {
client.developers += user.tag;
} else {
client.developers += user.tag + " & ";
}
}
2021-08-31 10:59:38 +00:00
console.log("\n");
2020-03-09 11:17:47 +00:00
2021-08-31 10:53:23 +00:00
/*STATIONS*/
2020-03-11 20:46:42 +00:00
try {
2021-08-22 17:50:48 +00:00
client.funcs.logger('Stations', 'Started fetching list ' + client.config.stationslistUrl);
client.stations = await fetch(client.config.stationslistUrl)
.then(client.funcs.checkFetchStatus)
.then(response => response.json());
2021-08-31 10:53:23 +00:00
client.funcs.logger('Stations', 'List');
client.stations.forEach(station => {
console.log(" - " + station.name);
});
console.log("\n");
2021-08-26 23:52:30 +00:00
client.funcs.logger('Stations', 'Successfully fetched list');
} catch (error) {
2021-08-31 07:38:48 +00:00
client.funcs.logger('Stations', 'Fetching list failed');
2021-08-22 17:50:48 +00:00
console.error(error + "\n");
2020-03-11 20:46:42 +00:00
}
2020-03-09 00:00:02 +00:00
setInterval(async () => {
try {
2021-08-26 23:52:30 +00:00
client.funcs.logger('Stations', 'Started fetching list ' + client.config.stationslistUrl);
client.stations = await fetch(client.config.stationslistUrl)
.then(client.funcs.checkFetchStatus)
.then(response => response.json());
2021-08-31 10:53:23 +00:00
2021-08-26 23:52:30 +00:00
client.funcs.logger('Stations', 'Successfully fetched list');
} catch (error) {
2021-08-22 17:50:48 +00:00
client.funcs.logger('Stations', 'Fetching list failed');
2021-08-22 15:48:40 +00:00
//console.error(error);
}
2020-03-09 11:17:47 +00:00
}, 3600000);
if(!client.stations) {
client.user.setStatus('dnd');
}
2021-08-31 10:53:23 +00:00
/*GUILDS*/
client.funcs.logger('Guilds', 'Started fetching list');
client.funcs.logger('Guilds', 'List');
let guilds = await client.guilds.fetch();
guilds.forEach(guild => {
console.log(" - " + guild.id + ": " + guild.name);
});
console.log("\n");
client.funcs.logger('Guilds', 'Successfully fetched list');
/*STATISTICS*/
client.datastore.calculateGlobal(client);
2021-08-31 10:53:23 +00:00
/*EMOJIS*/
2020-04-02 07:07:27 +00:00
require(`../emojis.js`).execute(client);
2021-08-31 10:53:23 +00:00
/*COMMANDS*/
require(`../commands.js`).execute(client);
2021-08-18 22:52:55 +00:00
2020-03-02 19:38:42 +00:00
}
2020-03-08 14:22:00 +00:00
}