2022-07-18 20:44:19 +00:00
|
|
|
import { Client, Collection, IntentsBitField } from "discord.js";
|
2023-06-04 01:07:41 +00:00
|
|
|
import Datastore from "./client/classes/Datastore";
|
|
|
|
import Radio from "./client/classes/Radio";
|
|
|
|
import Stations from "./client/classes/Stations";
|
|
|
|
import Streamer from "./client/classes/Streamer";
|
2023-06-04 01:29:42 +00:00
|
|
|
import Statistics from "./client/classes/Statistics";
|
2023-06-04 02:48:42 +00:00
|
|
|
import { command } from "./client/utils/typings";
|
2023-06-04 01:07:41 +00:00
|
|
|
import config from "./config";
|
|
|
|
import messages from "./client/messages";
|
2021-06-08 09:01:56 +00:00
|
|
|
|
2021-09-02 15:18:37 +00:00
|
|
|
const events = "./client/events/";
|
|
|
|
|
2022-07-18 20:44:19 +00:00
|
|
|
const GatewayIntents = new IntentsBitField();
|
2021-06-08 09:01:56 +00:00
|
|
|
GatewayIntents.add(
|
|
|
|
1 << 0, // GUILDS
|
|
|
|
1 << 7, // GUILD_VOICE_STATES
|
2021-09-02 09:07:08 +00:00
|
|
|
1 << 9 // GUILD_MESSAGES
|
2021-06-08 09:01:56 +00:00
|
|
|
);
|
|
|
|
|
2023-06-04 02:48:42 +00:00
|
|
|
export default class RadioClient extends Client {
|
2021-06-08 09:01:56 +00:00
|
|
|
readonly commands: Collection<string, command>;
|
|
|
|
public funcs: any;
|
|
|
|
readonly config = config;
|
|
|
|
readonly messages = messages;
|
|
|
|
public datastore: Datastore | null;
|
2021-09-16 01:51:36 +00:00
|
|
|
public stations: Stations | null;
|
2021-09-11 14:11:10 +00:00
|
|
|
public streamer: Streamer | null;
|
2021-09-16 01:51:36 +00:00
|
|
|
public statistics: Statistics | null;
|
|
|
|
public radio: Radio | null;
|
2021-06-08 09:01:56 +00:00
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
intents: GatewayIntents
|
|
|
|
});
|
|
|
|
this.commands = new Collection();
|
|
|
|
this.datastore = null;
|
2021-09-16 01:51:36 +00:00
|
|
|
this.stations = null;
|
2021-09-11 14:11:10 +00:00
|
|
|
this.streamer = null;
|
2021-09-16 01:51:36 +00:00
|
|
|
this.statistics = null;
|
|
|
|
this.radio = null;
|
2021-06-08 09:01:56 +00:00
|
|
|
|
|
|
|
this.funcs = {};
|
2023-06-04 01:07:41 +00:00
|
|
|
this.funcs.check = require("./client/funcs/check");
|
|
|
|
this.funcs.isDev = require("./client/funcs/isDev");
|
|
|
|
this.funcs.logger = require("./client/funcs/logger");
|
|
|
|
this.funcs.msToTime = require("./client/funcs/msToTime");
|
|
|
|
this.funcs.saveState = require("./client/funcs/saveState");
|
|
|
|
this.funcs.loadState = require("./client/funcs/loadState");
|
|
|
|
this.funcs.play = require("./client/funcs/play");
|
|
|
|
this.funcs.listStations = require("./client/funcs/listStations");
|
2021-06-08 09:01:56 +00:00
|
|
|
|
2021-09-02 13:50:01 +00:00
|
|
|
console.log('RadioX ' + this.config.version);
|
|
|
|
console.log('Internet Radio to your Discord guild');
|
2022-02-22 11:18:41 +00:00
|
|
|
console.log('(c)2020-2022 EximiaBots by Warén Group');
|
2021-09-02 13:50:01 +00:00
|
|
|
console.log('');
|
|
|
|
|
|
|
|
this.funcs.logger("Bot", "Starting");
|
|
|
|
|
2021-09-09 15:55:42 +00:00
|
|
|
this.funcs.logger("Maintenance Mode", "Enabled");
|
2021-09-12 14:38:52 +00:00
|
|
|
this.config.maintenanceMode = true;
|
2021-09-09 15:55:42 +00:00
|
|
|
|
2021-06-08 09:01:56 +00:00
|
|
|
this.on("ready", () => {
|
2021-08-28 08:07:47 +00:00
|
|
|
require(`${events}ready`).execute(this);
|
2021-06-08 09:01:56 +00:00
|
|
|
});
|
2021-09-02 09:07:08 +00:00
|
|
|
|
2021-09-02 11:39:23 +00:00
|
|
|
this.on("messageDelete", msg => {
|
|
|
|
require(`${events}messageDelete`).execute(this, msg);
|
|
|
|
});
|
|
|
|
|
2021-08-18 22:50:35 +00:00
|
|
|
this.on("interactionCreate", interaction => {
|
2021-08-28 08:07:47 +00:00
|
|
|
require(`${events}interactionCreate`).execute(this, interaction);
|
2021-06-08 09:01:56 +00:00
|
|
|
});
|
2021-09-09 09:44:50 +00:00
|
|
|
|
2021-06-08 09:01:56 +00:00
|
|
|
this.on("voiceStateUpdate", (oldState, newState) => {
|
|
|
|
require(`${events}voiceStateUpdate`).execute(this, oldState, newState);
|
|
|
|
});
|
2021-09-09 09:44:50 +00:00
|
|
|
|
2021-09-09 22:21:42 +00:00
|
|
|
this.on("error", error => {
|
2021-09-09 22:44:21 +00:00
|
|
|
this.funcs.logger("Discord Client / Error");
|
2021-09-09 22:21:42 +00:00
|
|
|
console.error(error);
|
2021-09-09 22:44:21 +00:00
|
|
|
console.log('');
|
2021-09-09 22:21:42 +00:00
|
|
|
});
|
|
|
|
|
2021-09-02 13:50:01 +00:00
|
|
|
process.on('SIGINT', () => {
|
|
|
|
require(`${events}SIGINT`).execute(this);
|
|
|
|
});
|
2021-09-02 16:18:20 +00:00
|
|
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
require(`${events}SIGTERM`).execute(this);
|
|
|
|
});
|
2021-09-06 19:35:49 +00:00
|
|
|
|
|
|
|
process.on('uncaughtException', (error) => {
|
|
|
|
require(`${events}uncaughtException`).execute(this, error);
|
|
|
|
});
|
2021-09-09 09:05:39 +00:00
|
|
|
|
|
|
|
process.on('exit', () => {
|
|
|
|
this.funcs.logger("Bot", "Stopping");
|
|
|
|
});
|
2021-09-09 09:44:50 +00:00
|
|
|
|
2021-09-09 22:21:42 +00:00
|
|
|
process.on('warning', (warning) => {
|
2021-09-09 22:44:21 +00:00
|
|
|
require(`${events}warning`).execute(this, warning);
|
2021-06-08 09:01:56 +00:00
|
|
|
});
|
|
|
|
|
2021-09-09 22:54:43 +00:00
|
|
|
this.login(this.config.token).catch((err) => {
|
|
|
|
this.funcs.logger("Discord Client / Error");
|
|
|
|
console.log(err);
|
|
|
|
console.log('');
|
|
|
|
});
|
2021-06-08 09:01:56 +00:00
|
|
|
}
|
|
|
|
}
|