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

Customise Your AI

Right now, the AI is not responding to the text you sent in Discord. Let’s change that by using input from the user.


Add an Input Option

info

To accept text input, we need to add a string option to the /ask slash command.

tip

What method lets you define options in SlashCommandBuilder?

.addStringOption((option) =>
    option
        .setName('...')  // What should we call this input?
        .setDescription('...')  // How will you describe the input?
        .setRequired(true)
)

Read the User Input

info

In the execute() function, we can extract what the user typed using .getString().

tip

Use the name you gave your option in the previous step.

const prompt = interaction.options.getString('...');

tasks

  1. Use the input from Discord as the prompt for your AI client.
  2. Where are you currently hardcoding the prompt? Replace that with the prompt variable you just defined.