unknown commands not break denim again
This commit is contained in:
parent
70f224caed
commit
c6afe1835f
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.58.1",
|
||||
"version": "3001.58.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "denim_3001",
|
||||
"version": "3001.58.1",
|
||||
"version": "3001.58.2",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.16.1",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.58.1",
|
||||
"version": "3001.58.2",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
|
||||
27
src/app.ts
27
src/app.ts
@ -228,26 +228,32 @@ function handle(e: unknown, mesOrInt: Message | CommandInteraction) {
|
||||
mesOrInt.reply(txt);
|
||||
}
|
||||
|
||||
async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise<void>;
|
||||
async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise<void>;
|
||||
async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string): Promise<unknown>;
|
||||
async function runKomand(interaction: CommandInteraction, cmd: Komand, cmdName: string): Promise<unknown>;
|
||||
async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cmdName: string, arg?: string) {
|
||||
const jeMes = mesOrInt instanceof Message;
|
||||
|
||||
if (jeMes && cmd.slashRun) {
|
||||
const nazev = `${prefix}${cmdName}`;
|
||||
const id = client.slashCommandy[nazev];
|
||||
return void mesOrInt.channel.send(`tuto ejenom sleh komand </${nazev}:${id}>`);
|
||||
}
|
||||
|
||||
if (cmd.cd && jeMes) {
|
||||
const zbyva = Math.round(maKuldan(mesOrInt.author.id, cmdName, cmd.cd));
|
||||
if (zbyva) return void mesOrInt.channel.send(`si kkt vole maz kuldan jeste ${formatCas(zbyva)}`);
|
||||
if (zbyva) return mesOrInt.channel.send(`si kkt vole maz kuldan jeste ${formatCas(zbyva)}`);
|
||||
}
|
||||
|
||||
if (cmd.premium && !lidiCoMajDenimPremium.includes((mesOrInt instanceof Message) ? mesOrInt.author.id : mesOrInt.member?.user.id || "")) {
|
||||
return void mesOrInt.channel?.send("sorka bracho tuto je koamnd jenom pro curaki co platy");
|
||||
return mesOrInt.channel?.send("sorka bracho tuto je koamnd jenom pro curaki co platy");
|
||||
}
|
||||
|
||||
const akce = cmd.run ?? cmd.slashRun!;
|
||||
|
||||
if (typeof akce == "string") {
|
||||
const res = renderMessage(akce, arg?.split(" ") || []);
|
||||
if (mesOrInt instanceof Message) return void mesOrInt.channel.send(res);
|
||||
return void mesOrInt.reply(res);
|
||||
if (mesOrInt instanceof Message) return mesOrInt.channel.send(res);
|
||||
return mesOrInt.reply(res);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -255,7 +261,7 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
||||
const result = await akce(mesOrInt as never, arg || "");
|
||||
if (!result) return;
|
||||
|
||||
if (jeMes) return void mesOrInt.channel.send(result)
|
||||
if (jeMes) return mesOrInt.channel.send(result)
|
||||
.catch(e => handle(e, mesOrInt));
|
||||
// další feklo
|
||||
mesOrInt.reply(result as InteractionReplyOptions);
|
||||
@ -289,13 +295,6 @@ client.on("messageCreate", async mes => {
|
||||
const komand = client.komandy[cmdName];
|
||||
if (mes.channel.type == ChannelType.DM && komand?.DMUnsafe) return void mes.channel.send("tuten komand bohuzel v sz nefunkuje");
|
||||
|
||||
if (komand.slashRun) {
|
||||
const nazev = `${prefix}${cmdName}`;
|
||||
const id = client.slashCommandy[nazev];
|
||||
return void mes.channel.send(`tuto ejenom sleh komand </${nazev}:${id}>`);
|
||||
}
|
||||
|
||||
|
||||
if (komand) return void runKomand(mes, komand, cmdName, celArgs);
|
||||
|
||||
// neměl jsi na mysli?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user