Export modules in typescript

This commit is contained in:
Christer Warén 2023-06-04 04:29:42 +03:00
parent 56f0ab5a40
commit 9303c4fcc9
38 changed files with 38 additions and 38 deletions

View File

@ -3,7 +3,7 @@ import Datastore from "./client/classes/Datastore";
import Radio from "./client/classes/Radio"; import Radio from "./client/classes/Radio";
import Stations from "./client/classes/Stations"; import Stations from "./client/classes/Stations";
import Streamer from "./client/classes/Streamer"; import Streamer from "./client/classes/Streamer";
import Statistics from "./client/classes/Statistics; import Statistics from "./client/classes/Statistics";
import fs from "fs"; import fs from "fs";
import { command, radio } from "./client/utils/typings"; import { command, radio } from "./client/utils/typings";
import config from "./config"; import config from "./config";

View File

@ -1,7 +1,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
module.exports = class { export default class {
constructor() { constructor() {
this.map = new Map(); this.map = new Map();
this.loadData(); this.loadData();

View File

@ -3,7 +3,7 @@ const {
joinVoiceChannel joinVoiceChannel
} = require("@discordjs/voice"); } = require("@discordjs/voice");
module.exports = class Radio extends Map { export default class Radio extends Map {
constructor() { constructor() {
super(); super();
} }

View File

@ -1,7 +1,7 @@
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const _importDynamic = new Function('modulePath', 'return import(modulePath)');
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
module.exports = class Stations extends Array { export default class Stations extends Array {
constructor() { constructor() {
super(); super();
this.logger = require("../funcs/logger.js"); this.logger = require("../funcs/logger.js");

View File

@ -1,4 +1,4 @@
module.exports = class { export default class Statistics {
constructor() { constructor() {
this.map = new Map(); this.map = new Map();
} }

View File

@ -5,7 +5,7 @@ const {
NoSubscriberBehavior NoSubscriberBehavior
} = require("@discordjs/voice"); } = require("@discordjs/voice");
module.exports = class { export default class Streamer {
constructor() { constructor() {
this.map = new Map(); this.map = new Map();
this.mode = null; this.mode = null;

View File

@ -4,7 +4,7 @@ const { Routes } = require('discord-api-types/v9');
const fs = require('fs'); const fs = require('fs');
const path = require ('path'); const path = require ('path');
module.exports = { export default {
async execute(client) { async execute(client) {
const commands = []; const commands = [];

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'bug', name: 'bug',
description: 'Report a bug', description: 'Report a bug',
category: 'info', category: 'info',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'help', name: 'help',
description: 'Get help using bot', description: 'Get help using bot',
category: 'info', category: 'info',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'invite', name: 'invite',
description: 'Invite Bot', description: 'Invite Bot',
category: 'info', category: 'info',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'list', name: 'list',
description: 'List radio stations', description: 'List radio stations',
category: 'radio', category: 'radio',

View File

@ -3,7 +3,7 @@ import Streamer from "../classes/Streamer";
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); const _importDynamic = new Function('modulePath', 'return import(modulePath)');
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args)); const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
module.exports = { export default {
name: 'maintenance', name: 'maintenance',
description: 'Bot Maintenance', description: 'Bot Maintenance',
category: 'info', category: 'info',

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'next', name: 'next',
description: 'Next Station', description: 'Next Station',
category: 'radio', category: 'radio',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'nowplaying', name: 'nowplaying',
description: 'Current Radio Station', description: 'Current Radio Station',
category: 'radio', category: 'radio',

View File

@ -4,7 +4,7 @@ const {
joinVoiceChannel joinVoiceChannel
} = require("@discordjs/voice"); } = require("@discordjs/voice");
module.exports = { export default {
name: "play", name: "play",
usage: "<song name>", usage: "<song name>",
description: "Play radio", description: "Play radio",

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'prev', name: 'prev',
description: 'Previous Station', description: 'Previous Station',
category: 'radio', category: 'radio',

View File

@ -1,7 +1,7 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'statistics', name: 'statistics',
description: 'Show statistics', description: 'Show statistics',
category: 'info', category: 'info',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'status', name: 'status',
description: 'Bot Status', description: 'Bot Status',
category: 'info', category: 'info',

View File

@ -1,6 +1,6 @@
import { EmbedBuilder } from "discord.js"; import { EmbedBuilder } from "discord.js";
module.exports = { export default {
name: 'stop', name: 'stop',
description: 'Stop radio', description: 'Stop radio',
category: 'radio', category: 'radio',

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'emojis', name: 'emojis',
async execute(client) { async execute(client) {
let customEmojis = { let customEmojis = {

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'SIGINT', name: 'SIGINT',
execute(client) { execute(client) {
client.user.setStatus('dnd'); client.user.setStatus('dnd');

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'SIGTERM', name: 'SIGTERM',
execute(client) { execute(client) {
process.emit('SIGINT'); process.emit('SIGINT');

View File

@ -1,6 +1,6 @@
import { PermissionFlagsBits } from "discord.js"; import { PermissionFlagsBits } from "discord.js";
module.exports = { export default {
name: 'interactionCreate', name: 'interactionCreate',
async execute(client, interaction) { async execute(client, interaction) {

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'messageDelete', name: 'messageDelete',
async execute(client, msg) { async execute(client, msg) {
if(!msg.author.bot || !msg.guild) return; if(!msg.author.bot || !msg.guild) return;

View File

@ -4,7 +4,7 @@ import Stations from "../classes/Stations";
import Streamer from "../classes/Streamer"; import Streamer from "../classes/Streamer";
import Statistics from "../classes/Statistics"; import Statistics from "../classes/Statistics";
module.exports = { export default {
name: 'ready', name: 'ready',
async execute(client) { async execute(client) {

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'uncaughtException', name: 'uncaughtException',
execute(client, error) { execute(client, error) {
client.funcs.logger("Error"); client.funcs.logger("Error");

View File

@ -4,7 +4,7 @@ const {
joinVoiceChannel joinVoiceChannel
} = require("@discordjs/voice"); } = require("@discordjs/voice");
module.exports = { export default {
name: "voiceStateUpdate", name: "voiceStateUpdate",
async execute(client, oldState, newState) { async execute(client, oldState, newState) {
if (oldState.channel === null) return; if (oldState.channel === null) return;

View File

@ -1,4 +1,4 @@
module.exports = { export default {
name: 'warning', name: 'warning',
execute(client, warning) { execute(client, warning) {
if(warning.name == "ExperimentalWarning" && warning.message.startsWith("stream/web")) return; if(warning.name == "ExperimentalWarning" && warning.message.startsWith("stream/web")) return;

View File

@ -1,4 +1,4 @@
module.exports = function check(client, interaction, command) { export default function check(client, interaction, command) {
let message = {}; let message = {};
const radio = client.radio.get(interaction.guild.id); const radio = client.radio.get(interaction.guild.id);
if(client.config.maintenanceMode){ if(client.config.maintenanceMode){

View File

@ -1,4 +1,4 @@
module.exports = function isDev(devList, authorID){ export default function isDev(devList, authorID){
let response = false; let response = false;
Object.keys(devList).forEach(function(oneDev) { Object.keys(devList).forEach(function(oneDev) {
let devID = devList[oneDev]; let devID = devList[oneDev];

View File

@ -1,6 +1,6 @@
import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js"; import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js";
module.exports = function listStations(client, interaction){ export default function listStations(client, interaction){
let stations = new Array(); let stations = new Array();
let options = new Array(); let options = new Array();

View File

@ -1,4 +1,4 @@
module.exports = function loadState(client, guild){ export default function loadState(client, guild){
let data = client.datastore.getEntry(guild.id); let data = client.datastore.getEntry(guild.id);
if(!data) return; if(!data) return;
let state; let state;

View File

@ -1,4 +1,4 @@
module.exports = function logger(area, text){ export default function logger(area, text){
let date = new Date(); let date = new Date();
console.log('[' + area + '] ' + date.toISOString()); console.log('[' + area + '] ' + date.toISOString());
if(text) console.log(text + '\n'); if(text) console.log(text + '\n');

View File

@ -1,4 +1,4 @@
module.exports = function msToTime(duration) { export default function msToTime(duration) {
let seconds = Math.floor((duration / 1000) % 60), let seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60), minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24), hours = Math.floor((duration / (1000 * 60 * 60)) % 24),

View File

@ -1,6 +1,6 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js"; 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 = {}; let message = {};
const radio = client.radio.get(guild.id); const radio = client.radio.get(guild.id);
const audioPlayer = client.streamer.listen(station); const audioPlayer = client.streamer.listen(station);

View File

@ -1,4 +1,4 @@
module.exports = function saveState(client, guild, radio){ export default function saveState(client, guild, radio){
client.datastore.checkEntry(guild.id); client.datastore.checkEntry(guild.id);
let date = new Date(); let date = new Date();

View File

@ -1,4 +1,4 @@
module.exports = { export default {
wrongVoiceChannel: "You need to be in the same voice channel as RadioX to use this command!", 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!", noPerms: "You need the %command.permission% permission to use this command!",
notPlaying: "There is nothing playing!", notPlaying: "There is nothing playing!",

View File

@ -1,6 +1,6 @@
require('dotenv/config'); require('dotenv/config');
module.exports = { export default {
//credentials //credentials
token: process.env.DISCORD_TOKEN, token: process.env.DISCORD_TOKEN,