如何在discord v13的交互中查询addStringOption的内容?

How do I query the content of the addStringOption in the interactions in discord v13?

美好的一天,

我想保存你在addStringOption中输入的内容,我就是不知道怎么查询,谁能解释一下吗?

   const { SlashCommandBuilder } = require("@discordjs/builders");
    
    module.exports = {
        data: new SlashCommandBuilder()
        .setName('announce')
        .setDescription('test')
        .addSubcommand(subcommand =>subcommand.setName('normal').setDescription('TEST')
        .addStringOption(option => option.setName('message').setDescription('TEST').setRequired(true))),
    
        async execute(interaction) {
            interaction.reply("test")
        }
    }

我不是 100% 了解您所说的查询的意思,但我假设您想获取用户输入的选项的值。为此,您要在选项 属性.

上使用 getString 函数
async execute(interaction) {
  // Get the string option
  const value = interaction.options.getString('message');
  // Return the value
  await interaction.reply(value);
}

在此处阅读更多内容: https://discord.js.org/#/docs/discord.js/stable/class/CommandInteractionOptionResolver?scrollTo=getString