Fix the last of the eslint errors (for real this time)
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index ca170be..26fa66e 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -67,13 +67,12 @@
fetchReply: true
})) as Message;
const options = {
- enabled: interaction.options.getString("enabled") as string | boolean | null,
+ enabled: interaction.options.getString("enabled")?.startsWith("yes") as boolean | null,
category: interaction.options.getChannel("category"),
maxtickets: interaction.options.getNumber("maxticketsperuser"),
supportping: interaction.options.getRole("supportrole")
};
if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
- options.enabled = options.enabled === "yes" ? true : false;
if (options.category) {
let channel: GuildChannel | null;
try {
@@ -211,7 +210,8 @@
types: data.tickets.types,
customTypes: data.tickets.customTypes
};
- while (true) {
+ let timedOut = false;
+ while (!timedOut) {
embed = new EmojiEmbed()
.setTitle("Tickets")
.setDescription(
@@ -276,7 +276,8 @@
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- break;
+ timedOut = true;
+ continue;
}
i.deferUpdate();
if ((i.component as MessageActionRowComponent).customId === "clearCategory") {
@@ -312,7 +313,9 @@
description: "Click the button below to speak to us privately"
}
];
- while (true) {
+ let innerTimedOut = false;
+ let templateSelected = false;
+ while (!innerTimedOut && !templateSelected) {
const enabled = data.enabled && data.category !== null;
await interaction.editReply({
embeds: [
@@ -373,7 +376,8 @@
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- break;
+ innerTimedOut = true;
+ continue;
}
if ((i.component as MessageActionRowComponent).customId === "template") {
i.deferUpdate();
@@ -397,7 +401,8 @@
])
]
});
- break;
+ templateSelected = true;
+ continue;
} else if ((i.component as MessageActionRowComponent).customId === "blank") {
i.deferUpdate();
await interaction.channel!.send({
@@ -411,7 +416,8 @@
])
]
});
- break;
+ templateSelected = true;
+ continue;
} else if ((i.component as MessageActionRowComponent).customId === "custom") {
await i.showModal(
new Discord.Modal()
@@ -462,7 +468,8 @@
(m) => m.customId === "modify"
);
} catch (e) {
- break;
+ innerTimedOut = true;
+ continue;
}
if (out.fields) {
const title = out.fields.getTextInputValue("title");
@@ -485,9 +492,7 @@
])
]
});
- break;
- } else {
- continue;
+ templateSelected = true;
}
}
}
@@ -498,18 +503,18 @@
data.enabled = !data.enabled;
} else if ((i.component as MessageActionRowComponent).customId === "manageTypes") {
data = await manageTypes(interaction, data, m as Message);
- } else {
- break;
}
}
await interaction.editReply({
- embeds: [embed.setFooter({ text: "Message closed" })],
+ embeds: [embed.setFooter({ text: "Message timed out" })],
components: []
});
};
async function manageTypes(interaction: CommandInteraction, data: GuildConfig["tickets"], m: Message) {
- while (true) {
+ let timedOut = false;
+ let backPressed = false;
+ while (!timedOut && !backPressed) {
if (data.useCustom) {
const customTypes = data.customTypes;
await interaction.editReply({
@@ -622,7 +627,8 @@
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- break;
+ timedOut = true;
+ continue;
}
if (i.component.customId === "types") {
i.deferUpdate();
@@ -700,7 +706,7 @@
} catch {
continue;
}
- data.customTypes = data.customTypes || [];
+ data.customTypes = data.customTypes ?? [];
if (!data.customTypes.includes(toAdd)) {
data.customTypes.push(toAdd);
}
@@ -717,7 +723,7 @@
data.useCustom = true;
} else {
i.deferUpdate();
- break;
+ backPressed = true;
}
}
return data;