【问题标题】:User in voice channel语音通道中的用户
【发布时间】: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


【解决方案1】:

假设当前意图是 GUILDS 和 GUILD_MESSAGES,那么问题一定来自缺少的 GUILD_VOICE_STATES 意图。确保将其包含在意图数组中,它应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 2020-12-24
    • 2020-10-19
    • 2020-09-16
    • 1970-01-01
    • 2021-09-18
    • 1970-01-01
    • 2019-09-23
    • 2021-03-20
    • 2021-05-07
    相关资源
    最近更新 更多