Update bunny command to defer reply until it finds an image

This commit is contained in:
Ethan Lane 2024-04-19 18:16:25 +01:00
parent 790afcca4a
commit f3d67bb33a

View file

@ -7,7 +7,7 @@ export default class Bunny extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
this.CommandBuilder = new SlashCommandBuilder()
.setName("bunny")
.setDescription("Get a random picture of a rabbit.");
}
@ -15,6 +15,8 @@ export default class Bunny extends Command {
public override async execute(interaction: CommandInteraction) {
if (!interaction.isChatInputCommand()) return;
await interaction.deferReply();
const subreddits = [
'rabbits',
'bunnieswithhats',
@ -37,9 +39,9 @@ export default class Bunny extends Command {
.setURL(`https://reddit.com${result.Result!.Permalink}`)
.setFooter({ text: `r/${selectedSubreddit} · ${result.Result!.Ups} upvotes`});
await interaction.reply({ embeds: [ embed ]});
await interaction.editReply({ embeds: [ embed ]});
} else {
await interaction.reply("There was an error running this command.");
await interaction.editReply("There was an error running this command.");
}
}
}