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 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";

View File

@ -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();

View File

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

View File

@ -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");

View File

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

View File

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

View File

@ -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 = [];

View File

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

View File

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

View File

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

View File

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

View File

@ -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',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {

View File

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

View File

@ -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;

View File

@ -1,4 +1,4 @@
module.exports = {
export default {
name: 'warning',
execute(client, warning) {
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 = {};
const radio = client.radio.get(interaction.guild.id);
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;
Object.keys(devList).forEach(function(oneDev) {
let devID = devList[oneDev];

View File

@ -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();

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);
if(!data) return;
let state;

View File

@ -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');

View File

@ -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),

View File

@ -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);

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);
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!",
noPerms: "You need the %command.permission% permission to use this command!",
notPlaying: "There is nothing playing!",

View File

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