【发布时间】:2020-11-21 21:29:45
【问题描述】:
我正在尝试查找具有特定角色 ID 的任何成员是否存在于特定语音频道中。如果该特定语音频道中甚至存在 1 个具有特定角色 id 的成员,则只有这些成员可以使用音乐机器人的命令。
根据我的研究,我知道voiceStateUpdate 可能会有所帮助,但问题是我不知道如何在我的代码中使用它(因为我是 JavaScript 新手)。这是文档的链接:
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate 。
这是我的代码的一部分:
client.on('voiceStateUpdate', (oldMember, newMember) => {
});
client.on('message', async message => {
if (message.author.bot) return
if (!message.content.startsWith(prefix)) return
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
const args = message.content.substring(prefix.length).split(' ');
const searchString = args.slice(1).join(' ')
const url = args[1] ? args[1].replace(/<(._)>/g, '$1') : ''
const serverQueue = queue.get(message.guild.id)
if() { //the conditional statement I am trying to put here but I don't know how to do it properly
if (message.content.startsWith(`${prefix}play`)) {
const voiceChannel = message.member.voice.channel
if (!voiceChannel) return message.channel.send("You need to be in a voice channel to play music")
.......
所以主要是我不知道在 if 语句中确切地写什么才能使我的代码正常工作。
【问题讨论】:
标签: discord.js