fixed up a few commands
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index ac2cd81..25034b2 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, TextInputComponent, Role, ButtonStyle, ButtonComponent, TextInputBuilder } from "discord.js";
+import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, Role, ButtonStyle, ButtonComponent, TextInputBuilder } from "discord.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
@@ -43,7 +43,7 @@
let timedOut = false;
while (!timedOut) {
const config = await client.database.guilds.read(interaction.guild!.id);
- const moderation = config["moderation"];
+ const moderation = config.moderation;
m = await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -117,7 +117,7 @@
continue;
}
type modIDs = "mute" | "kick" | "ban" | "softban" | "warn" | "role";
- let chosen = moderation[i.customId as modIDs] ?? { text: null, url: null };
+ let chosen = moderation[i.customId as modIDs];
if ((i.component as ButtonComponent).customId === "clearMuteRole") {
i.deferUpdate();
if (clicked === "clearMuteRole") {
@@ -181,31 +181,28 @@
])
]
});
- let out: Discord.ModalSubmitInteraction;
+ let out: Discord.ModalSubmitInteraction | null;
try {
out = await modalInteractionCollector(
m,
(m) => m.channel!.id === interaction.channel!.id,
(_) => true
- ) as Discord.ModalSubmitInteraction;
+ ) as Discord.ModalSubmitInteraction | null;
} catch (e) {
continue;
}
- if ((out!).fields) {
- const buttonText = out.fields.getTextInputValue("name");
- const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
- const current = chosen;
- if (current.text !== buttonText || current.link !== buttonLink) {
- chosen = { text: buttonText, link: buttonLink };
- await client.database.guilds.write(interaction.guild!.id, {
- ["moderation." + i.customId]: {
- text: buttonText,
- link: buttonLink
- }
- });
- }
- } else {
- continue;
+ if (!out) continue
+ const buttonText = out.fields.getTextInputValue("name");
+ const buttonLink = out.fields.getTextInputValue("url").replace(/{id}/gi, "{id}");
+ const current = chosen;
+ if (current.text !== buttonText || current.link !== buttonLink) {
+ chosen = { text: buttonText, link: buttonLink };
+ await client.database.guilds.write(interaction.guild!.id, {
+ ["moderation." + i.customId]: {
+ text: buttonText,
+ link: buttonLink
+ }
+ });
}
}
}
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index b840fb0..cdd218b 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -20,7 +20,8 @@
.setAutocomplete(true)
);
-const callback = async (interaction: CommandInteraction): Promise<unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => { // TODO: This command feels unintuitive. Clicking a channel in the select menu deletes it
+ // instead, it should give a submenu to edit the channel, enable/disable or delete it
singleNotify("statsChannelDeleted", interaction.guild!.id, true);
const m = (await interaction.reply({
embeds: LoadingEmbed,
@@ -30,7 +31,7 @@
let config = await client.database.guilds.read(interaction.guild!.id);
if (interaction.options.get("name")?.value as string) {
let channel;
- if (Object.keys(config["stats"]).length >= 25) {
+ if (Object.keys(config.stats).length >= 25) {
return await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -151,7 +152,7 @@
let timedOut = false;
while (!timedOut) {
config = await client.database.guilds.read(interaction.guild!.id);
- const stats = config["stats"];
+ const stats = config.stats;
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("remove")
.setMinValues(1)