COMMAND REGISTRATION WORKS
diff --git a/src/commands/mod/_meta.ts b/src/commands/mod/_meta.ts
index 7bdd813..987a1c1 100644
--- a/src/commands/mod/_meta.ts
+++ b/src/commands/mod/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "mod";
const description = "Perform moderator actions";
-export { name, description };
+const subcommand = await command(name, description, `mod`)
+
+export { name, description, subcommand as command };
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 9b24b0c..5f4f41c 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -6,11 +6,13 @@
import addPlurals from "../../utils/plurals.js";
import client from "../../utils/client.js";
+
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("ban")
.setDescription("Bans a user from the server")
.addUserOption((option) => option.setName("user").setDescription("The user to ban").setRequired(true))
+ .addStringOption((option) => option.setName("reason").setDescription("The reason for the ban").setRequired(false))
.addNumberOption((option) =>
option
.setName("delete")
@@ -20,6 +22,7 @@
.setRequired(false)
);
+
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
// TODO:[Modals] Replace this with a modal
@@ -34,12 +37,12 @@
.setTitle("Ban")
.setDescription(
keyValueList({
- user: renderUser(interaction.options.getUser("user")),
+ user: renderUser(interaction.options.getUser("user")!),
reason: reason ? "\n> " + (reason).replaceAll("\n", "\n> ") : "*No reason provided*"
}) +
`The user **will${notify ? "" : " not"}** be notified\n` +
`${addPlurals(
- interaction.options.getNumber("delete") ?? 0,
+ (interaction.options.get("delete")?.value as number | null) ?? 0,
"day"
)} of messages will be deleted\n\n` +
`Are you sure you want to ban <@!${(interaction.options.getMember("user") as GuildMember).id}>?`
@@ -80,18 +83,14 @@
)
.setStatus("Danger")
],
- components: [
- new ActionRowBuilder().addComponents(
- config.moderation.ban.text
- ? [
- new ButtonBuilder()
- .setStyle(ButtonStyle.Link)
- .setLabel(config.moderation.ban.text)
- .setURL(config.moderation.ban.link)
- ]
- : []
- )
- ]
+ components: config.moderation.ban.text ? [
+ new ActionRowBuilder().addComponents([
+ new ButtonBuilder()
+ .setStyle(ButtonStyle.Link)
+ .setLabel(config.moderation.ban.text)
+ .setURL(config.moderation.ban.link!)
+ ])
+ ] : []
});
dmd = true;
}
diff --git a/src/commands/mod/nick.ts b/src/commands/mod/nick.ts
index 9a101e8..b5e5554 100644
--- a/src/commands/mod/nick.ts
+++ b/src/commands/mod/nick.ts
@@ -1,18 +1,19 @@
import { CommandInteraction, GuildMember } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import keyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("nick")
- .setDescription("Changes a users nickname")
- .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
- .addStringOption((option) =>
- option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
- );
+
+const command = (builder: SlashCommandSubcommandBuilder) => builder
+ .setName("nick")
+ .setDescription("Changes a users nickname")
+ .addUserOption((option) => option.setName("user").setDescription("The user to change").setRequired(true))
+ .addStringOption((option) =>
+ option.setName("name").setDescription("The name to set | Leave blank to clear").setRequired(false)
+ );
+
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { renderUser } = client.logger;
diff --git a/src/commands/mod/slowmode.ts b/src/commands/mod/slowmode.ts
index 654fbcc..3e883b3 100644
--- a/src/commands/mod/slowmode.ts
+++ b/src/commands/mod/slowmode.ts
@@ -15,22 +15,22 @@
.setName("time")
.setDescription("The delay between messages")
.setRequired(false)
- .addChoices([
- ["Off", "0"],
- ["5 seconds", "5"],
- ["10 seconds", "10"],
- ["15 seconds", "15"],
- ["30 seconds", "30"],
- ["1 minute", "60"],
- ["2 minutes", "120"],
- ["5 minutes", "300"],
- ["10 minutes", "600"],
- ["15 minutes", "900"],
- ["30 minutes", "1800"],
- ["1 hour", "3600"],
- ["2 hours", "7200"],
- ["6 hours", "21600"]
- ])
+ .addChoices(
+ {name: "Off", value: "0"},
+ {name: "5 seconds", value: "5"},
+ {name: "10 seconds", value: "10"},
+ {name: "15 seconds", value: "15"},
+ {name: "30 seconds", value: "30"},
+ {name: "1 minute", value: "60"},
+ {name: "2 minutes", value: "120"},
+ {name: "5 minutes", value: "300"},
+ {name: "10 minutes", value: "600"},
+ {name: "15 minutes", value: "900"},
+ {name: "30 minutes", value: "1800"},
+ {name: "1 hour", value: "3600"},
+ {name: "2 hours", value: "7200"},
+ {name: "6 hours", value: "21600"}
+ )
);
const callback = async (interaction: CommandInteraction): Promise<void> => {
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index ca68a70..a713f55 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -7,7 +7,7 @@
SelectMenuBuilder,
ButtonStyle
} from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import pageIndicator from "../../utils/createPageIndicator.js";