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:
parent
0afccf3735
commit
6b2876e514
1 changed files with 10 additions and 4 deletions
|
|
@ -42,6 +42,11 @@ export default {
|
||||||
|
|
||||||
const category = categoryOption as CategoryChannel;
|
const category = categoryOption as CategoryChannel;
|
||||||
|
|
||||||
|
await interaction.reply({
|
||||||
|
content: `${emoji.answer.loading} | Starting the deletion of **${category.name}**.`,
|
||||||
|
flags: MessageFlags.Ephemeral,
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const channel of category.children.cache.values()) {
|
for (const channel of category.children.cache.values()) {
|
||||||
await channel.delete(
|
await channel.delete(
|
||||||
|
|
@ -53,11 +58,12 @@ export default {
|
||||||
`Deleted ${category.name} (requested by ${interaction.user.username})`,
|
`Deleted ${category.name} (requested by ${interaction.user.username})`,
|
||||||
);
|
);
|
||||||
|
|
||||||
await interaction.reply({
|
if (interaction.channel) {
|
||||||
|
await interaction.editReply({
|
||||||
content: `${emoji.answer.yes} | Deleted category **${category.name}** and its channels.`,
|
content: `${emoji.answer.yes} | Deleted category **${category.name}** and its channels.`,
|
||||||
flags: MessageFlags.Ephemeral,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (err: unknown) {
|
catch (err: unknown) {
|
||||||
log.error(err, 'Cannot delete category or its channels');
|
log.error(err, 'Cannot delete category or its channels');
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue