diff --git a/src/Client.ts b/src/Client.ts index cf4ad7c..7b5a4e1 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -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; public funcs: any; readonly config = config; @@ -109,5 +107,3 @@ class RadioClient extends Client { }); } } - -export default RadioClient diff --git a/src/client/classes/Datastore.ts b/src/client/classes/Datastore.ts index 60fa3bc..490e099 100644 --- a/src/client/classes/Datastore.ts +++ b/src/client/classes/Datastore.ts @@ -2,6 +2,7 @@ const fs = require('fs'); const path = require('path'); export default class { + map: Map; 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); } diff --git a/src/client/classes/Radio.ts b/src/client/classes/Radio.ts index e4f13d9..4004fd3 100644 --- a/src/client/classes/Radio.ts +++ b/src/client/classes/Radio.ts @@ -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"); diff --git a/src/client/classes/Stations.ts b/src/client/classes/Stations.ts index 11d402d..e91343f 100644 --- a/src/client/classes/Stations.ts +++ b/src/client/classes/Stations.ts @@ -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 diff --git a/src/client/classes/Statistics.ts b/src/client/classes/Statistics.ts index d78cc9b..25e264c 100644 --- a/src/client/classes/Statistics.ts +++ b/src/client/classes/Statistics.ts @@ -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"; diff --git a/src/client/classes/Streamer.ts b/src/client/classes/Streamer.ts index f1b1971..4e5055a 100644 --- a/src/client/classes/Streamer.ts +++ b/src/client/classes/Streamer.ts @@ -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); }); } diff --git a/src/client/commands.ts b/src/client/commands.ts index 9074d1b..fb7b4f8 100644 --- a/src/client/commands.ts +++ b/src/client/commands.ts @@ -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), diff --git a/src/client/commands/bug.ts b/src/client/commands/bug.ts index 0fadce8..598f94b 100644 --- a/src/client/commands/bug.ts +++ b/src/client/commands/bug.ts @@ -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); diff --git a/src/client/commands/help.ts b/src/client/commands/help.ts index 10c0f3d..3db2606 100644 --- a/src/client/commands/help.ts +++ b/src/client/commands/help.ts @@ -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); diff --git a/src/client/commands/invite.ts b/src/client/commands/invite.ts index 5754dd7..dc3b847 100644 --- a/src/client/commands/invite.ts +++ b/src/client/commands/invite.ts @@ -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) diff --git a/src/client/commands/list.ts b/src/client/commands/list.ts index 7a07c05..ea31a02 100644 --- a/src/client/commands/list.ts +++ b/src/client/commands/list.ts @@ -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}.**`); diff --git a/src/client/commands/maintenance.ts b/src/client/commands/maintenance.ts index b105ff4..03ac808 100644 --- a/src/client/commands/maintenance.ts +++ b/src/client/commands/maintenance.ts @@ -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); diff --git a/src/client/commands/next.ts b/src/client/commands/next.ts index 173f6ba..a4f8662 100644 --- a/src/client/commands/next.ts +++ b/src/client/commands/next.ts @@ -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]; diff --git a/src/client/commands/nowplaying.ts b/src/client/commands/nowplaying.ts index 8b87161..354ee03 100644 --- a/src/client/commands/nowplaying.ts +++ b/src/client/commands/nowplaying.ts @@ -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(); diff --git a/src/client/commands/play.ts b/src/client/commands/play.ts index 8a0bf2e..7f23ee0 100644 --- a/src/client/commands/play.ts +++ b/src/client/commands/play.ts @@ -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); diff --git a/src/client/commands/prev.ts b/src/client/commands/prev.ts index bb150f0..351854b 100644 --- a/src/client/commands/prev.ts +++ b/src/client/commands/prev.ts @@ -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]; diff --git a/src/client/commands/statistics.ts b/src/client/commands/statistics.ts index 6fa7a2b..1fe9090 100644 --- a/src/client/commands/statistics.ts +++ b/src/client/commands/statistics.ts @@ -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"); diff --git a/src/client/commands/status.ts b/src/client/commands/status.ts index ed81280..6bdf562 100644 --- a/src/client/commands/status.ts +++ b/src/client/commands/status.ts @@ -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); diff --git a/src/client/commands/stop.ts b/src/client/commands/stop.ts index 5744bff..a85e1d7 100644 --- a/src/client/commands/stop.ts +++ b/src/client/commands/stop.ts @@ -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); diff --git a/src/client/emojis.ts b/src/client/emojis.ts index 1afa068..df5f0a0 100644 --- a/src/client/emojis.ts +++ b/src/client/emojis.ts @@ -1,7 +1,7 @@ export default { name: 'emojis', - async execute(client) { - let customEmojis = { + async execute(client: any): Promise { + 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: "📜", diff --git a/src/client/events/SIGINT.ts b/src/client/events/SIGINT.ts index aa61eae..27ee4a3 100644 --- a/src/client/events/SIGINT.ts +++ b/src/client/events/SIGINT.ts @@ -1,6 +1,6 @@ export default { name: 'SIGINT', - execute(client) { + execute(client: any) { client.user.setStatus('dnd'); client.streamer.leave(client); diff --git a/src/client/events/SIGTERM.ts b/src/client/events/SIGTERM.ts index 110e121..911daf8 100644 --- a/src/client/events/SIGTERM.ts +++ b/src/client/events/SIGTERM.ts @@ -1,6 +1,6 @@ export default { name: 'SIGTERM', - execute(client) { + execute(client: any) { process.emit('SIGINT'); } } diff --git a/src/client/events/interactionCreate.ts b/src/client/events/interactionCreate.ts index a120811..ae15bbc 100644 --- a/src/client/events/interactionCreate.ts +++ b/src/client/events/interactionCreate.ts @@ -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; diff --git a/src/client/events/messageDelete.ts b/src/client/events/messageDelete.ts index 2837404..2b1b5b1 100644 --- a/src/client/events/messageDelete.ts +++ b/src/client/events/messageDelete.ts @@ -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; diff --git a/src/client/events/ready.ts b/src/client/events/ready.ts index 7666385..403ff64 100644 --- a/src/client/events/ready.ts +++ b/src/client/events/ready.ts @@ -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); }); diff --git a/src/client/events/uncaughtException.ts b/src/client/events/uncaughtException.ts index 7d80b89..2153077 100644 --- a/src/client/events/uncaughtException.ts +++ b/src/client/events/uncaughtException.ts @@ -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(''); diff --git a/src/client/events/voiceStateUpdate.ts b/src/client/events/voiceStateUpdate.ts index a301c27..4c4729a 100644 --- a/src/client/events/voiceStateUpdate.ts +++ b/src/client/events/voiceStateUpdate.ts @@ -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(); diff --git a/src/client/events/warning.ts b/src/client/events/warning.ts index 93031ca..a831895 100644 --- a/src/client/events/warning.ts +++ b/src/client/events/warning.ts @@ -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"); diff --git a/src/client/funcs/check.ts b/src/client/funcs/check.ts index ff6429b..c832d7f 100644 --- a/src/client/funcs/check.ts +++ b/src/client/funcs/check.ts @@ -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({ diff --git a/src/client/funcs/isDev.ts b/src/client/funcs/isDev.ts index 8106d65..5d54e06 100644 --- a/src/client/funcs/isDev.ts +++ b/src/client/funcs/isDev.ts @@ -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]; diff --git a/src/client/funcs/listStations.ts b/src/client/funcs/listStations.ts index 829abf9..0a51045 100644 --- a/src/client/funcs/listStations.ts +++ b/src/client/funcs/listStations.ts @@ -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, diff --git a/src/client/funcs/loadState.ts b/src/client/funcs/loadState.ts index 2967d77..9428bb8 100644 --- a/src/client/funcs/loadState.ts +++ b/src/client/funcs/loadState.ts @@ -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; diff --git a/src/client/funcs/logger.ts b/src/client/funcs/logger.ts index ec4b450..17d8680 100644 --- a/src/client/funcs/logger.ts +++ b/src/client/funcs/logger.ts @@ -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'); diff --git a/src/client/funcs/msToTime.ts b/src/client/funcs/msToTime.ts index 442ee95..fdb10b9 100644 --- a/src/client/funcs/msToTime.ts +++ b/src/client/funcs/msToTime.ts @@ -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), diff --git a/src/client/funcs/play.ts b/src/client/funcs/play.ts index f69596a..899075e 100644 --- a/src/client/funcs/play.ts +++ b/src/client/funcs/play.ts @@ -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); diff --git a/src/client/funcs/saveState.ts b/src/client/funcs/saveState.ts index 9814b55..4940866 100644 --- a/src/client/funcs/saveState.ts +++ b/src/client/funcs/saveState.ts @@ -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();