I've been working on a Discord bot and been reading up on the docs. I'm quite new to this and I can't find any YT tutorials on the topic, here's the code:
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('test')
.setDescription('Select a test to use.')
.addStringOption(option =>
option
.setName('type')
.setDescription('Type of test requested')),
async execute(interaction) {
const ptypes = interaction.options.getString('type') ?? 'No reason provided';
await interaction.reply(`You chose ${ptypes}`);
},
};
Here's how that would work:
/test > [click]test > [input]test
Here's how I want it to work:
/test > [input]test
You can accomplish this, by supplying .setRequired()
.addStringOption(option =>
option
.setName('type')
.setDescription('Type of test requested'))
.setRequired(true),