【发布时间】:2020-07-02 12:00:56
【问题描述】:
我目前正在开发一个不和谐的机器人,使用 discord.js 供私人使用。
这里有一个小背景:在我的服务器中,我们在一个语音频道中组织了 30 到 40 名成员的活动(他们都有与活动对应的角色),我们需要检查哪些人失踪了。所以基本上机器人需要比较2个列表,具有事件角色的成员在语音通道上连接,另一个与具有角色但未连接在指定语音通道上的成员。
我已经做了一些研究,我知道了它应该如何工作的基础(检索管理员所在的语音频道 ID,并从命令中获取角色)。但是,它比我想象的要复杂,我需要帮助。
这是我的“代码”:
client.on('message', message => {
if(message.content == "check"){
//role restriction
if(!!message.member.roles.cache.has("admin")) return console.log("Fail from "+message.author.username);
else{
//retreiving the role from command
var messageArray = message.content.split(" ");
var command = messageArray[0];
var args = messageArray.slice(1)
//finding the correct channel with the gaved ID
console.log(message.guild.channels.cache
.find(VoiceChannel => VoiceChannel.id == 618882800950706189))
//voice channel ID where admin is connected
//console.log(message.member.voice.channelID);
};
};
});
我会感谢我得到的每一个帮助:)
【问题讨论】:
标签: node.js bots discord.js