ran prettier lol
All checks were successful
CI / build (push) Successful in 10s

This commit is contained in:
Space-Banane
2026-02-22 15:31:37 +01:00
parent bc58cb7361
commit e1300a98b3
17 changed files with 473 additions and 408 deletions

View File

@@ -3,34 +3,40 @@ import { getAllCommands, getCommand } from "../lib/commandRegistry";
import { GUILD_ID } from "../config";
export default async function (client: Client) {
const token = process.env.DISCORD_TOKEN!;
const clientId = client.user!.id; // use the ready client's ID
const token = process.env.DISCORD_TOKEN!;
const clientId = client.user!.id; // use the ready client's ID
const rest = new REST().setToken(token);
const rest = new REST().setToken(token);
const commandData = getAllCommands().map((cmd) => cmd.data.toJSON());
const commandData = getAllCommands().map((cmd) => cmd.data.toJSON());
await rest.put(Routes.applicationGuildCommands(clientId, GUILD_ID), {
body: commandData,
});
await rest.put(Routes.applicationGuildCommands(clientId, GUILD_ID), {
body: commandData,
});
console.log(`Registered ${commandData.length} slash command(s).`);
console.log(`Registered ${commandData.length} slash command(s).`);
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
const command = getCommand(interaction.commandName);
if (!command) return;
const command = getCommand(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (err) {
console.error(err);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: "An error occurred.", ephemeral: true });
} else {
await interaction.reply({ content: "An error occurred.", ephemeral: true });
}
}
});
try {
await command.execute(interaction);
} catch (err) {
console.error(err);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({
content: "An error occurred.",
ephemeral: true,
});
} else {
await interaction.reply({
content: "An error occurred.",
ephemeral: true,
});
}
}
});
}