From a3e062a1ffc8d414944e97ace0266360a9355fd9 Mon Sep 17 00:00:00 2001 From: Vylpes Date: Tue, 27 Dec 2022 15:18:55 +0000 Subject: [PATCH] defect/214-application-did-not-respond (#233) Co-authored-by: Ethan Lane Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/233 --- src/commands/rules.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/commands/rules.ts b/src/commands/rules.ts index f6a6406..930138c 100644 --- a/src/commands/rules.ts +++ b/src/commands/rules.ts @@ -32,13 +32,18 @@ export default class Rules extends Command { const rules = JSON.parse(rulesFile) as IRules[]; const embeds: EmbedBuilder[] = []; - + + if (rules.length == 0) { + await interaction.reply({ content: "No rules have been supplied within code base for this server.", ephemeral: true }); + return; + } + rules.forEach(rule => { const embed = new EmbedBuilder() .setColor(EmbedColours.Ok) .setTitle(rule.title || "Rules") .setDescription(rule.description ? rule.description.join("\n") : "*none*"); - + if (rule.image) { embed.setImage(rule.image); } @@ -53,9 +58,17 @@ export default class Rules extends Command { const channel = interaction.channel; if (!channel) { + await interaction.reply({ content: "Channel not found.", ephemeral: true }); return; } - + await channel.send({ embeds: embeds }); + + const successEmbed = new EmbedBuilder() + .setColor(EmbedColours.Ok) + .setTitle("Success") + .setDescription("The rules have sent to this channel successfully"); + + await interaction.reply({ embeds: [ successEmbed ], ephemeral: true }); } } \ No newline at end of file