Performance testing
diff --git a/src/utils/commandRegistration/slashCommandBuilder.ts b/src/utils/commandRegistration/slashCommandBuilder.ts
index 76ecabe..b2927d6 100644
--- a/src/utils/commandRegistration/slashCommandBuilder.ts
+++ b/src/utils/commandRegistration/slashCommandBuilder.ts
@@ -13,7 +13,13 @@
}
-export async function group(name: string, description: string, path: string) {
+export async function group(
+ name: string,
+ description: string,
+ path: string,
+ nameLocalizations?: Record<string, string>,
+ descriptionLocalizations?: Record<string, string>
+) {
// If the name of the command does not match the path (e.g. attachment.ts has /attachments), use commandString
console.log(`│ ├─ Loading group ${name}`)
const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path, "│ ")
@@ -22,6 +28,8 @@
subcommandGroup
.setName(name)
.setDescription(description)
+ if (nameLocalizations) { subcommandGroup.setNameLocalizations(nameLocalizations) }
+ if (descriptionLocalizations) { subcommandGroup.setDescriptionLocalizations(descriptionLocalizations) }
for (const subcommand of fetched.subcommands) {
subcommandGroup.addSubcommand(subcommand.command);
@@ -31,7 +39,16 @@
};
}
-export async function command(name: string, description: string, path: string, commandString: string | undefined = undefined) {
+export async function command(
+ name: string,
+ description: string,
+ path: string,
+ commandString: string | undefined = undefined,
+ nameLocalizations?: Record<string, string>,
+ descriptionLocalizations?: Record<string, string>,
+ userPermissions?: Discord.PermissionsString[],
+ allowedInDMs?: boolean
+) {
// If the name of the command does not match the path (e.g. attachment.ts has /attachments), use commandString
commandString = "commands/" + (commandString ?? path);
const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path);
@@ -39,6 +56,14 @@
return (command: SlashCommandBuilder) => {
command.setName(name)
command.setDescription(description)
+ command.setNameLocalizations(nameLocalizations ?? {})
+ command.setDescriptionLocalizations(descriptionLocalizations ?? {})
+ command.setDMPermission(allowedInDMs ?? false)
+ if (userPermissions) {
+ const bitfield = new Discord.PermissionsBitField()
+ bitfield.add(userPermissions)
+ command.setDefaultMemberPermissions(bitfield.bitfield)
+ }
for (const subcommand of fetched.subcommands) {
let fetchedCommand;