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();
+ }
}
};
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 657e90d..850e826 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,4 +1,4 @@
-import type { Guild, User } from 'discord.js';
+import type { Guild, User } from "discord.js";
// @ts-expect-error
import type { HaikuClient } from "jshaiku";
import type { GuildMember } from "discord.js";
@@ -14,7 +14,7 @@
if (!member && !guild) return;
guild = await client.guilds.fetch(member ? member.guild.id : guild!.id);
if (!guild) return;
- user = user ?? member!.user
+ user = user ?? member!.user;
const config = await client.database.guilds.read(guild.id);
Object.entries(config.getKey("stats")).forEach(async ([channel, props]) => {
if ((props as PropSchema).enabled) {
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index f28b291..8aba46d 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,5 +1,12 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Interaction, MessageComponentInteraction, Permissions, Role } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ Interaction,
+ MessageComponentInteraction,
+ Permissions,
+ Role
+} from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import fetch from "node-fetch";
import { TestString, NSFWCheck } from "./scanners.js";
@@ -175,20 +182,17 @@
let length = 5;
let itt = 0;
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- while (true) {
+ do {
itt += 1;
code = "";
for (let i = 0; i < length; i++) {
code += chars.charAt(Math.floor(Math.random() * chars.length));
}
- if (code in verify) continue;
if (itt > 1000) {
itt = 0;
length += 1;
- continue;
}
- break;
- }
+ } while (code in verify);
const role: Role | null = await interaction.guild!.roles.fetch(config.verify.role);
if (!role) {
await interaction.editReply({