fixed up a few commands
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 18b6c7e..70e904c 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -97,7 +97,7 @@
.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
+ .setURL(config.moderation.ban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
)
)
}
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index bdbb9ee..380bcc9 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -86,7 +86,7 @@
.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.kick.text)
- .setURL(config.moderation.kick.link)
+ .setURL(config.moderation.kick.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
)
)
}
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 3270d37..86291e5 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -252,7 +252,7 @@
.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.mute.text)
- .setURL(config.moderation.mute.link)
+ .setURL(config.moderation.mute.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
)
)
};
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index 35f275f..2787e91 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -97,7 +97,7 @@
.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.softban.text)
- .setURL(config.moderation.softban.link)
+ .setURL(config.moderation.softban.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
)
)
}
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 93241e1..8e96078 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -99,7 +99,7 @@
.addComponents(new ButtonBuilder()
.setStyle(ButtonStyle.Link)
.setLabel(config.moderation.warn.text)
- .setURL(config.moderation.warn.link)
+ .setURL(config.moderation.warn.link.replaceAll("{id}", (interaction.options.getMember("user") as GuildMember).id))
)
)
}
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)