Typescript Continue

This commit is contained in:
Christer Warén 2023-06-04 06:20:37 +03:00
parent 3fc7337d0f
commit fb36a8f890
6 changed files with 13 additions and 14 deletions

View File

@ -14,7 +14,7 @@ export default class {
fs.mkdirSync(dir);
}
//console.log("");
const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../../datastore')).filter(f => f.endsWith('.json'));
const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../../datastore')).filter((f: string) => f.endsWith('.json'));
for (const file of dataFiles) {
try {
const json = require(`../../../datastore/${file}`);

View File

@ -47,7 +47,7 @@ export default class Radio extends Map {
if(!station) return;
const construct = {
const construct: any = {
textChannel: client.channels.cache.get(state.channels.text),
voiceChannel: client.channels.cache.get(state.channels.voice),
connection: null,

View File

@ -1,5 +1,6 @@
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
const fetch = (...args: any) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
// @ts-ignore
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
export default class Stations extends Array {
logger: any;

View File

@ -13,7 +13,7 @@ export default {
}
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: { name: any; }) => `\`${x.name}\``).join(', ')}\n`;
commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter((x: { category: any; omitFromHelp: any; }) => 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);

View File

@ -1,7 +1,8 @@
import { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder } from "discord.js";
import Streamer from "../classes/Streamer";
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
const fetch = (...args: any) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
// @ts-ignore
const fetch = (...args) => _importDynamic('node-fetch').then(({default: fetch}) => fetch(...args));
export default {
name: 'maintenance',

View File

@ -34,7 +34,7 @@ export default {
if(!query){
return client.funcs.listStations(client, interaction);
}
let url = query ? query.replace(/<(.+)>/g, "$1") : "";
const radio = client.radio.get(interaction.guild.id);
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) return interaction.reply({
@ -65,13 +65,9 @@ export default {
});
}
let station;
const number = parseInt(query - 1);
if (url.startsWith("http")) {
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.errorStationURL,
ephemeral: true
});
} else if (!isNaN(number)) {
if (!isNaN(query)) {
const number = parseInt((query - 1) as unknown as string);
if (number > client.stations.length - 1) {
return interaction.reply({
content: client.messageEmojis["error"] + client.messages.wrongStationNumber,
@ -114,13 +110,14 @@ export default {
return;
}
let date = new Date();
const construct = {
textChannel: interaction.channel,
voiceChannel: voiceChannel,
connection: null,
message: null,
station: station,
startTime: number
startTime: date.getTime()
};
client.radio.set(interaction.guild.id, construct);