děkujeme codefactoru za tento přínosný příspěvěk
This commit is contained in:
parent
6eca55d6d6
commit
390ca1c00b
12
src/app.ts
12
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<any>;
|
async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise<void>;
|
||||||
async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise<any>;
|
async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise<void>;
|
||||||
async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cmdName: string, arg?: string) {
|
async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cmdName: string, arg?: string) {
|
||||||
const jeMes = mesOrInt instanceof Message;
|
const jeMes = mesOrInt instanceof Message;
|
||||||
|
|
||||||
@ -231,8 +231,8 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
|||||||
|
|
||||||
if (typeof akce == "string") {
|
if (typeof akce == "string") {
|
||||||
const res = renderMessage(akce, arg?.split(" ") || []);
|
const res = renderMessage(akce, arg?.split(" ") || []);
|
||||||
if (mesOrInt instanceof Message) return mesOrInt.channel.send(res);
|
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(res);
|
||||||
return mesOrInt.reply(res);
|
return void mesOrInt.reply(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -240,7 +240,7 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
|||||||
const result = await akce(mesOrInt, arg);
|
const result = await akce(mesOrInt, arg);
|
||||||
if (!result) return;
|
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
|
// @ts-ignore a zas ksd
|
||||||
mesOrInt.reply(result);
|
mesOrInt.reply(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -249,7 +249,7 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
|||||||
const admin = process.env.adminID;
|
const admin = process.env.adminID;
|
||||||
|
|
||||||
const txt = `pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`;
|
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);
|
mesOrInt.reply(txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Modul na komand "anketa"
|
// 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 { Modul, SRecord } from "../utils/types";
|
||||||
import { formatter } from "../utils/utils";
|
import { formatter } from "../utils/utils";
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ async function zbytek(settings: { time: number; immediateShow: boolean; listName
|
|||||||
if (settings.immediateShow) embed.fields = fildy;
|
if (settings.immediateShow) embed.fields = fildy;
|
||||||
|
|
||||||
let zprava: Message<boolean> | InteractionResponse;
|
let zprava: Message<boolean> | InteractionResponse;
|
||||||
let edit: (c: any) => void;
|
let edit: (c: MessageCreateOptions) => void;
|
||||||
|
|
||||||
if (jeMes) {
|
if (jeMes) {
|
||||||
zprava = await mesOrInt.channel.send({ embeds: [embed], components: radky });
|
zprava = await mesOrInt.channel.send({ embeds: [embed], components: radky });
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js';
|
import { REST, RESTPostAPIChatInputApplicationCommandsJSONBody, Routes } from 'discord.js';
|
||||||
import { CClient, Modul } from '../utils/types';
|
import { CClient, Modul, SRecord } from '../utils/types';
|
||||||
|
|
||||||
const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [
|
const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [
|
||||||
{
|
{
|
||||||
@ -34,6 +34,7 @@ const komandy: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [
|
|||||||
|
|
||||||
const exp: Modul = {
|
const exp: Modul = {
|
||||||
on_ready: async () => {
|
on_ready: async () => {
|
||||||
|
const client = module.exports.client as CClient;
|
||||||
|
|
||||||
// Construct and prepare an instance of the REST module
|
// Construct and prepare an instance of the REST module
|
||||||
const rest = new REST({ version: '10' }).setToken(process.env.token!);
|
const rest = new REST({ version: '10' }).setToken(process.env.token!);
|
||||||
@ -46,7 +47,7 @@ const exp: Modul = {
|
|||||||
const data = (await rest.put(
|
const data = (await rest.put(
|
||||||
Routes.applicationCommands(client.user!.id),
|
Routes.applicationCommands(client.user!.id),
|
||||||
{ body: komandy },
|
{ body: komandy },
|
||||||
)) as any;
|
)) as SRecord<string>[] | undefined;
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user