From 9303c4fcc969fa9feca59a051cf8954f1d9444ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 4 Jun 2023 04:29:42 +0300 Subject: [PATCH] Export modules in typescript --- src/Client.ts | 2 +- src/client/classes/Datastore.ts | 2 +- src/client/classes/Radio.ts | 2 +- src/client/classes/Stations.ts | 2 +- src/client/classes/Statistics.ts | 2 +- src/client/classes/Streamer.ts | 2 +- src/client/commands.ts | 2 +- src/client/commands/bug.ts | 2 +- src/client/commands/help.ts | 2 +- src/client/commands/invite.ts | 2 +- src/client/commands/list.ts | 2 +- src/client/commands/maintenance.ts | 2 +- src/client/commands/next.ts | 2 +- src/client/commands/nowplaying.ts | 2 +- src/client/commands/play.ts | 2 +- src/client/commands/prev.ts | 2 +- src/client/commands/statistics.ts | 2 +- src/client/commands/status.ts | 2 +- src/client/commands/stop.ts | 2 +- src/client/emojis.ts | 2 +- src/client/events/SIGINT.ts | 2 +- src/client/events/SIGTERM.ts | 2 +- src/client/events/interactionCreate.ts | 2 +- src/client/events/messageDelete.ts | 2 +- src/client/events/ready.ts | 2 +- src/client/events/uncaughtException.ts | 2 +- src/client/events/voiceStateUpdate.ts | 2 +- src/client/events/warning.ts | 2 +- src/client/funcs/check.ts | 2 +- src/client/funcs/isDev.ts | 2 +- src/client/funcs/listStations.ts | 2 +- src/client/funcs/loadState.ts | 2 +- src/client/funcs/logger.ts | 2 +- src/client/funcs/msToTime.ts | 2 +- src/client/funcs/play.ts | 2 +- src/client/funcs/saveState.ts | 2 +- src/client/messages.ts | 2 +- src/config.ts | 2 +- 38 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index b7240f9..cf4ad7c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -3,7 +3,7 @@ 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 Statistics from "./client/classes/Statistics"; import fs from "fs"; import { command, radio } from "./client/utils/typings"; import config from "./config"; diff --git a/src/client/classes/Datastore.ts b/src/client/classes/Datastore.ts index bf0ce66..60fa3bc 100644 --- a/src/client/classes/Datastore.ts +++ b/src/client/classes/Datastore.ts @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); -module.exports = class { +export default class { constructor() { this.map = new Map(); this.loadData(); diff --git a/src/client/classes/Radio.ts b/src/client/classes/Radio.ts index 7990782..e4f13d9 100644 --- a/src/client/classes/Radio.ts +++ b/src/client/classes/Radio.ts @@ -3,7 +3,7 @@ const { joinVoiceChannel } = require("@discordjs/voice"); -module.exports = class Radio extends Map { +export default class Radio extends Map { constructor() { super(); } diff --git a/src/client/classes/Stations.ts b/src/client/classes/Stations.ts index 67d67c5..11d402d 100644 --- a/src/client/classes/Stations.ts +++ b/src/client/classes/Stations.ts @@ -1,7 +1,7 @@ const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); -module.exports = class Stations extends Array { +export default class Stations extends Array { constructor() { super(); this.logger = require("../funcs/logger.js"); diff --git a/src/client/classes/Statistics.ts b/src/client/classes/Statistics.ts index 78bfac5..d78cc9b 100644 --- a/src/client/classes/Statistics.ts +++ b/src/client/classes/Statistics.ts @@ -1,4 +1,4 @@ -module.exports = class { +export default class Statistics { constructor() { this.map = new Map(); } diff --git a/src/client/classes/Streamer.ts b/src/client/classes/Streamer.ts index 68a849a..f1b1971 100644 --- a/src/client/classes/Streamer.ts +++ b/src/client/classes/Streamer.ts @@ -5,7 +5,7 @@ const { NoSubscriberBehavior } = require("@discordjs/voice"); -module.exports = class { +export default class Streamer { constructor() { this.map = new Map(); this.mode = null; diff --git a/src/client/commands.ts b/src/client/commands.ts index 7d2bff0..9074d1b 100644 --- a/src/client/commands.ts +++ b/src/client/commands.ts @@ -4,7 +4,7 @@ const { Routes } = require('discord-api-types/v9'); const fs = require('fs'); const path = require ('path'); -module.exports = { +export default { async execute(client) { const commands = []; diff --git a/src/client/commands/bug.ts b/src/client/commands/bug.ts index 87bac4a..0fadce8 100644 --- a/src/client/commands/bug.ts +++ b/src/client/commands/bug.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'bug', description: 'Report a bug', category: 'info', diff --git a/src/client/commands/help.ts b/src/client/commands/help.ts index 8c96388..10c0f3d 100644 --- a/src/client/commands/help.ts +++ b/src/client/commands/help.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'help', description: 'Get help using bot', category: 'info', diff --git a/src/client/commands/invite.ts b/src/client/commands/invite.ts index d1bc453..5754dd7 100644 --- a/src/client/commands/invite.ts +++ b/src/client/commands/invite.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'invite', description: 'Invite Bot', category: 'info', diff --git a/src/client/commands/list.ts b/src/client/commands/list.ts index 50378c1..7a07c05 100644 --- a/src/client/commands/list.ts +++ b/src/client/commands/list.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'list', description: 'List radio stations', category: 'radio', diff --git a/src/client/commands/maintenance.ts b/src/client/commands/maintenance.ts index d84b083..b105ff4 100644 --- a/src/client/commands/maintenance.ts +++ b/src/client/commands/maintenance.ts @@ -3,7 +3,7 @@ import Streamer from "../classes/Streamer"; const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); -module.exports = { +export default { name: 'maintenance', description: 'Bot Maintenance', category: 'info', diff --git a/src/client/commands/next.ts b/src/client/commands/next.ts index 268752a..173f6ba 100644 --- a/src/client/commands/next.ts +++ b/src/client/commands/next.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'next', description: 'Next Station', category: 'radio', diff --git a/src/client/commands/nowplaying.ts b/src/client/commands/nowplaying.ts index 3b7b830..8b87161 100644 --- a/src/client/commands/nowplaying.ts +++ b/src/client/commands/nowplaying.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'nowplaying', description: 'Current Radio Station', category: 'radio', diff --git a/src/client/commands/play.ts b/src/client/commands/play.ts index b1e816b..8a0bf2e 100644 --- a/src/client/commands/play.ts +++ b/src/client/commands/play.ts @@ -4,7 +4,7 @@ const { joinVoiceChannel } = require("@discordjs/voice"); -module.exports = { +export default { name: "play", usage: "", description: "Play radio", diff --git a/src/client/commands/prev.ts b/src/client/commands/prev.ts index d73093f..bb150f0 100644 --- a/src/client/commands/prev.ts +++ b/src/client/commands/prev.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'prev', description: 'Previous Station', category: 'radio', diff --git a/src/client/commands/statistics.ts b/src/client/commands/statistics.ts index 00d3876..6fa7a2b 100644 --- a/src/client/commands/statistics.ts +++ b/src/client/commands/statistics.ts @@ -1,7 +1,7 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'statistics', description: 'Show statistics', category: 'info', diff --git a/src/client/commands/status.ts b/src/client/commands/status.ts index 67e0ac6..ed81280 100644 --- a/src/client/commands/status.ts +++ b/src/client/commands/status.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'status', description: 'Bot Status', category: 'info', diff --git a/src/client/commands/stop.ts b/src/client/commands/stop.ts index 83516f0..5744bff 100644 --- a/src/client/commands/stop.ts +++ b/src/client/commands/stop.ts @@ -1,6 +1,6 @@ import { EmbedBuilder } from "discord.js"; -module.exports = { +export default { name: 'stop', description: 'Stop radio', category: 'radio', diff --git a/src/client/emojis.ts b/src/client/emojis.ts index 61af51a..1afa068 100644 --- a/src/client/emojis.ts +++ b/src/client/emojis.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'emojis', async execute(client) { let customEmojis = { diff --git a/src/client/events/SIGINT.ts b/src/client/events/SIGINT.ts index b7f11f1..aa61eae 100644 --- a/src/client/events/SIGINT.ts +++ b/src/client/events/SIGINT.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'SIGINT', execute(client) { client.user.setStatus('dnd'); diff --git a/src/client/events/SIGTERM.ts b/src/client/events/SIGTERM.ts index 62c4830..110e121 100644 --- a/src/client/events/SIGTERM.ts +++ b/src/client/events/SIGTERM.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'SIGTERM', execute(client) { process.emit('SIGINT'); diff --git a/src/client/events/interactionCreate.ts b/src/client/events/interactionCreate.ts index b368e5f..a120811 100644 --- a/src/client/events/interactionCreate.ts +++ b/src/client/events/interactionCreate.ts @@ -1,6 +1,6 @@ import { PermissionFlagsBits } from "discord.js"; -module.exports = { +export default { name: 'interactionCreate', async execute(client, interaction) { diff --git a/src/client/events/messageDelete.ts b/src/client/events/messageDelete.ts index 01d3431..2837404 100644 --- a/src/client/events/messageDelete.ts +++ b/src/client/events/messageDelete.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'messageDelete', async execute(client, msg) { if(!msg.author.bot || !msg.guild) return; diff --git a/src/client/events/ready.ts b/src/client/events/ready.ts index d4a2d5b..7666385 100644 --- a/src/client/events/ready.ts +++ b/src/client/events/ready.ts @@ -4,7 +4,7 @@ import Stations from "../classes/Stations"; import Streamer from "../classes/Streamer"; import Statistics from "../classes/Statistics"; -module.exports = { +export default { name: 'ready', async execute(client) { diff --git a/src/client/events/uncaughtException.ts b/src/client/events/uncaughtException.ts index e3c27e2..7d80b89 100644 --- a/src/client/events/uncaughtException.ts +++ b/src/client/events/uncaughtException.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'uncaughtException', execute(client, error) { client.funcs.logger("Error"); diff --git a/src/client/events/voiceStateUpdate.ts b/src/client/events/voiceStateUpdate.ts index 09d7dc4..a301c27 100644 --- a/src/client/events/voiceStateUpdate.ts +++ b/src/client/events/voiceStateUpdate.ts @@ -4,7 +4,7 @@ const { joinVoiceChannel } = require("@discordjs/voice"); -module.exports = { +export default { name: "voiceStateUpdate", async execute(client, oldState, newState) { if (oldState.channel === null) return; diff --git a/src/client/events/warning.ts b/src/client/events/warning.ts index 537c089..93031ca 100644 --- a/src/client/events/warning.ts +++ b/src/client/events/warning.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'warning', execute(client, warning) { if(warning.name == "ExperimentalWarning" && warning.message.startsWith("stream/web")) return; diff --git a/src/client/funcs/check.ts b/src/client/funcs/check.ts index 8a7c153..ff6429b 100644 --- a/src/client/funcs/check.ts +++ b/src/client/funcs/check.ts @@ -1,4 +1,4 @@ -module.exports = function check(client, interaction, command) { +export default function check(client, interaction, command) { let message = {}; const radio = client.radio.get(interaction.guild.id); if(client.config.maintenanceMode){ diff --git a/src/client/funcs/isDev.ts b/src/client/funcs/isDev.ts index 8be3ac9..8106d65 100644 --- a/src/client/funcs/isDev.ts +++ b/src/client/funcs/isDev.ts @@ -1,4 +1,4 @@ -module.exports = function isDev(devList, authorID){ +export default function isDev(devList, authorID){ 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 94a5e94..829abf9 100644 --- a/src/client/funcs/listStations.ts +++ b/src/client/funcs/listStations.ts @@ -1,6 +1,6 @@ import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js"; -module.exports = function listStations(client, interaction){ +export default function listStations(client, interaction){ let stations = new Array(); let options = new Array(); diff --git a/src/client/funcs/loadState.ts b/src/client/funcs/loadState.ts index d56c275..2967d77 100644 --- a/src/client/funcs/loadState.ts +++ b/src/client/funcs/loadState.ts @@ -1,4 +1,4 @@ -module.exports = function loadState(client, guild){ +export default function loadState(client, 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 ec39d1a..ec4b450 100644 --- a/src/client/funcs/logger.ts +++ b/src/client/funcs/logger.ts @@ -1,4 +1,4 @@ -module.exports = function logger(area, text){ +export default function logger(area, text){ 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 07fdb9a..442ee95 100644 --- a/src/client/funcs/msToTime.ts +++ b/src/client/funcs/msToTime.ts @@ -1,4 +1,4 @@ -module.exports = function msToTime(duration) { +export default function msToTime(duration) { 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 83fc28a..f69596a 100644 --- a/src/client/funcs/play.ts +++ b/src/client/funcs/play.ts @@ -1,6 +1,6 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js"; -module.exports = async function play(client, interaction, guild, station) { +export default async function play(client, interaction, guild, station) { let message = {}; const radio = client.radio.get(guild.id); const audioPlayer = client.streamer.listen(station); diff --git a/src/client/funcs/saveState.ts b/src/client/funcs/saveState.ts index 6ef476a..9814b55 100644 --- a/src/client/funcs/saveState.ts +++ b/src/client/funcs/saveState.ts @@ -1,4 +1,4 @@ -module.exports = function saveState(client, guild, radio){ +export default function saveState(client, guild, radio){ client.datastore.checkEntry(guild.id); let date = new Date(); diff --git a/src/client/messages.ts b/src/client/messages.ts index 7352e8e..979038e 100644 --- a/src/client/messages.ts +++ b/src/client/messages.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!", noPerms: "You need the %command.permission% permission to use this command!", notPlaying: "There is nothing playing!", diff --git a/src/config.ts b/src/config.ts index 668ae51..2bdc4ed 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,6 @@ require('dotenv/config'); -module.exports = { +export default { //credentials token: process.env.DISCORD_TOKEN,