2021-09-02 22:23:17 +00:00
|
|
|
|
import Datastore from "../datastore.js";
|
|
|
|
|
import fetch from "node-fetch";
|
2020-03-09 00:03:19 +00:00
|
|
|
|
|
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
|
|
|
|
|
2021-09-02 13:50:45 +00:00
|
|
|
|
client.funcs.logger("Bot", "Ready");
|
2020-03-09 11:17:47 +00:00
|
|
|
|
|
2021-09-02 22:26:00 +00:00
|
|
|
|
/*DATASTORE*/
|
2021-09-02 22:23:17 +00:00
|
|
|
|
client.funcs.logger('Datastore', 'Initialize');
|
|
|
|
|
client.datastore = new Datastore();
|
|
|
|
|
|
2021-09-03 00:03:19 +00:00
|
|
|
|
client.funcs.logger('Datastore');
|
|
|
|
|
client.datastore.map.forEach(datastore => {
|
|
|
|
|
console.log("- " + datastore.guild.id + " / " + datastore.guild.name);
|
|
|
|
|
});
|
|
|
|
|
console.log("\n");
|
|
|
|
|
|
|
|
|
|
client.funcs.logger('Datastore', 'Ready');
|
|
|
|
|
|
2021-08-31 10:53:23 +00:00
|
|
|
|
/*DEVELOPERS*/
|
2021-09-02 11:40:12 +00:00
|
|
|
|
client.funcs.logger('Developers');
|
2021-08-31 10:59:38 +00:00
|
|
|
|
|
2020-03-11 23:19:11 +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]);
|
2021-09-02 13:50:45 +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);
|
2020-08-15 00:16:58 +00:00
|
|
|
|
client.stations = await fetch(client.config.stationslistUrl)
|
2020-04-04 23:29:39 +00:00
|
|
|
|
.then(client.funcs.checkFetchStatus)
|
|
|
|
|
.then(response => response.json());
|
2021-08-31 10:53:23 +00:00
|
|
|
|
|
2021-09-02 11:40:12 +00:00
|
|
|
|
client.funcs.logger('Stations');
|
2021-08-31 10:53:23 +00:00
|
|
|
|
client.stations.forEach(station => {
|
2021-09-02 13:50:45 +00:00
|
|
|
|
console.log("- " + station.name);
|
2021-08-31 10:53:23 +00:00
|
|
|
|
});
|
|
|
|
|
console.log("\n");
|
|
|
|
|
|
2021-08-26 23:52:30 +00:00
|
|
|
|
client.funcs.logger('Stations', 'Successfully fetched list');
|
2020-04-04 23:29:39 +00:00
|
|
|
|
} 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-04-04 23:29:39 +00:00
|
|
|
|
|
2020-03-09 00:00:02 +00:00
|
|
|
|
setInterval(async () => {
|
2020-04-04 23:29:39 +00:00
|
|
|
|
try {
|
2021-08-26 23:52:30 +00:00
|
|
|
|
client.funcs.logger('Stations', 'Started fetching list – ' + client.config.stationslistUrl);
|
2020-08-15 00:16:58 +00:00
|
|
|
|
client.stations = await fetch(client.config.stationslistUrl)
|
2020-04-04 23:29:39 +00:00
|
|
|
|
.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');
|
2020-04-04 23:29:39 +00:00
|
|
|
|
} 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-04-04 23:29:39 +00:00
|
|
|
|
}
|
2020-03-09 11:17:47 +00:00
|
|
|
|
}, 3600000);
|
2020-03-22 15:10:46 +00:00
|
|
|
|
|
2020-04-04 03:53:17 +00:00
|
|
|
|
if(!client.stations) {
|
|
|
|
|
client.user.setStatus('dnd');
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-31 10:53:23 +00:00
|
|
|
|
/*GUILDS*/
|
|
|
|
|
client.funcs.logger('Guilds', 'Started fetching list');
|
|
|
|
|
|
2021-09-02 11:40:12 +00:00
|
|
|
|
client.funcs.logger('Guilds');
|
2021-08-31 10:53:23 +00:00
|
|
|
|
let guilds = await client.guilds.fetch();
|
|
|
|
|
guilds.forEach(guild => {
|
2021-09-03 00:03:19 +00:00
|
|
|
|
console.log("- " + guild.id + " / " + guild.name);
|
2021-08-31 10:53:23 +00:00
|
|
|
|
});
|
|
|
|
|
console.log("\n");
|
|
|
|
|
|
|
|
|
|
client.funcs.logger('Guilds', 'Successfully fetched list');
|
2021-09-02 22:23:17 +00:00
|
|
|
|
|
2021-08-31 10:53:23 +00:00
|
|
|
|
/*STATISTICS*/
|
2020-04-04 03:53:17 +00:00
|
|
|
|
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);
|
2020-04-04 03:53:17 +00:00
|
|
|
|
|
2021-08-31 10:53:23 +00:00
|
|
|
|
/*COMMANDS*/
|
2021-08-21 14:55:52 +00:00
|
|
|
|
require(`../commands.js`).execute(client);
|
2021-08-18 22:52:55 +00:00
|
|
|
|
|
2021-09-02 22:23:17 +00:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
/*RESTORE RADIO*/
|
|
|
|
|
require(`../restoreradio.js`).execute(client, guilds);
|
|
|
|
|
}, 5000);
|
|
|
|
|
|
2020-03-02 19:38:42 +00:00
|
|
|
|
}
|
2020-03-08 14:22:00 +00:00
|
|
|
|
}
|