From 390ca1c00bf9c3b1d701586c2caf8850d6cad5c7 Mon Sep 17 00:00:00 2001 From: Histmy Date: Sun, 5 Mar 2023 15:04:50 +0100 Subject: [PATCH] =?UTF-8?q?d=C4=9Bkujeme=20codefactoru=20za=20tento=20p?= =?UTF-8?q?=C5=99=C3=ADnosn=C3=BD=20p=C5=99=C3=ADsp=C4=9Bv=C4=9Bk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 12 ++++++------ src/modules/anketa.ts | 4 ++-- src/modules/registerSlashCommands.ts | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app.ts b/src/app.ts index f7f908b..5cf9f10 100644 --- a/src/app.ts +++ b/src/app.ts @@ -215,8 +215,8 @@ function renderMessage(expression: string, args: string[]) { } } -async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise; -async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise; +async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise; +async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise; async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cmdName: string, arg?: string) { const jeMes = mesOrInt instanceof Message; @@ -231,8 +231,8 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm if (typeof akce == "string") { const res = renderMessage(akce, arg?.split(" ") || []); - if (mesOrInt instanceof Message) return mesOrInt.channel.send(res); - return mesOrInt.reply(res); + if (mesOrInt instanceof Message) return void mesOrInt.channel.send(res); + return void mesOrInt.reply(res); } try { @@ -240,7 +240,7 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm const result = await akce(mesOrInt, arg); if (!result) return; - if (mesOrInt instanceof Message) return mesOrInt.channel.send(result); + if (mesOrInt instanceof Message) return void mesOrInt.channel.send(result); // @ts-ignore a zas ksd mesOrInt.reply(result); } catch (e) { @@ -249,7 +249,7 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm const admin = process.env.adminID; const txt = `pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`; - if (mesOrInt instanceof Message) return mesOrInt.channel.send(txt); + if (mesOrInt instanceof Message) return void mesOrInt.channel.send(txt); mesOrInt.reply(txt); } } diff --git a/src/modules/anketa.ts b/src/modules/anketa.ts index 064a41f..5395692 100644 --- a/src/modules/anketa.ts +++ b/src/modules/anketa.ts @@ -1,6 +1,6 @@ // Modul na komand "anketa" -import { ActionRowBuilder, APIEmbed, APIEmbedField, ButtonBuilder, ButtonStyle, CommandInteraction, ComponentType, InteractionResponse, Message, MessageComponentInteraction } from "discord.js"; +import { ActionRowBuilder, APIEmbed, APIEmbedField, ButtonBuilder, ButtonStyle, CommandInteraction, ComponentType, InteractionResponse, Message, MessageComponentInteraction, MessageCreateOptions } from "discord.js"; import { Modul, SRecord } from "../utils/types"; import { formatter } from "../utils/utils"; @@ -54,7 +54,7 @@ async function zbytek(settings: { time: number; immediateShow: boolean; listName if (settings.immediateShow) embed.fields = fildy; let zprava: Message | InteractionResponse; - let edit: (c: any) => void; + let edit: (c: MessageCreateOptions) => void; if (jeMes) { zprava = await mesOrInt.channel.send({ embeds: [embed], components: radky }); diff --git a/src/modules/registerSlashCommands.ts b/src/modules/registerSlashCommands.ts index ff74661..f7740fd 100644 --- a/src/modules/registerSlashCommands.ts +++ b/src/modules/registerSlashCommands.ts @@ -1,5 +1,5 @@ import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js'; -import { CClient, Modul } from '../utils/types'; +import { CClient, Modul, SRecord } from '../utils/types'; const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [ { @@ -34,6 +34,7 @@ const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [ const exp: Modul = { on_ready: async () => { + const client = module.exports.client as CClient; // Construct and prepare an instance of the REST module const rest = new REST({ version: '10' }).setToken(process.env.token!); @@ -46,7 +47,7 @@ const exp: Modul = { const data = (await rest.put( Routes.applicationCommands(client.user!.id), { body: komandy }, - )) as any; + )) as SRecord[] | undefined; console.log(data);