COMMAND REGISTRATION WORKS
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 141d061..4fd1202 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -8,7 +8,6 @@
ButtonStyle
} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import addPlural from "../utils/plurals.js";
@@ -259,7 +258,7 @@
return;
};
-const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = async (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
const me = interaction.guild.me!;
if (!me.permissions.has("MANAGE_ROLES")) throw new Error("I do not have the *Manage Roles* permission");
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index 79cd402..f5660fe 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,8 +1,6 @@
import { LoadingEmbed } from "../utils/defaultEmbeds.js";
import { CommandInteraction, GuildChannel, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, ButtonStyle } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
-// @ts-expect-error
-import type { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import client from "../utils/client.js";
import addPlural from "../utils/plurals.js";
@@ -120,7 +118,7 @@
console.log(categorised);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/api/index.ts b/src/api/index.ts
index e5f0c38..b6f82f8 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,4 +1,4 @@
-import type { HaikuClient } from "jshaiku";
+import type { Client } from 'discord.js';
import express from "express";
import bodyParser from "body-parser";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -8,7 +8,7 @@
const app = express();
const port = 10000;
-const runServer = (client: HaikuClient) => {
+const runServer = (client: Client) => {
app.get("/", (req, res) => {
res.status(200).send(client.ws.ping);
});
diff --git a/src/commands/help.ts b/src/commands/help.ts
index df44aaa..4295f9c 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -1,14 +1,13 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
const command = new SlashCommandBuilder().setName("help").setDescription("Shows help for commands");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- interaction.reply("hel p"); // TODO: FINISH THIS FOR RELEASE
+ interaction.reply("hel p D:"); // TODO: FINISH THIS FOR RELEASE
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
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";
diff --git a/src/commands/nucleus/_meta.ts b/src/commands/nucleus/_meta.ts
index a79a596..751feca 100644
--- a/src/commands/nucleus/_meta.ts
+++ b/src/commands/nucleus/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "nucleus";
const description = "Commands relating to Nucleus itself";
-export { name, description };
+const subcommand = await command(name, description, `settings/logs`)
+
+export { name, description, subcommand as command };
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index bdd55af..49c80fb 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -1,6 +1,5 @@
import Discord, { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
@@ -63,7 +62,7 @@
}
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index 8fce0b8..a427688 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,7 +1,6 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { SelectMenuOption, SlashCommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import { SlashCommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import createPageIndicator from "../utils/createPageIndicator.js";
@@ -232,7 +231,7 @@
});
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/commands/role/_meta.ts b/src/commands/role/_meta.ts
index c5936c9..f546d51 100644
--- a/src/commands/role/_meta.ts
+++ b/src/commands/role/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "role";
const description = "Change roles for users";
-export { name, description };
+const subcommand = await command(name, description, `role`);
+
+export { name, description, subcommand as command };
diff --git a/src/commands/role/user.ts b/src/commands/role/user.ts
index bdadd9d..ac94b47 100644
--- a/src/commands/role/user.ts
+++ b/src/commands/role/user.ts
@@ -1,6 +1,5 @@
import { CommandInteraction, GuildMember, Role } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
@@ -21,10 +20,10 @@
.setName("action")
.setDescription("The action to perform")
.setRequired(true)
- .addChoices([
- ["Add", "give"],
- ["Remove", "remove"]
- ])
+ .addChoices(
+ {name: "Add", value: "give"},
+ {name: "Remove", value: "remove"}
+ )
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
@@ -91,7 +90,7 @@
}
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
const me = interaction.guild.me!;
const apply = interaction.options.getMember("user") as GuildMember | null;
diff --git a/src/commands/rolemenu.ts b/src/commands/rolemenu.ts
index dd3cb34..9aad543 100644
--- a/src/commands/rolemenu.ts
+++ b/src/commands/rolemenu.ts
@@ -1,6 +1,5 @@
-import { CommandInteraction } from "discord.js";
+import type { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import { callback as roleMenu } from "../actions/roleMenu.js";
const command = new SlashCommandBuilder()
@@ -11,7 +10,7 @@
await roleMenu(interaction);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/commands/server/_meta.ts b/src/commands/server/_meta.ts
index 5c0ba48..250951b 100644
--- a/src/commands/server/_meta.ts
+++ b/src/commands/server/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "server";
const description = "Commands for the server";
-export { name, description };
+const subcommand = await command(name, description, `server`);
+
+export { name, description, subcommand as command };
diff --git a/src/commands/server/about.ts b/src/commands/server/about.ts
index 116071e..b895768 100644
--- a/src/commands/server/about.ts
+++ b/src/commands/server/about.ts
@@ -1,6 +1,5 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import type { CommandInteraction } from "discord.js";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import generateKeyValueList, { toCapitals } from "../../utils/generateKeyValueList.js";
@@ -55,7 +54,7 @@
});
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/commands/settings/_meta.ts b/src/commands/settings/_meta.ts
index 1241322..76e570d 100644
--- a/src/commands/settings/_meta.ts
+++ b/src/commands/settings/_meta.ts
@@ -1,4 +1,9 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "settings";
const description = "Change bot settings";
-export { name, description };
+
+const subcommand = await command(name, description, "settings")
+
+export { name, description, subcommand as command};
diff --git a/src/commands/settings/commands.ts b/src/commands/settings/commands.ts
index 5260858..4493f79 100644
--- a/src/commands/settings/commands.ts
+++ b/src/commands/settings/commands.ts
@@ -3,7 +3,6 @@
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
@@ -208,7 +207,7 @@
}
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
throw new Error("You must have the *Manage Server* permission to use this command");
diff --git a/src/commands/settings/logs/_meta.ts b/src/commands/settings/logs/_meta.ts
index fadff33..24a1e54 100644
--- a/src/commands/settings/logs/_meta.ts
+++ b/src/commands/settings/logs/_meta.ts
@@ -1,4 +1,8 @@
+import { group } from "../../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "logs";
const description = "Settings for logging";
-export { name, description };
+const subcommand = await group(name, description, `settings/logs`)
+
+export { name, description, subcommand as command};
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index 38f66fb..7d4fef3 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -4,8 +4,7 @@
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -16,7 +15,7 @@
option
.setName("channel")
.setDescription("The channel to log attachments in")
- .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ .addChannelTypes(ChannelType.GuildText)
.setRequired(false)
);
@@ -189,7 +188,7 @@
});
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
throw new Error("You must have the *Manage Server* permission to use this command");
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index a06198d..0288bf7 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -5,7 +5,6 @@
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -16,7 +15,7 @@
option
.setName("channel")
.setDescription("The channel to set the log channel to")
- .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ .addChannelTypes(ChannelType.GuildText)
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
@@ -181,7 +180,7 @@
});
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
throw new Error("You must have the *Manage Server* permission to use this command");
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 793d1fa..9eaf25c 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,7 +1,6 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, Message, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, ButtonStyle } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import client from "../../../utils/client.js";
import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
@@ -104,7 +103,7 @@
return;
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
throw new Error("You must have the *Manage Server* permission to use this command");
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 44b8d69..c1b2380 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -5,8 +5,6 @@
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-// @ts-expect-error
-import type { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -17,7 +15,7 @@
option
.setName("channel")
.setDescription("The channel to set the staff notifications channel to")
- .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ .addChannelTypes(ChannelType.GuildText)
.setRequired(false)
);
@@ -187,7 +185,7 @@
});
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
throw new Error("You must have the *Manage Server* permission to use this command");
diff --git a/src/commands/settings/rolemenu.ts b/src/commands/settings/rolemenu.ts
index b9464b5..02ab93e 100644
--- a/src/commands/settings/rolemenu.ts
+++ b/src/commands/settings/rolemenu.ts
@@ -1,6 +1,5 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
@@ -13,7 +12,7 @@
await interaction.reply("You're mum");
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_ROLES"))
throw Error("You must have the *Manage Roles* permission to use this command");
diff --git a/src/commands/settings/stats.ts b/src/commands/settings/stats.ts
index 1bcd49d..f19998a 100644
--- a/src/commands/settings/stats.ts
+++ b/src/commands/settings/stats.ts
@@ -3,7 +3,6 @@
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import client from "../../utils/client.js";
import convertCurlyBracketString from "../../utils/convertCurlyBracketString.js";
import { callback as statsChannelAddCallback } from "../../reflex/statsChannelUpdate.js";
@@ -218,7 +217,7 @@
});
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_CHANNELS"))
throw new Error("You must have the *Manage Channels* permission to use this command");
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index d6dee70..48d419d 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -16,7 +16,7 @@
TextInputComponent,
ButtonStyle
} from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { ChannelType } from "discord-api-types/v9";
import client from "../../utils/client.js";
import { toHexInteger, toHexArray, tickets as ticketTypes } from "../../utils/calculate.js";
@@ -33,16 +33,16 @@
.setName("enabled")
.setDescription("If users should be able to create tickets")
.setRequired(false)
- .addChoices([
- ["Yes", "yes"],
- ["No", "no"]
- ])
+ .addChoices(
+ {name: "Yes", value: "yes"},
+ {name: "No",value: "no"}
+ )
)
.addChannelOption((option) =>
option
.setName("category")
.setDescription("The category where tickets are created")
- .addChannelType(ChannelType.GuildCategory)
+ .addChannelTypes(ChannelType.GuildCategory)
.setRequired(false)
)
.addNumberOption((option) =>
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 679a63d..5284f8a 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -37,7 +37,7 @@
option
.setName("channel")
.setDescription("The channel the welcome message should be sent to")
- .addChannelTypes([ChannelType.GuildText, ChannelType.GuildNews])
+ .addChannelTypes(ChannelType.GuildText)
);
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
diff --git a/src/commands/tags/_meta.ts b/src/commands/tags/_meta.ts
index 2ce5318..aa4fe55 100644
--- a/src/commands/tags/_meta.ts
+++ b/src/commands/tags/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "tags";
const description = "manage server tags";
-export { name, description };
+const subcommand = await command(name, description, `tags`);
+
+export { name, description, subcommand as command };
diff --git a/src/commands/ticket/_meta.ts b/src/commands/ticket/_meta.ts
index e484928..2e0dbbf 100644
--- a/src/commands/ticket/_meta.ts
+++ b/src/commands/ticket/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "ticket";
const description = "Manage modmail tickets";
-export { name, description };
+const subcommand = await command(name, description, `ticket`);
+
+export { name, description, subcommand as command };
diff --git a/src/commands/user/_meta.ts b/src/commands/user/_meta.ts
index 8677d79..0c8bc6b 100644
--- a/src/commands/user/_meta.ts
+++ b/src/commands/user/_meta.ts
@@ -1,4 +1,8 @@
+import { command } from "../../utils/commandRegistration/slashCommandBuilder.js";
+
const name = "user";
const description = "Commands for user info";
-export { name, description };
+const subcommand = await command(name, description, `user`);
+
+export { name, description, subcommand as command };
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index a6c319d..00be0c9 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -1,6 +1,5 @@
import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
import client from "../../utils/client.js";
@@ -35,7 +34,7 @@
});
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index a8a837b..dd736aa 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -1,8 +1,6 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, GuildMember, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
-import { SelectMenuOption, SlashCommandSubcommandBuilder } from "@discordjs/builders";
-// @ts-expect-error
-import { WrappedCheck } from "jshaiku";
+import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
import addPlural from "../../utils/plurals.js";
@@ -205,7 +203,7 @@
}
};
-const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = async (interaction: CommandInteraction) => {
const tracks = (await client.database.guilds.read(interaction.guild.id)).tracks;
if (tracks.length === 0) throw new Error("This server does not have any tracks");
const member = interaction.member as GuildMember;
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index f2c9c9d..b9556a6 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,7 +1,5 @@
import type { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
-// @ts-expect-error
-import { WrappedCheck } from "jshaiku";
import verify from "../reflex/verify.js";
const command = new SlashCommandBuilder().setName("verify").setDescription("Get verified in the server");
@@ -10,7 +8,7 @@
verify(interaction);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (_interaction: CommandInteraction) => {
return true;
};
diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts
index 2aa8ec7..f3a4785 100644
--- a/src/events/channelCreate.ts
+++ b/src/events/channelCreate.ts
@@ -1,10 +1,9 @@
import type { GuildAuditLogsEntry } from "discord.js";
import type { GuildBasedChannel } from "discord.js";
-// @ts-expect-error
-import { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "channelCreate";
-export async function callback(client: HaikuClient, channel: GuildBasedChannel) {
+export async function callback(client: NucleusClient, channel: GuildBasedChannel) {
const { getAuditLog, log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
const auditLog = await getAuditLog(channel.guild, "CHANNEL_CREATE");
const audit = auditLog.entries.filter((entry: GuildAuditLogsEntry) => entry.target!.id === channel.id).first();
diff --git a/src/events/channelDelete.ts b/src/events/channelDelete.ts
index e92676d..d92c994 100644
--- a/src/events/channelDelete.ts
+++ b/src/events/channelDelete.ts
@@ -6,8 +6,7 @@
ThreadChannel,
VoiceChannel
} from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import getEmojiByName from "../utils/getEmojiByName.js";
export const event = "channelDelete";
diff --git a/src/events/guildBanAdd.ts b/src/events/guildBanAdd.ts
index 9f4c47a..d1649a3 100644
--- a/src/events/guildBanAdd.ts
+++ b/src/events/guildBanAdd.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, GuildBan } from "discord.js";
import { purgeByUser } from "../actions/tickets/delete.js";
import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "guildBanAdd";
diff --git a/src/events/guildBanRemove.ts b/src/events/guildBanRemove.ts
index 5f1499d..2c3fc7b 100644
--- a/src/events/guildBanRemove.ts
+++ b/src/events/guildBanRemove.ts
@@ -1,7 +1,6 @@
import type { GuildAuditLogsEntry, GuildBan } from "discord.js";
import { purgeByUser } from "../actions/tickets/delete.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "guildBanRemove";
diff --git a/src/events/guildCreate.ts b/src/events/guildCreate.ts
index a5ada67..b1adbaa 100644
--- a/src/events/guildCreate.ts
+++ b/src/events/guildCreate.ts
@@ -1,6 +1,5 @@
import type { Guild } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import guide from "../reflex/guide.js";
export const event = "guildCreate";
diff --git a/src/events/guildMemberUpdate.ts b/src/events/guildMemberUpdate.ts
index 1f21870..543d6ff 100644
--- a/src/events/guildMemberUpdate.ts
+++ b/src/events/guildMemberUpdate.ts
@@ -1,6 +1,5 @@
import type { GuildAuditLogsEntry, GuildMember } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "guildMemberUpdate";
diff --git a/src/events/guildUpdate.ts b/src/events/guildUpdate.ts
index 3274727..703b2d9 100644
--- a/src/events/guildUpdate.ts
+++ b/src/events/guildUpdate.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { Guild, GuildAuditLogsEntry } from "discord.js";
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts
index a00baf8..4feee82 100644
--- a/src/events/interactionCreate.ts
+++ b/src/events/interactionCreate.ts
@@ -6,8 +6,7 @@
import Fuse from "fuse.js";
import { autocomplete as tagAutocomplete } from "../commands/tag.js";
import type { AutocompleteInteraction, Interaction, MessageComponentInteraction } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "interactionCreate";
diff --git a/src/events/inviteCreate.ts b/src/events/inviteCreate.ts
index 735ec21..76dfc1e 100644
--- a/src/events/inviteCreate.ts
+++ b/src/events/inviteCreate.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, Invite } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "inviteCreate";
diff --git a/src/events/inviteDelete.ts b/src/events/inviteDelete.ts
index 375a693..cdc6828 100644
--- a/src/events/inviteDelete.ts
+++ b/src/events/inviteDelete.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, Invite } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "inviteDelete";
diff --git a/src/events/memberJoin.ts b/src/events/memberJoin.ts
index 786c4ec..95dfde2 100644
--- a/src/events/memberJoin.ts
+++ b/src/events/memberJoin.ts
@@ -1,8 +1,7 @@
import type { GuildMember } from "discord.js";
import { callback as statsChannelAdd } from "../reflex/statsChannelUpdate.js";
import { callback as welcome } from "../reflex/welcome.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "guildMemberAdd";
diff --git a/src/events/memberLeave.ts b/src/events/memberLeave.ts
index 20845d5..8fa0c76 100644
--- a/src/events/memberLeave.ts
+++ b/src/events/memberLeave.ts
@@ -1,6 +1,5 @@
import type { GuildAuditLogsEntry, GuildMember } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import { purgeByUser } from "../actions/tickets/delete.js";
import { callback as statsChannelRemove } from "../reflex/statsChannelUpdate.js";
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index d0f059c..76b6855 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
import logAttachment from "../premium/attachmentLogs.js";
import createLogException from "../utils/createLogException.js";
diff --git a/src/events/messageDelete.ts b/src/events/messageDelete.ts
index 0527a60..bc668f1 100644
--- a/src/events/messageDelete.ts
+++ b/src/events/messageDelete.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildAuditLogsEntry, Message } from "discord.js";
export const event = "messageDelete";
diff --git a/src/events/messageEdit.ts b/src/events/messageEdit.ts
index 89e69de..4c482cc 100644
--- a/src/events/messageEdit.ts
+++ b/src/events/messageEdit.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { Message, MessageReference } from "discord.js";
export const event = "messageUpdate";
diff --git a/src/events/roleCreate.ts b/src/events/roleCreate.ts
index e7a0a5c..c8a32b1 100644
--- a/src/events/roleCreate.ts
+++ b/src/events/roleCreate.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildAuditLogsEntry, Role } from "discord.js";
export const event = "roleCreate";
diff --git a/src/events/roleDelete.ts b/src/events/roleDelete.ts
index 348f211..1f71f25 100644
--- a/src/events/roleDelete.ts
+++ b/src/events/roleDelete.ts
@@ -1,6 +1,5 @@
import getEmojiByName from "../utils/getEmojiByName.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildAuditLogsEntry, Role } from "discord.js";
export const event = "roleDelete";
diff --git a/src/events/roleUpdate.ts b/src/events/roleUpdate.ts
index 9b75fc0..357a22f 100644
--- a/src/events/roleUpdate.ts
+++ b/src/events/roleUpdate.ts
@@ -1,6 +1,5 @@
import type { Role } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import getEmojiByName from "../utils/getEmojiByName.js";
export const event = "roleUpdate";
diff --git a/src/events/stickerCreate.ts b/src/events/stickerCreate.ts
index 76bb6f1..b7a417c 100644
--- a/src/events/stickerCreate.ts
+++ b/src/events/stickerCreate.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildAuditLogsEntry, Sticker } from "discord.js";
export const event = "stickerDelete";
diff --git a/src/events/stickerDelete.ts b/src/events/stickerDelete.ts
index 18dcc80..8130d8a 100644
--- a/src/events/stickerDelete.ts
+++ b/src/events/stickerDelete.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildAuditLogsEntry, Sticker } from "discord.js";
export const event = "stickerDelete";
diff --git a/src/events/stickerUpdate.ts b/src/events/stickerUpdate.ts
index e2ed1f9..1421ec2 100644
--- a/src/events/stickerUpdate.ts
+++ b/src/events/stickerUpdate.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { Sticker } from "discord.js";
export const event = "stickerUpdate";
diff --git a/src/events/threadCreate.ts b/src/events/threadCreate.ts
index 5d0be0b..f0f32e5 100644
--- a/src/events/threadCreate.ts
+++ b/src/events/threadCreate.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, ThreadChannel } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "threadCreate";
export async function callback(client: HaikuClient, thread: ThreadChannel) {
diff --git a/src/events/threadDelete.ts b/src/events/threadDelete.ts
index fba3007..c166f86 100644
--- a/src/events/threadDelete.ts
+++ b/src/events/threadDelete.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, ThreadChannel } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "threadDelete";
export async function callback(client: HaikuClient, thread: ThreadChannel) {
diff --git a/src/events/threadUpdate.ts b/src/events/threadUpdate.ts
index 0077330..20247d6 100644
--- a/src/events/threadUpdate.ts
+++ b/src/events/threadUpdate.ts
@@ -1,8 +1,7 @@
import type { GuildAuditLogsEntry, ThreadChannel } from "discord.js";
// @ts-expect-error
import humanizeDuration from "humanize-duration";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "threadUpdate";
diff --git a/src/events/webhookUpdate.ts b/src/events/webhookUpdate.ts
index 6187253..e4e9659 100644
--- a/src/events/webhookUpdate.ts
+++ b/src/events/webhookUpdate.ts
@@ -1,7 +1,6 @@
import type { GuildAuditLogsEntry, Webhook } from "discord.js";
import type Discord from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
export const event = "webhookUpdate";
export async function callback(client: HaikuClient, channel: Discord.GuildChannel) {
diff --git a/src/index.ts b/src/index.ts
index 49ade67..eac8818 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,38 +1,16 @@
-import { Logger } from "./utils/log.js";
import runServer from "./api/index.js";
-import Memory from "./utils/memory.js";
-import type { VerifySchema } from "./reflex/verify.js";
-import { Guilds, History, ModNotes, Premium } from "./utils/database.js";
import client from "./utils/client.js";
-import EventScheduler from "./utils/eventScheduler.js";
-import type { RoleMenuSchema } from "./actions/roleMenu.js";
+import config from "./config/main.json" assert { type: "json" };
+import register from "./utils/commandRegistration/register.js";
-await client.registerCommandsIn(`dist/commands`);
-await client.registerEventsIn(`dist/events`);
client.on("ready", () => {
+ console.log(`Logged in as ${client.user!.tag}!`);
+ register();
runServer(client);
});
process.on("unhandledRejection", (err) => {
console.error(err);
});
-client.logger = new Logger() as Logger;
-client.verify = {} as Record<string, VerifySchema>;
-client.roleMenu = {} as Record<string, RoleMenuSchema>;
-client.memory = new Memory() as Memory;
-client.noLog = [] as string[];
-client.database = {
- guilds: await new Guilds().setup(),
- history: new History(),
- notes: new ModNotes(),
- premium: new Premium(),
- eventScheduler: await new EventScheduler().start()
-} as {
- guilds: Guilds;
- history: History;
- notes: ModNotes;
- premium: Premium;
- eventScheduler: EventScheduler;
-};
-
-await client.login();
+if (config.enableDevelopment) { await client.login(config.developmentToken); }
+else { await client.login(config.token); }
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 850e826..cd1c8ef 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,6 +1,5 @@
import type { Guild, User } from "discord.js";
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import type { GuildMember } from "discord.js";
import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
import singleNotify from "../utils/singleNotify.js";
diff --git a/src/reflex/welcome.ts b/src/reflex/welcome.ts
index 36a93fb..241185d 100644
--- a/src/reflex/welcome.ts
+++ b/src/reflex/welcome.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error
-import type { HaikuClient } from "jshaiku";
+import type { HaikuClient } from "../utils/haiku/index.js";
import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
import client from "../utils/client.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
diff --git a/src/utils/client.ts b/src/utils/client.ts
index 1795cfa..7d608c7 100644
--- a/src/utils/client.ts
+++ b/src/utils/client.ts
@@ -1,13 +1,39 @@
-// @ts-expect-error
-import { HaikuClient } from "jshaiku";
-import { Intents } from "discord.js";
-import config from "../config/main.json" assert { type: "json" };
+import { Client } from 'discord.js';
+import { Logger } from "../utils/log.js";
+import Memory from "../utils/memory.js";
+import type { VerifySchema } from "../reflex/verify.js";
+import { Guilds, History, ModNotes, Premium } from "../utils/database.js";
+import EventScheduler from "../utils/eventScheduler.js";
+import type { RoleMenuSchema } from "../actions/roleMenu.js";
-const client = new HaikuClient(
- {
- intents: new Intents(32767).bitfield // This is a way of specifying all intents w/o having to type them out
- },
- config
-);
+
+class NucleusClient extends Client {
+ logger = Logger;
+ verify: Record<string, VerifySchema> = {};
+ roleMenu: Record<string, RoleMenuSchema> = {};
+ memory: Memory = new Memory() as Memory;
+ noLog: string[] = [];
+ database: {
+ guilds: Guilds;
+ history: History;
+ notes: ModNotes;
+ premium: Premium;
+ eventScheduler: EventScheduler;
+ };
+
+ constructor(database: typeof NucleusClient.prototype.database) {
+ super({ intents: 32767 });
+ this.database = database;
+ }
+}
+
+const client = new NucleusClient({
+ guilds: new Guilds(),
+ history: new History(),
+ notes: new ModNotes(),
+ premium: new Premium(),
+ eventScheduler: new EventScheduler()
+});
export default client;
+export { NucleusClient };
\ No newline at end of file
diff --git a/src/utils/commandRegistration/getFilesInFolder.ts b/src/utils/commandRegistration/getFilesInFolder.ts
new file mode 100644
index 0000000..a669065
--- /dev/null
+++ b/src/utils/commandRegistration/getFilesInFolder.ts
@@ -0,0 +1,23 @@
+import fs from "fs";
+
+export default async function getSubcommandsInFolder(path: string) {
+ const files = fs.readdirSync(path, { withFileTypes: true }).filter(
+ file => !file.name.endsWith(".ts") && !file.name.endsWith(".map")
+ );
+ const subcommands = [];
+ const subcommandGroups = [];
+ for (const file of files) {
+ if (file.name === "_meta.js") continue;
+ // If its a folder
+ if (file.isDirectory()) {
+ // Get the _meta.ts file
+ console.log(`│ ├─ Loading subcommand group ${file.name}}`)
+ subcommandGroups.push((await import(`../../../${path}/${file.name}/_meta.js`)).command);
+ } else if (file.name.endsWith(".js")) {
+ // If its a file
+ console.log(`│ ├─ Loading subcommand ${file.name}}`)
+ subcommands.push((await import(`../../../${path}/${file.name}`)).command);
+ }
+ }
+ return {subcommands, subcommandGroups};
+}
diff --git a/src/utils/commandRegistration/register.ts b/src/utils/commandRegistration/register.ts
new file mode 100644
index 0000000..af0b5fc
--- /dev/null
+++ b/src/utils/commandRegistration/register.ts
@@ -0,0 +1,61 @@
+import { SlashCommandBuilder } from 'discord.js';
+import config from "../../config/main.json" assert { type: "json" };
+import client from "../client.js";
+import fs from "fs";
+
+
+async function registerCommands() {
+ const developmentMode = config.enableDevelopment;
+ const commands = [];
+
+ const files = fs.readdirSync(config.commandsFolder, { withFileTypes: true }).filter(
+ file => !file.name.endsWith(".ts") && !file.name.endsWith(".map")
+ );
+ console.log(`Registering ${files.length} commands`)
+ let i = 0;
+ for (const file of files) {
+ // Box drawing characters: | └ ─ ┌ ┐ ┘ ┬ ┤ ├ ┴ ┼
+ console.log(`├─ ${file.name}`)
+ if (file.isDirectory()) {
+ commands.push((await import(`../../../${config.commandsFolder}/${file.name}/_meta.js`)).command);
+ } else if (file.name.endsWith(".js")) {
+ commands.push((await import(`../../../${config.commandsFolder}/${file.name}`)).command);
+ }
+ i++;
+ console.log(`├─ Loaded ${file.name} [${i} / ${files.length}]`)
+ }
+ console.log(`Loaded ${commands.length} commands, processing...`)
+ const processed = []
+
+ for (const subcommand of commands) {
+ if (subcommand instanceof Function) {
+ processed.push(subcommand(new SlashCommandBuilder()))
+ } else {
+ processed.push(subcommand)
+ }
+ }
+
+ console.log(`Processed ${commands.length} commands, registering...`)
+
+ if (developmentMode) {
+ const guild = await client.guilds.fetch(config.developmentGuildID);
+ guild.commands.set([])
+ guild.commands.set(processed);
+ console.log(`Commands registered in ${guild.name}`)
+ } else {
+ client.application!.commands.set([])
+ client.application!.commands.set(processed);
+ console.log(`Commands registered globally`)
+ }
+
+};
+
+async function registerEvents() {
+ // pass
+};
+
+export default async function register() {
+ console.log("> Registering commands")
+ await registerCommands();
+ await registerEvents();
+};
diff --git a/src/utils/commandRegistration/slashCommandBuilder.ts b/src/utils/commandRegistration/slashCommandBuilder.ts
new file mode 100644
index 0000000..719855f
--- /dev/null
+++ b/src/utils/commandRegistration/slashCommandBuilder.ts
@@ -0,0 +1,37 @@
+import type { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
+import type { SlashCommandBuilder } from "discord.js";
+import config from "../../config/main.json" assert { type: "json" };
+import getSubcommandsInFolder from "./getFilesInFolder.js";
+
+
+export async function group(name: string, description: string, path: string) {
+ const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path)
+ return (subcommandGroup: SlashCommandSubcommandGroupBuilder) => {
+ subcommandGroup
+ .setName(name)
+ .setDescription(description)
+
+ for (const subcommand of fetched.subcommands) {
+ subcommandGroup.addSubcommand(subcommand);
+ };
+
+ return subcommandGroup;
+ };
+}
+
+export async function command(name: string, description: string, path: string) {
+ const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path);
+ console.log(`│ ├─ Loaded ${fetched.subcommands.length} subcommands and ${fetched.subcommandGroups.length} subcommand groups for ${name}`)
+ return (command: SlashCommandBuilder) => {
+ command.setName(name)
+ command.setDescription(description)
+
+ for (const subcommand of fetched.subcommands) {
+ command.addSubcommand(subcommand);
+ }
+ for (const group of fetched.subcommandGroups) {
+ command.addSubcommandGroup(group);
+ };
+ return command;
+ };
+}
diff --git a/src/utils/log.ts b/src/utils/log.ts
index e4ac4cd..a578b69 100644
--- a/src/utils/log.ts
+++ b/src/utils/log.ts
@@ -7,58 +7,54 @@
const wait = promisify(setTimeout);
-export class Logger {
+
+export const Logger = {
renderUser(user: Discord.User | string) {
if (typeof user === "string") return `${user} [<@${user}>]`;
return `${user.username} [<@${user.id}>]`;
- }
+ },
renderTime(t: number) {
t = Math.floor((t /= 1000));
return `<t:${t}:D> at <t:${t}:T>`;
- }
+ },
renderDelta(t: number) {
t = Math.floor((t /= 1000));
return `<t:${t}:R> (<t:${t}:D> at <t:${t}:T>)`;
- }
+ },
renderNumberDelta(num1: number, num2: number) {
const delta = num2 - num1;
return `${num1} -> ${num2} (${delta > 0 ? "+" : ""}${delta})`;
- }
+ },
entry(value: string, displayValue: string): { value: string; displayValue: string } {
return { value: value, displayValue: displayValue };
- }
+ },
renderChannel(channel: Discord.GuildChannel | Discord.ThreadChannel) {
return `${channel.name} [<#${channel.id}>]`;
- }
+ },
renderRole(role: Discord.Role) {
return `${role.name} [<@&${role.id}>]`;
- }
+ },
renderEmoji(emoji: Discord.GuildEmoji) {
return `<${emoji.animated ? "a" : ""}:${emoji.name}:${emoji.id}> [\`:${emoji.name}:\`]`;
- }
-
- public readonly NucleusColors: Record<string, number> = {
+ },
+ NucleusColors: {
red: 0xf27878,
yellow: 0xf2d478,
green: 0x68d49e
- };
-
- async getAuditLog(
- guild: Discord.Guild,
- event: Discord.GuildAuditLogsResolvable
- ): Promise<Discord.GuildAuditLogsEntry[]> {
+ },
+ async getAuditLog(guild: Discord.Guild, event: Discord.GuildAuditLogsResolvable): Promise<Discord.GuildAuditLogsEntry[]> {
await wait(250);
const auditLog = await guild.fetchAuditLogs({ type: event });
return auditLog as unknown as Discord.GuildAuditLogsEntry[];
- }
-
+ },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async log(log: any): Promise<void> {
const config = await client.database.guilds.read(log.hidden.guild);
if (!config.logging.logs.enabled) return;
if (!(log.meta.calculateType === true)) {
if (!toHexArray(config.logging.logs.toLog).includes(log.meta.calculateType))
- return console.log("Not logging this type of event");
+ console.log("Not logging this type of event");
+ return;
}
if (config.logging.logs.channel) {
const channel = (await client.channels.fetch(config.logging.logs.channel)) as Discord.TextChannel | null;
@@ -79,8 +75,8 @@
.setTitle(`${getEmojiByName(log.meta.emoji)} ${log.meta.displayName}`)
.setDescription(
(log.separate.start ? log.separate.start + "\n" : "") +
- generateKeyValueList(description) +
- (log.separate.end ? "\n" + log.separate.end : "")
+ generateKeyValueList(description) +
+ (log.separate.end ? "\n" + log.separate.end : "")
)
.setTimestamp(log.meta.timestamp)
.setColor(log.meta.color);
@@ -88,6 +84,7 @@
}
}
}
-}
+};
+
export default {};