Fix various issues pre-switching-to-bun
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index ef7b255..4e7703c 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -230,7 +230,9 @@
let selectPaneOpen = false;
- while (true) {
+ let cancelled = false;
+ let timedOut = false;
+ while (!cancelled && !timedOut) {
let selectPane: MessageActionRow[] = [];
if (selectPaneOpen) {
@@ -297,7 +299,8 @@
time: 300000
});
} catch (e) {
- break;
+ timedOut = true;
+ continue;
}
i.deferUpdate();
if (!("customId" in i.component)) {
@@ -314,91 +317,40 @@
page = parseInt((i as SelectMenuInteraction).values[0]!);
selectPaneOpen = false;
} else {
- if (interaction) {
- const em = new Discord.MessageEmbed(pages[page]!.embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
- em.setFooter({ text: "Message closed" });
- interaction.editReply({
- embeds: [em],
- components: [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("left")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("select")
- .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle(selectPaneOpen ? "PRIMARY" : "SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("right")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])
- ]
- });
- } else {
- m.delete();
- }
- return;
+ cancelled = true;
}
}
- if (interaction) {
- const em = new Discord.MessageEmbed(pages[page]!.embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
- text: "Message timed out"
- });
- await interaction.editReply({
- embeds: [em],
- components: [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("left")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("select")
- .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("right")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])
- ]
- });
+ if (timedOut) {
+ if (interaction) {
+ const em = new Discord.MessageEmbed(pages[page]!.embed);
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
+ text: "Message timed out"
+ });
+ await interaction.editReply({
+ embeds: [em],
+ components: []
+ });
+ } else {
+ const em = new Discord.MessageEmbed(pages[page]!.embed);
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
+ text: "Message timed out"
+ });
+ await m.edit({
+ embeds: [em],
+ components: []
+ });
+ }
} else {
- const em = new Discord.MessageEmbed(pages[page]!.embed);
- em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page)).setFooter({
- text: "Message timed out"
- });
- await m.edit({
- embeds: [em],
- components: [
- new MessageActionRow().addComponents([
- new MessageButton()
- .setCustomId("left")
- .setEmoji(getEmojiByName("CONTROL.LEFT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("select")
- .setEmoji(getEmojiByName("CONTROL.MENU", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true),
- new MessageButton()
- .setCustomId("right")
- .setEmoji(getEmojiByName("CONTROL.RIGHT", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])
- ]
- });
+ if (interaction) {
+ const em = new Discord.MessageEmbed(pages[page]!.embed);
+ em.setDescription(em.description + "\n\n" + createPageIndicator(pages.length, page));
+ em.setFooter({ text: "Message closed" });
+ interaction.editReply({
+ embeds: [em],
+ components: []
+ });
+ } else {
+ m.delete();
+ }
}
};