使用命令时,漫游器必须连接到语音通道,但要使其连接,它必须看到该语音通道中的用户使用命令对其进行调用。但是,这不会发生,机器人返回否定结果,它不会看到用户。有什么问题吗?
代码:
const queue = new Map();
async function execute(message, serverQueue) {
const args = message.content.split(' ');
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send('You need to be in a voice channel to play music!');
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('CONNECT') || !permissions.has('SPEAK')) {
return message.channel.send('I need the permissions to join and speak in your voice channel!');
}
}
答案 0 :(得分:1)
从discord.js v12开始,您需要使用voice.channel
而不是voiceChannel
const queue = new Map();
async function execute(message, serverQueue) {
const args = message.content.split(' ');
const voiceChannel = message.member.voice.channel;
if (!voiceChannel) return message.channel.send('You need to be in a voice channel to play music!');
const permissions = voiceChannel.permissionsFor(message.client.user);
if (!permissions.has('CONNECT') || !permissions.has('SPEAK')) {
return message.channel.send('I need the permissions to join and speak in your voice channel!');
}
}