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

57 lines
2.0 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
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]);
if (i == client.config.devId.length - 1) {
client.developers += user.tag;
} else {
client.developers += user.tag + " & ";
}
}
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-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');
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-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');
}
client.datastore.calculateGlobal(client);
2020-04-02 07:07:27 +00:00
require(`../emojis.js`).execute(client);
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
}