discord - Discord.js 斜线命令选项
问题描述
我正在使用 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
},
],
解决方案
您不能将选项类型作为语音通道
,因为它不是有效类型,但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" });
推荐阅读
- docker - Docker 在 NPM 安装时被阻止 - 套接字超时
- python - Python - 请求 - JSONDecodeError
- c# - WPF如何使用MVVM模式将值绑定到TextBox correclty
- bootstrap-4 - 在 BS4 中对齐并排嵌套的 div
- java - 集成测试:java.lang.IllegalStateException:无法解开代理对象
- docker - 从家庭 TIBCO EMS 服务器切换到辅助 TIBCO EMS 服务器后,WSO2 ESB 无法重新连接到 TIBCO JMS 服务器
- javascript - Socket.io 无法连接到 Android 浏览器上的 localhost
- php - Swift - PHP:发送到 PHP 的文本字段值被接收为 null
- python - 我们可以通过理解来做到这一点吗?
- kubernetes - 需要使用带有凭证的驱动程序名称创建 K8 环境