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); fs.mkdirSync(dir);
} }
//console.log(""); //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) { for (const file of dataFiles) {
try { try {
const json = require(`../../../datastore/${file}`); const json = require(`../../../datastore/${file}`);

View File

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

View File

@ -1,5 +1,6 @@
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); 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 { export default class Stations extends Array {
logger: any; logger: any;

View File

@ -13,7 +13,7 @@ export default {
} }
let commands = ''; let commands = '';
for (let i = 0; i < categories.length; i++) { 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); 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 { ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder } from "discord.js";
import Streamer from "../classes/Streamer"; import Streamer from "../classes/Streamer";
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); 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 { export default {
name: 'maintenance', name: 'maintenance',

View File

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