我一直在做一个Discord机器人,并一直在阅读文档。我对这个很陌生,我找不到任何关于这个主题的YT教程,下面是代码:
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}`);
},
};
当我输入命令时,它不是自动显示一个框让我输入,而是让我在输入任何东西之前选择名为"test"的选项。
/test>(点击)测试比;[输入]测试我希望它是这样工作的:
/test>[输入]测试
您可以通过提供.setRequired()
.addStringOption(option =>
option
.setName('type')
.setDescription('Type of test requested'))
.setRequired(true),