【发布时间】:2022-01-23 23:05:19
【问题描述】:
我正在尝试制作 Discord 音乐机器人,但 message.member.voice.channel 总是返回 null。我在stackoverflow上看到了很多其他类似的问题,但似乎没有一个对我有帮助。代码如下:
function play(message, args) {
const VoiceChannel = message.member.voice.channel;
console.log(VoiceChannel);
if(!VoiceChannel) message.reply('You need to be in a voice channel');
if(!args.length) message.reply('You need to specify song name');
}
/*............................................................................*/
if(command === 'play'){
play(message, args);
}
(与 VoiceChannel 不同,args.length 可以正常工作)
【问题讨论】:
-
也许你有遗漏的意图?您可以在此处发布意图。
-
const { Client, Intents, DiscordAPIError, User, Channel, Collection } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
标签: javascript node.js discord discord.js