diff --git a/src/index.ts b/src/index.ts index 642d9cf..676618f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ import { Client, GatewayIntentBits } from "discord.js"; import { config } from "./env.js"; -import { loadCommands, registerCommands } from "./utils/commands.js"; import { loadEvents } from "./utils/events.js"; const client = new Client({ @@ -12,9 +11,7 @@ const client = new Client({ GatewayIntentBits.GuildMembers, }); -loadCommands(client); loadEvents(client); -registerCommands(); // Graceful shutdown process.on("SIGINT", async () => { diff --git a/src/utils/commands.ts b/src/utils/commands.ts index c313414..0539bac 100644 --- a/src/utils/commands.ts +++ b/src/utils/commands.ts @@ -1,13 +1,4 @@ -import { - type ChatInputCommandInteraction, - type Client, - Collection, - REST, - Routes, -} from "discord.js"; -import { commands } from "../commands/index.js"; -import type { Command } from "../commands/types.js"; -import { config } from "../env.js"; +import type { ChatInputCommandInteraction } from "discord.js"; export const buildCommandString = (interaction: ChatInputCommandInteraction): string => { const commandName = interaction.commandName; @@ -15,37 +6,3 @@ export const buildCommandString = (interaction: ChatInputCommandInteraction): st .map((option) => `${option.name}:${option.value}`) .join(" ")}`; }; - -export async function loadCommands(client: Client) { - if (!client.commands) { - client.commands = new Collection(); - } - - let loaded = 0; - for (const command of commands.values()) { - client.commands.set(command.data.name, command); - loaded += 1; - } - - console.log(`Successfully loaded ${loaded} command handlers into client.commands.`); -} - -export async function registerCommands() { - const commandsData = Array.from(commands.values()).map((command) => command.data); - - try { - const guildId = config.discord.serverId; - const scope = guildId ? `guild ${guildId}` : "global"; - console.log(`Started refreshing ${commandsData.length} ${scope} application commands.`); - - const rest = new REST({ version: "10" }).setToken(config.discord.token); - - await rest.put(Routes.applicationGuildCommands(config.discord.clientId, guildId), { - body: commandsData, - }); - - console.log(`Successfully reloaded ${commandsData.length} ${scope} commands.`); - } catch (error) { - console.error(JSON.stringify(error, null, 2)); - } -} diff --git a/src/utils/deploy-commands.ts b/src/utils/deploy-commands.ts index a638a72..49015cf 100644 --- a/src/utils/deploy-commands.ts +++ b/src/utils/deploy-commands.ts @@ -7,9 +7,6 @@ export async function deployCommands(): Promise { const rest = new REST({ version: "10" }).setToken(config.discord.token); - (await rest.put(Routes.applicationCommands(config.discord.clientId), { - body: [], - })) as RESTPutAPIApplicationCommandsResult; try { const result = (await rest.put( Routes.applicationGuildCommands(config.discord.clientId, config.discord.serverId),