fix(commands/administration): now the interaction will not reply if the channel is deleted

The interaction will send a message at the start of the command's
execution and a confirmation message at the end (only if the channel is
still here)
This commit is contained in:
Raphael 2025-12-05 12:16:09 +01:00 committed by Raphaël
parent 0afccf3735
commit 6b2876e514

View file

@ -42,6 +42,11 @@ export default {
const category = categoryOption as CategoryChannel;
await interaction.reply({
content: `${emoji.answer.loading} | Starting the deletion of **${category.name}**.`,
flags: MessageFlags.Ephemeral,
});
try {
for (const channel of category.children.cache.values()) {
await channel.delete(
@ -53,10 +58,11 @@ export default {
`Deleted ${category.name} (requested by ${interaction.user.username})`,
);
await interaction.reply({
content: `${emoji.answer.yes} | Deleted category **${category.name}** and its channels.`,
flags: MessageFlags.Ephemeral,
});
if (interaction.channel) {
await interaction.editReply({
content: `${emoji.answer.yes} | Deleted category **${category.name}** and its channels.`,
});
}
}
catch (err: unknown) {
log.error(err, 'Cannot delete category or its channels');