【问题标题】:Discord.js slash command optionDiscord.js 斜线命令选项
【发布时间】:2021-11-17 19:51:46
【问题描述】:

我正在使用 WOKCommands,并且想要使您只能选择一个语音通道。我该怎么做?

options: [
        {
            name: 'channel',
            description: '???? Voice channel in which you want to play your activity',
            required: true,
            type: discord_js_1.default.Constants.ApplicationCommandOptionTypes.CHANNEL
            
        },
    ],

【问题讨论】:

    标签: discord discord.js


    【解决方案1】:

    您不能将选项类型设置为语音频道
    因为它不是有效类型,但 channel
    所以在这种情况下,您可以检查频道类型是否为语音并给他一条错误消息以提供语音频道
    示例:

    let channel = interaction.options.getChannel(interaction.options.data[0].name);
    if(channel.type !== "GUILD_VOICE") return interaction.channel.send({ content:"Please provide a valid voice channel" });
    

    【讨论】:

    • 好的,感谢您的帮助:)
    • 没问题 ;) 很高兴为您提供帮助
    猜你喜欢
    • 2021-06-11
    • 2022-01-15
    • 2022-01-25
    • 2021-08-17
    • 2022-01-14
    • 2021-11-12
    • 2021-08-28
    • 2021-09-12
    • 2021-12-22
    相关资源
    最近更新 更多