mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 10:49:20 +00:00
Fixed say crash if the bot don't have permission
This commit is contained in:
+24
-5
@@ -28,6 +28,13 @@ const EMBEDS = {
|
|||||||
user: data instanceof Interaction ? data.user : data.author
|
user: data instanceof Interaction ? data.user : data.author
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
SAY_ERROR: (data: Message | Interaction, error: any) => {
|
||||||
|
return makeErrorEmbed({
|
||||||
|
title: `Unable to say`,
|
||||||
|
description: error.message,
|
||||||
|
user: data instanceof Interaction ? data.user : data.author
|
||||||
|
});
|
||||||
|
},
|
||||||
SUCCESSFULLY_SAID: (data: Message | Interaction) => {
|
SUCCESSFULLY_SAID: (data: Message | Interaction) => {
|
||||||
return makeSuccessEmbed({
|
return makeSuccessEmbed({
|
||||||
title: 'Successfully said',
|
title: 'Successfully said',
|
||||||
@@ -90,15 +97,27 @@ export default class Say extends DiscordModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.isSlashCommand() && data.getChannel()) {
|
if (data.isSlashCommand() && data.getChannel()) {
|
||||||
await data.getChannel()!.send({ content: query });
|
try {
|
||||||
await data
|
await data.getChannel()!.send({ content: query });
|
||||||
.getMessageComponentInteraction()
|
await data
|
||||||
.reply({ ephemeral: true, embeds: [EMBEDS.SUCCESSFULLY_SAID(data.getRaw())] });
|
.getMessageComponentInteraction()
|
||||||
|
.reply({ ephemeral: true, embeds: [EMBEDS.SUCCESSFULLY_SAID(data.getRaw())] });
|
||||||
|
} catch (err: any) {
|
||||||
|
return await sendHybridInteractionMessageResponse(data, {
|
||||||
|
embeds: [EMBEDS.SAY_ERROR(data.getRaw(), err)]
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (data.isMessage()) {
|
} else if (data.isMessage()) {
|
||||||
const message = data.getMessage();
|
const message = data.getMessage();
|
||||||
if (message.deletable) await message.delete();
|
if (message.deletable) await message.delete();
|
||||||
|
|
||||||
await data.getChannel()!.send({ content: query });
|
try {
|
||||||
|
await data.getChannel()!.send({ content: query });
|
||||||
|
} catch (err: any) {
|
||||||
|
return await sendHybridInteractionMessageResponse(data, {
|
||||||
|
embeds: [EMBEDS.SAY_ERROR(data.getRaw(), err)]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user