Discord.js 获取此错误代码:";(节点:25096)未处理的PromisejectionWarning:TypeError:无法读取属性';频道';“未定义”的定义;
嗨,我已经尝试让一个discord机器人加入一个语音频道有一段时间了,并且一直在努力,这是我到目前为止的代码,当我在服务器的常规聊天中键入“/加入”时,我收到了这条消息。提前谢谢Discord.js 获取此错误代码:";(节点:25096)未处理的PromisejectionWarning:TypeError:无法读取属性';频道';“未定义”的定义;,discord.js,Discord.js,嗨,我已经尝试让一个discord机器人加入一个语音频道有一段时间了,并且一直在努力,这是我到目前为止的代码,当我在服务器的常规聊天中键入“/加入”时,我收到了这条消息。提前谢谢 const Discord = require('discord.js'); const client = new Discord.Client(); client.login('my token); client.on('message', async message => { // Voice only
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('my token);
client.on('message', async message => {
// Voice only works in guilds, if the message does not come from a guild,
// we ignore it
if (!message.guild) return;
if (message.content === '/join') {
// Only try to join the sender's voice channel if they are in one themselves
if (message.member.voice.channel) {
const connection = await message.member.voice.channel.join();
} else {
message.reply('You need to join a voice channel first!');
}
}
});
将“message.member.voice.channel”替换为“message.member.voice.channel”。不幸的是,这仍然不起作用。你在两个地方改变了吗?天哪,我已经脑死亡了,谢谢你们,终于起作用了!!!