mirror of
				https://github.com/warengroup/eximiabots-radiox.git
				synced 2025-11-04 08:09:33 +00:00 
			
		
		
		
	TypeScript types
This commit is contained in:
		@@ -4,11 +4,9 @@ import Radio from "./client/classes/Radio";
 | 
			
		||||
import Stations from "./client/classes/Stations";
 | 
			
		||||
import Streamer from "./client/classes/Streamer";
 | 
			
		||||
import Statistics from "./client/classes/Statistics";
 | 
			
		||||
import fs from "fs";
 | 
			
		||||
import { command, radio } from "./client/utils/typings";
 | 
			
		||||
import { command } from "./client/utils/typings";
 | 
			
		||||
import config from "./config";
 | 
			
		||||
import messages from "./client/messages";
 | 
			
		||||
import path from "path";
 | 
			
		||||
 | 
			
		||||
const events = "./client/events/";
 | 
			
		||||
 | 
			
		||||
@@ -19,7 +17,7 @@ GatewayIntents.add(
 | 
			
		||||
    1 << 9 // GUILD_MESSAGES
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
class RadioClient extends Client {
 | 
			
		||||
export default class RadioClient extends Client {
 | 
			
		||||
    readonly commands: Collection<string, command>;
 | 
			
		||||
    public funcs: any;
 | 
			
		||||
    readonly config = config;
 | 
			
		||||
@@ -109,5 +107,3 @@ class RadioClient extends Client {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default RadioClient
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ const fs = require('fs');
 | 
			
		||||
const path = require('path');
 | 
			
		||||
 | 
			
		||||
export default class {
 | 
			
		||||
    map: Map<any, any>;
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.map = new Map();
 | 
			
		||||
        this.loadData();
 | 
			
		||||
@@ -27,7 +28,7 @@ export default class {
 | 
			
		||||
        //console.log("");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    checkEntry(id){
 | 
			
		||||
    checkEntry(id: string){
 | 
			
		||||
        this.loadEntry(id);
 | 
			
		||||
        if(!this.map.has(id)){
 | 
			
		||||
            this.createEntry(id);
 | 
			
		||||
@@ -37,8 +38,8 @@ export default class {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    createEntry(id){
 | 
			
		||||
        let newData = {};
 | 
			
		||||
    createEntry(id: string){
 | 
			
		||||
        let newData: any = {};
 | 
			
		||||
        newData.guild = {};
 | 
			
		||||
        newData.guild.id = id;
 | 
			
		||||
        newData.statistics = {};
 | 
			
		||||
@@ -47,7 +48,7 @@ export default class {
 | 
			
		||||
        this.saveEntry(id, newData);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    loadEntry(id){
 | 
			
		||||
    loadEntry(id: any){
 | 
			
		||||
        try {
 | 
			
		||||
            const json = require(`../../../datastore/` + id + '.json');
 | 
			
		||||
            this.map.set(id, json);
 | 
			
		||||
@@ -55,11 +56,11 @@ export default class {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getEntry(id){
 | 
			
		||||
    getEntry(id: string){
 | 
			
		||||
        return this.map.get(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    updateEntry(guild, newData) {
 | 
			
		||||
    updateEntry(guild: any, newData: any) {
 | 
			
		||||
        newData.guild.name = guild.name;
 | 
			
		||||
 | 
			
		||||
        let date = new Date();
 | 
			
		||||
@@ -70,7 +71,7 @@ export default class {
 | 
			
		||||
        //this.showEntry(this.getEntry(guild.id));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    showEntry(data){
 | 
			
		||||
    showEntry(data : any){
 | 
			
		||||
        console.log(data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -94,10 +95,10 @@ export default class {
 | 
			
		||||
        this.updateEntry(newData.guild, newData);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    saveEntry(file, data) {
 | 
			
		||||
    saveEntry(file: string, data: any) {
 | 
			
		||||
        data = JSON.stringify(data, null, 4);
 | 
			
		||||
 | 
			
		||||
        fs.writeFile(path.join(path.dirname(__dirname), '../../datastore') + "/" + file + ".json", data, 'utf8', function(err) {
 | 
			
		||||
        fs.writeFile(path.join(path.dirname(__dirname), '../../datastore') + "/" + file + ".json", data, 'utf8', function(err: any) {
 | 
			
		||||
            if (err) {
 | 
			
		||||
                //console.log(err);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,11 +4,12 @@ const {
 | 
			
		||||
} = require("@discordjs/voice");
 | 
			
		||||
 | 
			
		||||
export default class Radio extends Map {
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    save(client) {
 | 
			
		||||
    save(client: any) {
 | 
			
		||||
        let currentRadios = this.keys();
 | 
			
		||||
        let radio = currentRadios.next();
 | 
			
		||||
 | 
			
		||||
@@ -29,16 +30,16 @@ export default class Radio extends Map {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    restore(client, guilds) {
 | 
			
		||||
    restore(client: any, guilds: any) {
 | 
			
		||||
        if(!client.stations) return;
 | 
			
		||||
 | 
			
		||||
        guilds.forEach(async guild => {
 | 
			
		||||
        guilds.forEach(async (guild: { id: any; }) => {
 | 
			
		||||
            let state = client.funcs.loadState(client, guild);
 | 
			
		||||
            if(!state) return;
 | 
			
		||||
            if(!state.station || !state.channels.voice || !state.channels.text) return;
 | 
			
		||||
            let voiceChannel = client.channels.cache.get(state.channels.voice);
 | 
			
		||||
            if(!voiceChannel) return;
 | 
			
		||||
            if(voiceChannel.members.filter(member => !member.user.bot).size === 0) return;
 | 
			
		||||
            if(voiceChannel.members.filter((member: { user: { bot: any; }; }) => !member.user.bot).size === 0) return;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            const sstation = await client.stations.search(state.station.name, "direct");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,22 +1,24 @@
 | 
			
		||||
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
 | 
			
		||||
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
 | 
			
		||||
const fetch = (...args: any) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
 | 
			
		||||
 | 
			
		||||
export default class Stations extends Array {
 | 
			
		||||
    logger: any;
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.logger = require("../funcs/logger.js");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fetch(options){
 | 
			
		||||
    async fetch(options: any){
 | 
			
		||||
        try {
 | 
			
		||||
            this.logger('Stations', 'Started fetching list – ' + options.url);
 | 
			
		||||
            let list = await fetch(options.url)
 | 
			
		||||
                .then(this.checkFetchStatus)
 | 
			
		||||
                .then(response => response.json());
 | 
			
		||||
                .then((response: { json: () => any; }) => response.json());
 | 
			
		||||
 | 
			
		||||
            if(list){
 | 
			
		||||
                this.length = 0;
 | 
			
		||||
                list.forEach(station => {
 | 
			
		||||
                list.forEach((station: any) => {
 | 
			
		||||
                    try {
 | 
			
		||||
                        this.push(station);
 | 
			
		||||
                    } catch (error) {
 | 
			
		||||
@@ -25,12 +27,12 @@ export default class Stations extends Array {
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                if(options.show){
 | 
			
		||||
                    list.forEach(station => {
 | 
			
		||||
                    list.forEach((station: { name: any; }) => {
 | 
			
		||||
                        this.logger('Stations', station.name);
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                list.forEach(async station => {
 | 
			
		||||
                list.forEach(async (station: { stream: { [x: string]: any; default: string | number; }; }) => {
 | 
			
		||||
                    try {
 | 
			
		||||
                        let stationTest = await fetch(station.stream[station.stream.default]);
 | 
			
		||||
                        if(stationTest.ok === true) return;
 | 
			
		||||
@@ -50,7 +52,7 @@ export default class Stations extends Array {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    checkFetchStatus(response) {
 | 
			
		||||
    checkFetchStatus(response: any) {
 | 
			
		||||
        if (response.ok) { // res.status >= 200 && res.status < 300
 | 
			
		||||
            return response;
 | 
			
		||||
        } else {
 | 
			
		||||
@@ -58,7 +60,7 @@ export default class Stations extends Array {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    search(key, type) {
 | 
			
		||||
    search(key: string, type: string) {
 | 
			
		||||
        if (this === null) return false;
 | 
			
		||||
        if (!key) return false;
 | 
			
		||||
        if (!type) return false;
 | 
			
		||||
@@ -73,7 +75,7 @@ export default class Stations extends Array {
 | 
			
		||||
            return foundStation;
 | 
			
		||||
        } else {
 | 
			
		||||
 | 
			
		||||
            let foundStations = [];
 | 
			
		||||
            let foundStations : any[] = [];
 | 
			
		||||
            if (key == "radio") return false;
 | 
			
		||||
 | 
			
		||||
            this
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,13 @@
 | 
			
		||||
import { Guild } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default class Statistics {
 | 
			
		||||
    map: any;
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.map = new Map();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    update(client, guild, radio) {
 | 
			
		||||
    update(client: any, guild: Guild, radio: any) {
 | 
			
		||||
 | 
			
		||||
        client.datastore.checkEntry(guild.id);
 | 
			
		||||
 | 
			
		||||
@@ -26,13 +30,13 @@ export default class Statistics {
 | 
			
		||||
        this.calculateGlobal(client);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    calculateGlobal(client){
 | 
			
		||||
    calculateGlobal(client: any){
 | 
			
		||||
        if(!client.stations) return;
 | 
			
		||||
        if(!client.datastore.map) return;
 | 
			
		||||
 | 
			
		||||
        let guilds = client.datastore.map.keys();
 | 
			
		||||
        let stations = client.stations;
 | 
			
		||||
        let statistics = {};
 | 
			
		||||
        let statistics : any = {};
 | 
			
		||||
 | 
			
		||||
        if(!client.stations) return;
 | 
			
		||||
 | 
			
		||||
@@ -59,7 +63,7 @@ export default class Statistics {
 | 
			
		||||
            calculation = guilds.next();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let newData = {};
 | 
			
		||||
        let newData : any = {};
 | 
			
		||||
        newData.guild = {};
 | 
			
		||||
        newData.guild.id = "global";
 | 
			
		||||
        newData.guild.name = "global";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,21 @@
 | 
			
		||||
const {
 | 
			
		||||
    createAudioPlayer,
 | 
			
		||||
    createAudioResource,
 | 
			
		||||
    AudioPlayerStatus,
 | 
			
		||||
    NoSubscriberBehavior
 | 
			
		||||
} = require("@discordjs/voice");
 | 
			
		||||
 | 
			
		||||
export default class Streamer {
 | 
			
		||||
    map: any;
 | 
			
		||||
    mode: any | null;
 | 
			
		||||
    logger: any;
 | 
			
		||||
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.map = new Map();
 | 
			
		||||
        this.mode = null;
 | 
			
		||||
        this.logger = require("../funcs/logger");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    init(client){
 | 
			
		||||
    init(client: any){
 | 
			
		||||
        if(!client.config.streamerMode) return;
 | 
			
		||||
 | 
			
		||||
        switch(client.config.streamerMode){
 | 
			
		||||
@@ -29,24 +32,24 @@ export default class Streamer {
 | 
			
		||||
        if(this.mode == "auto"){
 | 
			
		||||
            if(!client.stations) return;
 | 
			
		||||
 | 
			
		||||
            client.stations.forEach(station => {
 | 
			
		||||
            client.stations.forEach((station: any) => {
 | 
			
		||||
                this.play(station);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    refresh(client){
 | 
			
		||||
    refresh(client: any){
 | 
			
		||||
        this.init(client);
 | 
			
		||||
 | 
			
		||||
        let streamers = this.map.keys();
 | 
			
		||||
        streamers.forEach(streamer => {
 | 
			
		||||
            if(client.stations.findIndex(station => station.name == streamer) == -1){
 | 
			
		||||
        streamers.forEach((streamer: any) => {
 | 
			
		||||
            if(client.stations.findIndex((station: { name: any; }) => station.name == streamer) == -1){
 | 
			
		||||
                this.stop(streamer);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    play(station) {
 | 
			
		||||
    play(station: any) {
 | 
			
		||||
        let audioPlayer = this.map.get(station.name);
 | 
			
		||||
        if(!audioPlayer) {
 | 
			
		||||
            if(this.mode == "auto"){
 | 
			
		||||
@@ -89,13 +92,13 @@ export default class Streamer {
 | 
			
		||||
            .on('autopaused', () => {
 | 
			
		||||
                this.logger('Streamer', station.name + " / " + "AutoPaused");
 | 
			
		||||
            })
 | 
			
		||||
            .on('error', error => {
 | 
			
		||||
            .on('error', (error: string) => {
 | 
			
		||||
                this.logger('Streamer', station.name + " / " + "Error" + "\n" + error);
 | 
			
		||||
            });
 | 
			
		||||
        return audioPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    stop(station){
 | 
			
		||||
    stop(station: any){
 | 
			
		||||
        let audioPlayer = this.map.get(station.name);
 | 
			
		||||
        if(audioPlayer){
 | 
			
		||||
            this.logger('Streamer', station.name + " / " + "Stop");
 | 
			
		||||
@@ -105,15 +108,15 @@ export default class Streamer {
 | 
			
		||||
        this.map.delete(station.name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    listen(station) {
 | 
			
		||||
    listen(station: any) {
 | 
			
		||||
        let audioPlayer = this.map.get(station.name);
 | 
			
		||||
        if(!audioPlayer || this.mode == "manual" && audioPlayer.subscribers.length == 0) audioPlayer = this.play(station);
 | 
			
		||||
        return audioPlayer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    leave(client) {
 | 
			
		||||
    leave(client: any) {
 | 
			
		||||
        if(!client.stations) return;
 | 
			
		||||
        client.stations.forEach(station => {
 | 
			
		||||
        client.stations.forEach((station: any) => {
 | 
			
		||||
            this.stop(station);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,10 +5,10 @@ const fs = require('fs');
 | 
			
		||||
const path = require ('path');
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    async execute(client) {
 | 
			
		||||
    async execute(client: any) {
 | 
			
		||||
 | 
			
		||||
        const commands = [];
 | 
			
		||||
        const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".ts"));
 | 
			
		||||
        const commands : any[] = [];
 | 
			
		||||
        const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter((f: string) => f.endsWith(".ts"));
 | 
			
		||||
 | 
			
		||||
        for (const file of commandFiles) {
 | 
			
		||||
            const command = require(`./commands/${file}`);
 | 
			
		||||
@@ -20,7 +20,7 @@ export default {
 | 
			
		||||
 | 
			
		||||
            command.data = command.data.toJSON();
 | 
			
		||||
            if(command.options) {
 | 
			
		||||
                command.options.forEach(function(option) {
 | 
			
		||||
                command.options.forEach(function(option: { type: string | number; }) {
 | 
			
		||||
                    if(option.type == "STRING") option.type = 3;
 | 
			
		||||
                    if(option.type == "NUMBER") option.type = 10;
 | 
			
		||||
                    command.data.options.push(option);
 | 
			
		||||
@@ -43,14 +43,14 @@ export default {
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
                    let guilds = await client.guilds.fetch();
 | 
			
		||||
                    guilds.forEach(async guild => {
 | 
			
		||||
                    guilds.forEach(async (guild: { id: string; name: string; }) => {
 | 
			
		||||
                        try {
 | 
			
		||||
                            await rest.put(
 | 
			
		||||
                                Routes.applicationGuildCommands(client.user.id, guild.id),
 | 
			
		||||
                                { body: commands }
 | 
			
		||||
                            );
 | 
			
		||||
                            client.funcs.logger('Slash Commands', 'Guild Applications – Successful' + "\n" + guild.id + " / " + guild.name);
 | 
			
		||||
                        } catch (DiscordAPIError) {
 | 
			
		||||
                        } catch (DiscordAPIError: any) {
 | 
			
		||||
                            client.funcs.logger('Slash Commands', 'Guild Applications – Failed' + "\n" + guild.id + " / " + guild.name);
 | 
			
		||||
                            if(DiscordAPIError.name != "DiscordAPIError[50001]") console.error(DiscordAPIError.message + "\n\n");
 | 
			
		||||
                        }
 | 
			
		||||
@@ -62,7 +62,7 @@ export default {
 | 
			
		||||
                    );
 | 
			
		||||
 | 
			
		||||
                    let guilds = await client.guilds.fetch();
 | 
			
		||||
                    guilds.forEach(async guild => {
 | 
			
		||||
                    guilds.forEach(async (guild: { id: any; }) => {
 | 
			
		||||
                        try {
 | 
			
		||||
                            await rest.put(
 | 
			
		||||
                                Routes.applicationGuildCommands(client.user.id, guild.id),
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@ export default {
 | 
			
		||||
    name: 'bug',
 | 
			
		||||
    description: 'Report a bug',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    async execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    async execute(interaction: any, client: any) {
 | 
			
		||||
        let message : any = {};
 | 
			
		||||
 | 
			
		||||
        message.bugTitle = client.messages.bugTitle.replace("%client.user.username%", client.user.username);
 | 
			
		||||
        message.bugDescription = client.messages.bugDescription.replace("%client.config.supportGuild%", client.config.supportGuild);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,16 +4,16 @@ export default {
 | 
			
		||||
    name: 'help',
 | 
			
		||||
    description: 'Get help using bot',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
 | 
			
		||||
        const categories = [];
 | 
			
		||||
        const categories : any= [];
 | 
			
		||||
        for (let i = 0; i < client.commands.size; i++) {
 | 
			
		||||
            if (!categories.includes([...client.commands.values()][i].category)) categories.push([...client.commands.values()][i].category);
 | 
			
		||||
        }
 | 
			
		||||
        let commands = '';
 | 
			
		||||
        for (let i = 0; i < categories.length; i++) {
 | 
			
		||||
            commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map(x => `\`${x.name}\``).join(', ')}\n`;
 | 
			
		||||
            commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map((x: { name: any; }) => `\`${x.name}\``).join(', ')}\n`;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        message.helpTitle = client.messages.helpTitle.replace("%client.user.username%", client.user.username);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@ export default {
 | 
			
		||||
    name: 'invite',
 | 
			
		||||
    description: 'Invite Bot',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
        message.inviteTitle = client.messages.inviteTitle.replace("%client.user.username%", client.user.username);
 | 
			
		||||
        const embed = new EmbedBuilder()
 | 
			
		||||
            .setTitle(message.inviteTitle)
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@ export default {
 | 
			
		||||
    name: 'list',
 | 
			
		||||
    description: 'List radio stations',
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
 | 
			
		||||
        if(!client.stations) {
 | 
			
		||||
            message.errorToGetPlaylist = client.messages.errorToGetPlaylist.replace("%client.config.supportGuild%", client.config.supportGuild);
 | 
			
		||||
@@ -20,7 +20,7 @@ export default {
 | 
			
		||||
        if(radio && !client.config.maintenanceMode){
 | 
			
		||||
            client.funcs.listStations(client, interaction);
 | 
			
		||||
        } else {
 | 
			
		||||
            let stations = `${client.stations.map(s => `**#** ${s.name}`).join('\n')}`
 | 
			
		||||
            let stations = `${client.stations.map((s: { name: any; }) => `**#** ${s.name}`).join('\n')}`
 | 
			
		||||
            const hashs = stations.split('**#**').length;
 | 
			
		||||
            for (let i = 0; i < hashs; i++) {
 | 
			
		||||
                stations = stations.replace('**#**', `**${i + 1}.**`);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,21 @@
 | 
			
		||||
import { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder } from "discord.js";
 | 
			
		||||
import Streamer from "../classes/Streamer";
 | 
			
		||||
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
 | 
			
		||||
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
 | 
			
		||||
const fetch = (...args: any) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'maintenance',
 | 
			
		||||
    description: 'Bot Maintenance',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    async execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    async execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
 | 
			
		||||
        if(!client.funcs.isDev(client.config.devId, interaction.user.id)) return interaction.reply({
 | 
			
		||||
            content: client.messageEmojis["error"] + client.messages.notAllowed,
 | 
			
		||||
            ephemeral: true
 | 
			
		||||
        });
 | 
			
		||||
        let action = interaction.options?.getNumber("action") ?? interaction.values?.[0];
 | 
			
		||||
        const options = new Array(
 | 
			
		||||
        const options: any = new Array(
 | 
			
		||||
            {
 | 
			
		||||
                emoji: "🌀",
 | 
			
		||||
                label: "Restart Bot",
 | 
			
		||||
@@ -79,12 +79,12 @@ export default {
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        client.funcs.logger('Maintenance', options.find(option => option.value == action).label);
 | 
			
		||||
        client.funcs.logger('Maintenance', options.find((option: { value: any; }) => option.value == action).label);
 | 
			
		||||
 | 
			
		||||
        const embed = new EmbedBuilder()
 | 
			
		||||
            .setTitle(client.messages.maintenanceTitle)
 | 
			
		||||
            .setColor(client.config.embedColor)
 | 
			
		||||
            .setDescription(options.find(option => option.value == action).label)
 | 
			
		||||
            .setDescription(options.find((option: { value: any; }) => option.value == action).label)
 | 
			
		||||
            .setFooter({
 | 
			
		||||
                text: client.messages.footerText,
 | 
			
		||||
                iconURL: "https://cdn.discordapp.com/emojis/" + client.messageEmojis["eximiabots"].replace(/[^0-9]+/g, '')
 | 
			
		||||
@@ -163,7 +163,7 @@ export default {
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if(!client.config.maintenanceMode){
 | 
			
		||||
                        clearInterval();
 | 
			
		||||
                        clearInterval(undefined);
 | 
			
		||||
                    }
 | 
			
		||||
                }, 500);
 | 
			
		||||
 | 
			
		||||
@@ -187,7 +187,7 @@ export default {
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if(!client.config.maintenanceMode){
 | 
			
		||||
                        clearInterval();
 | 
			
		||||
                        clearInterval(undefined);
 | 
			
		||||
                    }
 | 
			
		||||
                }, 500);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@ export default {
 | 
			
		||||
    name: 'next',
 | 
			
		||||
    description: 'Next Station',
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction, client, command) {
 | 
			
		||||
    async execute(interaction: any, client: any, command: any) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            const radio = client.radio.get(interaction.guild.id);
 | 
			
		||||
 | 
			
		||||
            let index = client.stations.findIndex(station => station.name == radio.station.name) + 1;
 | 
			
		||||
            let index = client.stations.findIndex((station: { name: any; }) => station.name == radio.station.name) + 1;
 | 
			
		||||
            if(index == client.stations.length) index = 0;
 | 
			
		||||
 | 
			
		||||
            let station = client.stations[index];
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,9 @@ export default {
 | 
			
		||||
    name: 'nowplaying',
 | 
			
		||||
    description: 'Current Radio Station',
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction, client, command) {
 | 
			
		||||
    async execute(interaction: any, client: any, command: any) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            let message = {};
 | 
			
		||||
            let message: any = {};
 | 
			
		||||
            const radio = client.radio.get(interaction.guild.id);
 | 
			
		||||
 | 
			
		||||
            let date = new Date();
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,8 @@ export default {
 | 
			
		||||
        { type: "STRING", name: "query", description: "Select station", required: false}
 | 
			
		||||
    ],
 | 
			
		||||
    category: "radio",
 | 
			
		||||
    async execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    async execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
 | 
			
		||||
        if(client.config.maintenanceMode){
 | 
			
		||||
            return interaction.reply({
 | 
			
		||||
@@ -119,7 +119,8 @@ export default {
 | 
			
		||||
            voiceChannel: voiceChannel,
 | 
			
		||||
            connection: null,
 | 
			
		||||
            message: null,
 | 
			
		||||
            station: station
 | 
			
		||||
            station: station,
 | 
			
		||||
            startTime: number
 | 
			
		||||
        };
 | 
			
		||||
        client.radio.set(interaction.guild.id, construct);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,11 @@ export default {
 | 
			
		||||
    name: 'prev',
 | 
			
		||||
    description: 'Previous Station',
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction, client, command) {
 | 
			
		||||
    async execute(interaction: any, client: any, command: any) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            const radio = client.radio.get(interaction.guild.id);
 | 
			
		||||
 | 
			
		||||
            let index = client.stations.findIndex(station => station.name == radio.station.name) - 1;
 | 
			
		||||
            let index = client.stations.findIndex((station: { name: any; }) => station.name == radio.station.name) - 1;
 | 
			
		||||
            if(index == -1) index = client.stations.length - 1;
 | 
			
		||||
 | 
			
		||||
            let station = client.stations[index];
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@ export default {
 | 
			
		||||
    name: 'statistics',
 | 
			
		||||
    description: 'Show statistics',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
        let stations = client.stations;
 | 
			
		||||
        let currentGuild = client.datastore.getEntry(interaction.guild.id);
 | 
			
		||||
        let global = client.datastore.getEntry("global");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@ export default {
 | 
			
		||||
    name: 'status',
 | 
			
		||||
    description: 'Bot Status',
 | 
			
		||||
    category: 'info',
 | 
			
		||||
    async execute(interaction, client) {
 | 
			
		||||
        let message = {};
 | 
			
		||||
    async execute(interaction: any, client: any) {
 | 
			
		||||
        let message: any = {};
 | 
			
		||||
 | 
			
		||||
        message.statusTitle = client.messages.statusTitle.replace("%client.user.username%", client.user.username);
 | 
			
		||||
        let uptime = client.funcs.msToTime(client.uptime);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ export default {
 | 
			
		||||
    name: 'stop',
 | 
			
		||||
    description: 'Stop radio',
 | 
			
		||||
    category: 'radio',
 | 
			
		||||
    async execute(interaction, client, command) {
 | 
			
		||||
    async execute(interaction: any, client: any, command: any) {
 | 
			
		||||
        if (client.funcs.check(client, interaction, command)) {
 | 
			
		||||
            const radio = client.radio.get(interaction.guild.id);
 | 
			
		||||
            client.statistics.update(client, interaction.guild, radio);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'emojis',
 | 
			
		||||
    async execute(client) {
 | 
			
		||||
        let customEmojis = {
 | 
			
		||||
    async execute(client: any): Promise<any> {
 | 
			
		||||
        let customEmojis: any = {
 | 
			
		||||
            logo: "<:RadioX:688765708808487072>",
 | 
			
		||||
            eximiabots: "<:EximiaBots:693277919929303132>",
 | 
			
		||||
            list: "<:RadioXList:688541155519889482>",
 | 
			
		||||
@@ -14,7 +14,7 @@ export default {
 | 
			
		||||
            next: "<:RadioXNext:882153637474893834>"
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        let fallbackEmojis = {
 | 
			
		||||
        let fallbackEmojis: any = {
 | 
			
		||||
            logo: "RadioX",
 | 
			
		||||
            eximiabots: "EximiaBots",
 | 
			
		||||
            list: "📜",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'SIGINT',
 | 
			
		||||
    execute(client) {
 | 
			
		||||
    execute(client: any) {
 | 
			
		||||
        client.user.setStatus('dnd');
 | 
			
		||||
 | 
			
		||||
        client.streamer.leave(client);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'SIGTERM',
 | 
			
		||||
    execute(client) {
 | 
			
		||||
    execute(client: any) {
 | 
			
		||||
        process.emit('SIGINT');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ import { PermissionFlagsBits } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'interactionCreate',
 | 
			
		||||
    async execute(client, interaction) {
 | 
			
		||||
    async execute(client: any, interaction: any) {
 | 
			
		||||
 | 
			
		||||
        const permissions = interaction.channel.permissionsFor(interaction.client.user);
 | 
			
		||||
        if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
import { Message } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'messageDelete',
 | 
			
		||||
    async execute(client, msg) {
 | 
			
		||||
    async execute(client: any, msg: Message) {
 | 
			
		||||
        if(!msg.author.bot || !msg.guild) return;
 | 
			
		||||
        const radio = client.radio.get(msg.guild.id);
 | 
			
		||||
        if(!radio) return;
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ import Statistics from "../classes/Statistics";
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'ready',
 | 
			
		||||
    async execute(client) {
 | 
			
		||||
    async execute(client: any) {
 | 
			
		||||
 | 
			
		||||
        client.funcs.logger("Bot", "Ready");
 | 
			
		||||
 | 
			
		||||
@@ -14,7 +14,7 @@ export default {
 | 
			
		||||
        client.funcs.logger('Datastore', 'Initialize');
 | 
			
		||||
        client.datastore = new Datastore();
 | 
			
		||||
 | 
			
		||||
        client.datastore.map.forEach(datastore => {
 | 
			
		||||
        client.datastore.map.forEach((datastore: { guild: { id: string; name: string; }; }) => {
 | 
			
		||||
            client.funcs.logger('Datastore', datastore.guild.id + " / " + datastore.guild.name);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +22,7 @@ export default {
 | 
			
		||||
 | 
			
		||||
        /*DEVELOPERS*/
 | 
			
		||||
        client.developers = "";
 | 
			
		||||
        let user = "";
 | 
			
		||||
        let user : any= "";
 | 
			
		||||
        for (let i = 0; i < client.config.devId.length; i++) {
 | 
			
		||||
            user = await client.users.fetch(client.config.devId[i]);
 | 
			
		||||
            client.funcs.logger('Developers', user.tag);
 | 
			
		||||
@@ -59,7 +59,7 @@ export default {
 | 
			
		||||
        client.funcs.logger('Guilds', 'Started fetching list');
 | 
			
		||||
 | 
			
		||||
        let guilds = await client.guilds.fetch();
 | 
			
		||||
        guilds.forEach(guild => {
 | 
			
		||||
        guilds.forEach((guild: { id: string; name: string; }) => {
 | 
			
		||||
            client.funcs.logger('Guilds', guild.id + " / " + guild.name);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'uncaughtException',
 | 
			
		||||
    execute(client, error) {
 | 
			
		||||
    execute(client: any, error: any) {
 | 
			
		||||
        client.funcs.logger("Error");
 | 
			
		||||
        console.log(error.stack);
 | 
			
		||||
        console.log('');
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { PermissionFlagsBits } from "discord.js";
 | 
			
		||||
import { PermissionFlagsBits, VoiceState } from "discord.js";
 | 
			
		||||
const {
 | 
			
		||||
    getVoiceConnection,
 | 
			
		||||
    joinVoiceChannel
 | 
			
		||||
@@ -6,13 +6,13 @@ const {
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    name: "voiceStateUpdate",
 | 
			
		||||
    async execute(client, oldState, newState) {
 | 
			
		||||
    async execute(client: any, oldState: VoiceState, newState: VoiceState) {
 | 
			
		||||
        if (oldState.channel === null) return;
 | 
			
		||||
        let change = false;
 | 
			
		||||
        const radio = client.radio?.get(newState.guild.id);
 | 
			
		||||
        if (!radio) return;
 | 
			
		||||
 | 
			
		||||
        if (newState.member.id === client.user.id && oldState.member.id === client.user.id) {
 | 
			
		||||
        if (newState.member?.id === client.user.id && oldState.member?.id === client.user.id) {
 | 
			
		||||
 | 
			
		||||
            if (newState.channel === null) {
 | 
			
		||||
                client.statistics.update(client, newState.guild, radio);
 | 
			
		||||
@@ -23,14 +23,14 @@ export default {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            const newPermissions = newState.channel.permissionsFor(newState.client.user);
 | 
			
		||||
            if (!newPermissions.has(PermissionFlagsBits.Connect) || !newPermissions.has(PermissionFlagsBits.Speak) || !newPermissions.has(PermissionFlagsBits.ViewChannel)) {
 | 
			
		||||
            if (!newPermissions?.has(PermissionFlagsBits.Connect) || !newPermissions?.has(PermissionFlagsBits.Speak) || !newPermissions?.has(PermissionFlagsBits.ViewChannel)) {
 | 
			
		||||
                try {
 | 
			
		||||
                    setTimeout(
 | 
			
		||||
                        async () => (
 | 
			
		||||
                            radio.connection = joinVoiceChannel({
 | 
			
		||||
                                channelId: oldState.channel.id,
 | 
			
		||||
                                guildId: oldState.channel.guild.id,
 | 
			
		||||
                                adapterCreator: oldState.channel.guild.voiceAdapterCreator
 | 
			
		||||
                                channelId: oldState.channel?.id,
 | 
			
		||||
                                guildId: oldState.channel?.guild.id,
 | 
			
		||||
                                adapterCreator: oldState.channel?.guild.voiceAdapterCreator
 | 
			
		||||
                            })
 | 
			
		||||
                            //radio.connection = await oldState.channel.join()
 | 
			
		||||
                        ),
 | 
			
		||||
@@ -55,7 +55,7 @@ export default {
 | 
			
		||||
        if ((oldState.channel.members.filter(member => !member.user.bot).size === 0 && oldState.channel === radio.voiceChannel) || change) {
 | 
			
		||||
            setTimeout(() => {
 | 
			
		||||
                if (!radio || !radio.connection || !radio.connection === null) return;
 | 
			
		||||
                if (radio.voiceChannel.members.filter(member => !member.user.bot).size === 0) {
 | 
			
		||||
                if (radio.voiceChannel.members.filter((member: { user: { bot: any; }; }) => !member.user.bot).size === 0) {
 | 
			
		||||
                    client.statistics.update(client, newState.guild, radio);
 | 
			
		||||
                    radio.connection?.destroy();
 | 
			
		||||
                    radio.message?.delete();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
export default {
 | 
			
		||||
    name: 'warning',
 | 
			
		||||
    execute(client, warning) {
 | 
			
		||||
    execute(client: any, warning: any) {
 | 
			
		||||
        if(warning.name == "ExperimentalWarning" && warning.message.startsWith("stream/web")) return;
 | 
			
		||||
 | 
			
		||||
        client.funcs.logger("Warning");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
export default function check(client, interaction, command) {
 | 
			
		||||
    let message = {};
 | 
			
		||||
export default function check(client: any, interaction: any, command: any) {
 | 
			
		||||
    let message: any = {};
 | 
			
		||||
    const radio = client.radio.get(interaction.guild.id);
 | 
			
		||||
    if(client.config.maintenanceMode){
 | 
			
		||||
        interaction.reply({
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
export default function isDev(devList, authorID){
 | 
			
		||||
export default function isDev(devList : any, authorID : any){
 | 
			
		||||
    let response = false;
 | 
			
		||||
    Object.keys(devList).forEach(function(oneDev) {
 | 
			
		||||
        let devID = devList[oneDev];
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js";
 | 
			
		||||
import { ActionRowBuilder, Interaction, StringSelectMenuBuilder } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default function listStations(client, interaction){
 | 
			
		||||
    let stations = new Array();
 | 
			
		||||
    let options = new Array();
 | 
			
		||||
export default function listStations(client: any, interaction: any){
 | 
			
		||||
    let stations: any  = new Array();
 | 
			
		||||
    let options: any = new Array();
 | 
			
		||||
 | 
			
		||||
    stations = client.stations.forEach(station => {
 | 
			
		||||
    stations = client.stations.forEach((station: { name?: any; owner?: any; label?: any; description?: any; value?: any; }) => {
 | 
			
		||||
        if(station.name == "GrooveFM") return;
 | 
			
		||||
        station = {
 | 
			
		||||
            label: station.name,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
export default function loadState(client, guild){
 | 
			
		||||
import { Guild } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default function loadState(client: any, guild: Guild){
 | 
			
		||||
    let data = client.datastore.getEntry(guild.id);
 | 
			
		||||
    if(!data) return;
 | 
			
		||||
    let state;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
export default function logger(area, text){
 | 
			
		||||
export default function logger(area : string, text: string){
 | 
			
		||||
    let date = new Date();
 | 
			
		||||
    console.log('[' + area + '] – ' + date.toISOString());
 | 
			
		||||
    if(text)  console.log(text + '\n');
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
export default function msToTime(duration) {
 | 
			
		||||
export default function msToTime(duration : number) {
 | 
			
		||||
    let seconds = Math.floor((duration / 1000) % 60),
 | 
			
		||||
        minutes = Math.floor((duration / (1000 * 60)) % 60),
 | 
			
		||||
        hours = Math.floor((duration / (1000 * 60 * 60)) % 24),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
 | 
			
		||||
 | 
			
		||||
export default async function play(client, interaction, guild, station) {
 | 
			
		||||
    let message = {};
 | 
			
		||||
export default async function play(client: any, interaction: any, guild: any, station: any) {
 | 
			
		||||
    let message: any = {};
 | 
			
		||||
    const radio = client.radio.get(guild.id);
 | 
			
		||||
    const audioPlayer = client.streamer.listen(station);
 | 
			
		||||
    radio.connection.subscribe(audioPlayer);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
export default function saveState(client, guild, radio){
 | 
			
		||||
export default function saveState(client: any, guild: any, radio: any){
 | 
			
		||||
    client.datastore.checkEntry(guild.id);
 | 
			
		||||
 | 
			
		||||
    let date = new Date();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user