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
- Use the input from Discord as the prompt for your AI client.
- Where are you currently hardcoding the prompt? Replace that with the
prompt
variable you just defined.