diff --git a/apps/guide/src/content/03-creating-your-bot/04-handling-command-interactions.mdx b/apps/guide/src/content/03-creating-your-bot/04-handling-command-interactions.mdx index 04487fe1a..300451cc1 100644 --- a/apps/guide/src/content/03-creating-your-bot/04-handling-command-interactions.mdx +++ b/apps/guide/src/content/03-creating-your-bot/04-handling-command-interactions.mdx @@ -26,13 +26,12 @@ Now that your command files have been created, your bot needs to load these file In your _`index.js`_ file, make these additions to the base template: - + -```js JavaScript focus=1:3,9 +```js JavaScript mark=1:4,9 import { readdir } from 'node:fs/promises'; import { join } from 'node:path'; import { fileURLToPath } from 'node:url'; -// focus[18:28] import { Client, Collection, Events, GatewayIntentBits } from 'discord.js'; import config from './config.json' assert { type: 'json' }; @@ -45,12 +44,18 @@ client.once(Events.ClientReady, () => { }); ``` -```ts TypeScript focus=1:3,9:14 +```ts TypeScript mark=1:11,16:21 import { readdir } from 'node:fs/promises'; import { join } from 'node:path'; import { fileURLToPath } from 'node:url'; -// focus[18:28] -import { Client, Collection, Events, GatewayIntentBits } from 'discord.js'; +import { + Client, + Collection, + Events, + GatewayIntentBits, + type RESTPostAPIChatInputApplicationCommandsJSONBody, + type ChatInputCommandInteraction, +} from 'discord.js'; import config from './config.json'; const client = new Client({ intents: [GatewayIntentBits.Guilds] }); @@ -259,11 +264,11 @@ for (const folder of commandFolders) { const commands = new Collection(); const foldersPath = fileURLToPath(new URL('commands', import.meta.url)); -const commandFolders = readdir(foldersPath); +const commandFolders = await readdir(foldersPath); for (const folder of commandFolders) { const commandsPath = join(foldersPath, folder); - const commandFiles = readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js'))); + const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js'))); for (const file of commandFiles) { const filePath = join(commandsPath, file); const command = await import(filePath);