Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Create A New AI Slash Command

Now we want to be able to call the Open AI using our Discord bot. Here we will implement a new slash command: /ask.


info

Slash commands let you trigger bot responses using a /command in Discord.

task

  1. Create a new file called ai.js in the commands/utilities folder.
  2. Create a new slash command for the AI wrapper

tip

import { SlashCommandBuilder } from 'discord.js'
export const data = new SlashCommandBuilder()
 .setName('some command');
 // can add more information about the slash command

async function execute (interaction) {
 // do something    

}

export { data, execute };