From 56f0ab5a40971dfd0eafdedbb63fba450d9d564e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 4 Jun 2023 04:07:41 +0300 Subject: [PATCH] TypeScript Initial --- src/Client.ts | 36 +++++++++---------- .../classes/{Datastore.js => Datastore.ts} | 0 src/client/classes/{Radio.js => Radio.ts} | 0 .../classes/{Stations.js => Stations.ts} | 0 .../classes/{Statistics.js => Statistics.ts} | 0 .../classes/{Streamer.js => Streamer.ts} | 2 +- src/client/{commands.js => commands.ts} | 2 +- src/client/commands/{bug.js => bug.ts} | 0 src/client/commands/{help.js => help.ts} | 0 src/client/commands/{invite.js => invite.ts} | 0 src/client/commands/{list.js => list.ts} | 0 .../{maintenance.js => maintenance.ts} | 2 +- src/client/commands/{next.js => next.ts} | 0 .../commands/{nowplaying.js => nowplaying.ts} | 0 src/client/commands/{play.js => play.ts} | 0 src/client/commands/{prev.js => prev.ts} | 0 .../commands/{statistics.js => statistics.ts} | 0 src/client/commands/{status.js => status.ts} | 0 src/client/commands/{stop.js => stop.ts} | 0 src/client/{emojis.js => emojis.ts} | 0 src/client/events/{SIGINT.js => SIGINT.ts} | 0 src/client/events/{SIGTERM.js => SIGTERM.ts} | 0 ...eractionCreate.js => interactionCreate.ts} | 0 .../{messageDelete.js => messageDelete.ts} | 0 src/client/events/{ready.js => ready.ts} | 10 +++--- ...aughtException.js => uncaughtException.ts} | 0 ...oiceStateUpdate.js => voiceStateUpdate.ts} | 0 src/client/events/{warning.js => warning.ts} | 0 src/client/funcs/{check.js => check.ts} | 0 src/client/funcs/{isDev.js => isDev.ts} | 0 .../{listStations.js => listStations.ts} | 0 .../funcs/{loadState.js => loadState.ts} | 0 src/client/funcs/{logger.js => logger.ts} | 0 src/client/funcs/{msToTime.js => msToTime.ts} | 0 src/client/funcs/{play.js => play.ts} | 0 .../funcs/{saveState.js => saveState.ts} | 0 src/client/{messages.js => messages.ts} | 2 -- src/{config.js => config.ts} | 0 src/{index.js => index.ts} | 0 39 files changed, 24 insertions(+), 30 deletions(-) rename src/client/classes/{Datastore.js => Datastore.ts} (100%) rename src/client/classes/{Radio.js => Radio.ts} (100%) rename src/client/classes/{Stations.js => Stations.ts} (100%) rename src/client/classes/{Statistics.js => Statistics.ts} (100%) rename src/client/classes/{Streamer.js => Streamer.ts} (98%) rename src/client/{commands.js => commands.ts} (98%) rename src/client/commands/{bug.js => bug.ts} (100%) rename src/client/commands/{help.js => help.ts} (100%) rename src/client/commands/{invite.js => invite.ts} (100%) rename src/client/commands/{list.js => list.ts} (100%) rename src/client/commands/{maintenance.js => maintenance.ts} (99%) rename src/client/commands/{next.js => next.ts} (100%) rename src/client/commands/{nowplaying.js => nowplaying.ts} (100%) rename src/client/commands/{play.js => play.ts} (100%) rename src/client/commands/{prev.js => prev.ts} (100%) rename src/client/commands/{statistics.js => statistics.ts} (100%) rename src/client/commands/{status.js => status.ts} (100%) rename src/client/commands/{stop.js => stop.ts} (100%) rename src/client/{emojis.js => emojis.ts} (100%) rename src/client/events/{SIGINT.js => SIGINT.ts} (100%) rename src/client/events/{SIGTERM.js => SIGTERM.ts} (100%) rename src/client/events/{interactionCreate.js => interactionCreate.ts} (100%) rename src/client/events/{messageDelete.js => messageDelete.ts} (100%) rename src/client/events/{ready.js => ready.ts} (91%) rename src/client/events/{uncaughtException.js => uncaughtException.ts} (100%) rename src/client/events/{voiceStateUpdate.js => voiceStateUpdate.ts} (100%) rename src/client/events/{warning.js => warning.ts} (100%) rename src/client/funcs/{check.js => check.ts} (100%) rename src/client/funcs/{isDev.js => isDev.ts} (100%) rename src/client/funcs/{listStations.js => listStations.ts} (100%) rename src/client/funcs/{loadState.js => loadState.ts} (100%) rename src/client/funcs/{logger.js => logger.ts} (100%) rename src/client/funcs/{msToTime.js => msToTime.ts} (100%) rename src/client/funcs/{play.js => play.ts} (100%) rename src/client/funcs/{saveState.js => saveState.ts} (100%) rename src/client/{messages.js => messages.ts} (75%) rename src/{config.js => config.ts} (100%) rename src/{index.js => index.ts} (100%) diff --git a/src/Client.ts b/src/Client.ts index 18a83b5..b7240f9 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,13 +1,13 @@ import { Client, Collection, IntentsBitField } from "discord.js"; -import Datastore from "./client/classes/Datastore.js"; -import Radio from "./client/classes/Radio.js"; -import Stations from "./client/classes/Stations.js"; -import Streamer from "./client/classes/Streamer.js"; -import Statistics from "./client/classes/Statistics.js"; +import Datastore from "./client/classes/Datastore"; +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.js"; -import config from "./config.js"; -import messages from "./client/messages.js"; +import { command, radio } from "./client/utils/typings"; +import config from "./config"; +import messages from "./client/messages"; import path from "path"; const events = "./client/events/"; @@ -41,14 +41,14 @@ class RadioClient extends Client { this.radio = null; this.funcs = {}; - this.funcs.check = require("./client/funcs/check.js"); - this.funcs.isDev = require("./client/funcs/isDev.js"); - this.funcs.logger = require("./client/funcs/logger.js"); - this.funcs.msToTime = require("./client/funcs/msToTime.js"); - this.funcs.saveState = require("./client/funcs/saveState.js"); - this.funcs.loadState = require("./client/funcs/loadState.js"); - this.funcs.play = require("./client/funcs/play.js"); - this.funcs.listStations = require("./client/funcs/listStations.js"); + 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"); console.log('RadioX ' + this.config.version); console.log('Internet Radio to your Discord guild'); @@ -64,10 +64,6 @@ class RadioClient extends Client { require(`${events}ready`).execute(this); }); - this.on("messageCreate", msg => { - require(`${events}messageCreate`).execute(this, msg); - }); - this.on("messageDelete", msg => { require(`${events}messageDelete`).execute(this, msg); }); diff --git a/src/client/classes/Datastore.js b/src/client/classes/Datastore.ts similarity index 100% rename from src/client/classes/Datastore.js rename to src/client/classes/Datastore.ts diff --git a/src/client/classes/Radio.js b/src/client/classes/Radio.ts similarity index 100% rename from src/client/classes/Radio.js rename to src/client/classes/Radio.ts diff --git a/src/client/classes/Stations.js b/src/client/classes/Stations.ts similarity index 100% rename from src/client/classes/Stations.js rename to src/client/classes/Stations.ts diff --git a/src/client/classes/Statistics.js b/src/client/classes/Statistics.ts similarity index 100% rename from src/client/classes/Statistics.js rename to src/client/classes/Statistics.ts diff --git a/src/client/classes/Streamer.js b/src/client/classes/Streamer.ts similarity index 98% rename from src/client/classes/Streamer.js rename to src/client/classes/Streamer.ts index 3ed27de..68a849a 100644 --- a/src/client/classes/Streamer.js +++ b/src/client/classes/Streamer.ts @@ -9,7 +9,7 @@ module.exports = class { constructor() { this.map = new Map(); this.mode = null; - this.logger = require("../funcs/logger.js"); + this.logger = require("../funcs/logger"); } init(client){ diff --git a/src/client/commands.js b/src/client/commands.ts similarity index 98% rename from src/client/commands.js rename to src/client/commands.ts index 4eb46d9..7d2bff0 100644 --- a/src/client/commands.js +++ b/src/client/commands.ts @@ -8,7 +8,7 @@ module.exports = { async execute(client) { const commands = []; - const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".js")); + const commandFiles = fs.readdirSync(path.join("./src/client/commands")).filter(f => f.endsWith(".ts")); for (const file of commandFiles) { const command = require(`./commands/${file}`); diff --git a/src/client/commands/bug.js b/src/client/commands/bug.ts similarity index 100% rename from src/client/commands/bug.js rename to src/client/commands/bug.ts diff --git a/src/client/commands/help.js b/src/client/commands/help.ts similarity index 100% rename from src/client/commands/help.js rename to src/client/commands/help.ts diff --git a/src/client/commands/invite.js b/src/client/commands/invite.ts similarity index 100% rename from src/client/commands/invite.js rename to src/client/commands/invite.ts diff --git a/src/client/commands/list.js b/src/client/commands/list.ts similarity index 100% rename from src/client/commands/list.js rename to src/client/commands/list.ts diff --git a/src/client/commands/maintenance.js b/src/client/commands/maintenance.ts similarity index 99% rename from src/client/commands/maintenance.js rename to src/client/commands/maintenance.ts index 3098cc0..d84b083 100644 --- a/src/client/commands/maintenance.js +++ b/src/client/commands/maintenance.ts @@ -1,5 +1,5 @@ import { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder } from "discord.js"; -import Streamer from "../classes/Streamer.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)); diff --git a/src/client/commands/next.js b/src/client/commands/next.ts similarity index 100% rename from src/client/commands/next.js rename to src/client/commands/next.ts diff --git a/src/client/commands/nowplaying.js b/src/client/commands/nowplaying.ts similarity index 100% rename from src/client/commands/nowplaying.js rename to src/client/commands/nowplaying.ts diff --git a/src/client/commands/play.js b/src/client/commands/play.ts similarity index 100% rename from src/client/commands/play.js rename to src/client/commands/play.ts diff --git a/src/client/commands/prev.js b/src/client/commands/prev.ts similarity index 100% rename from src/client/commands/prev.js rename to src/client/commands/prev.ts diff --git a/src/client/commands/statistics.js b/src/client/commands/statistics.ts similarity index 100% rename from src/client/commands/statistics.js rename to src/client/commands/statistics.ts diff --git a/src/client/commands/status.js b/src/client/commands/status.ts similarity index 100% rename from src/client/commands/status.js rename to src/client/commands/status.ts diff --git a/src/client/commands/stop.js b/src/client/commands/stop.ts similarity index 100% rename from src/client/commands/stop.js rename to src/client/commands/stop.ts diff --git a/src/client/emojis.js b/src/client/emojis.ts similarity index 100% rename from src/client/emojis.js rename to src/client/emojis.ts diff --git a/src/client/events/SIGINT.js b/src/client/events/SIGINT.ts similarity index 100% rename from src/client/events/SIGINT.js rename to src/client/events/SIGINT.ts diff --git a/src/client/events/SIGTERM.js b/src/client/events/SIGTERM.ts similarity index 100% rename from src/client/events/SIGTERM.js rename to src/client/events/SIGTERM.ts diff --git a/src/client/events/interactionCreate.js b/src/client/events/interactionCreate.ts similarity index 100% rename from src/client/events/interactionCreate.js rename to src/client/events/interactionCreate.ts diff --git a/src/client/events/messageDelete.js b/src/client/events/messageDelete.ts similarity index 100% rename from src/client/events/messageDelete.js rename to src/client/events/messageDelete.ts diff --git a/src/client/events/ready.js b/src/client/events/ready.ts similarity index 91% rename from src/client/events/ready.js rename to src/client/events/ready.ts index 1b58d91..d4a2d5b 100644 --- a/src/client/events/ready.js +++ b/src/client/events/ready.ts @@ -1,8 +1,8 @@ -import Datastore from "../classes/Datastore.js"; -import Radio from "../classes/Radio.js"; -import Stations from "../classes/Stations.js"; -import Streamer from "../classes/Streamer.js"; -import Statistics from "../classes/Statistics.js"; +import Datastore from "../classes/Datastore"; +import Radio from "../classes/Radio"; +import Stations from "../classes/Stations"; +import Streamer from "../classes/Streamer"; +import Statistics from "../classes/Statistics"; module.exports = { name: 'ready', diff --git a/src/client/events/uncaughtException.js b/src/client/events/uncaughtException.ts similarity index 100% rename from src/client/events/uncaughtException.js rename to src/client/events/uncaughtException.ts diff --git a/src/client/events/voiceStateUpdate.js b/src/client/events/voiceStateUpdate.ts similarity index 100% rename from src/client/events/voiceStateUpdate.js rename to src/client/events/voiceStateUpdate.ts diff --git a/src/client/events/warning.js b/src/client/events/warning.ts similarity index 100% rename from src/client/events/warning.js rename to src/client/events/warning.ts diff --git a/src/client/funcs/check.js b/src/client/funcs/check.ts similarity index 100% rename from src/client/funcs/check.js rename to src/client/funcs/check.ts diff --git a/src/client/funcs/isDev.js b/src/client/funcs/isDev.ts similarity index 100% rename from src/client/funcs/isDev.js rename to src/client/funcs/isDev.ts diff --git a/src/client/funcs/listStations.js b/src/client/funcs/listStations.ts similarity index 100% rename from src/client/funcs/listStations.js rename to src/client/funcs/listStations.ts diff --git a/src/client/funcs/loadState.js b/src/client/funcs/loadState.ts similarity index 100% rename from src/client/funcs/loadState.js rename to src/client/funcs/loadState.ts diff --git a/src/client/funcs/logger.js b/src/client/funcs/logger.ts similarity index 100% rename from src/client/funcs/logger.js rename to src/client/funcs/logger.ts diff --git a/src/client/funcs/msToTime.js b/src/client/funcs/msToTime.ts similarity index 100% rename from src/client/funcs/msToTime.js rename to src/client/funcs/msToTime.ts diff --git a/src/client/funcs/play.js b/src/client/funcs/play.ts similarity index 100% rename from src/client/funcs/play.js rename to src/client/funcs/play.ts diff --git a/src/client/funcs/saveState.js b/src/client/funcs/saveState.ts similarity index 100% rename from src/client/funcs/saveState.js rename to src/client/funcs/saveState.ts diff --git a/src/client/messages.js b/src/client/messages.ts similarity index 75% rename from src/client/messages.js rename to src/client/messages.ts index b50f160..7352e8e 100644 --- a/src/client/messages.js +++ b/src/client/messages.ts @@ -35,7 +35,5 @@ module.exports = { statusField4: ":hourglass: Latency", statusField5: ":globe_with_meridians: Hosted by", errorStationURL: "Station can't be URL", - messageCommandsDeprecatedTitle: "%client.user.username%", - messageCommandsDeprecatedDescription: "We recommend you to reauthorize our bot by clicking the invite link down below, because Discord is planning to remove message content from verified bots [Read More](https://support-dev.discord.com/hc/en-us/articles/4404772028055)" + "\n\n" + "**Invite Bot**" + "\n" + "https://wgi.fi/radiox_invite" + "\n\n" + "This bot now supports slash commands, you should start using them instead. Type / into the message box and select the bot you wish to use. Remember to be careful as there are a few bugs here and there on Discord." + "\n\n" + "We will remove this deprecation message in March of 2022 when RadioX 1.0.0 is released.", maintenance: "Shhhh... We are now sleeping and dreaming about new features to implement. Will be back soon." }; diff --git a/src/config.js b/src/config.ts similarity index 100% rename from src/config.js rename to src/config.ts diff --git a/src/index.js b/src/index.ts similarity index 100% rename from src/index.js rename to src/index.ts