问题描述
为了好玩,我刚刚开始使用 JavaScript 编写我的第一个 discord 机器人。而且我一直做得很好,直到我想让我的机器人扫描聊天中传入的消息以查找特定关键字,然后在找到该关键字后将消息作者从语音通道中踢出(如果他们已连接)。
到目前为止,我的代码如下所示:
//Checks if message content includes keyword.
if (msg.content.includes('what')) {
//Sets the variable "member" to be the message sender.
const member = msg.author;
//Checks if member is in a voice channel. If not prints reply
if (!member.voiceChannel) return msg.reply("That was a close one,I will get you next time!")
//Sets the members value to null,thus "kicking" the member out of voice channel
member.voice.setChannel(null);
}
我收到的错误消息是:
TypeError: Cannot read property 'setChannel' of undefined
我尝试了多种变体,但没有。请帮忙!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)