【问题标题】:Role Specific Commands for Discord.js v12Discord.js v12 的角色特定命令
【发布时间】:2020-05-14 07:32:30
【问题描述】:

是的,我知道这个问题已经问了很多很多次了。然而由于某种原因,我无法获得适用于 discord.js v12 的角色特定命令。

我已经尝试了几乎所有方法,但由于某种原因它不起作用......

这是我当前的代码:

bot.on('message', message=>{
 if(message.content.includes('test')) {
     if(message.member.roles.has(roleidgoeshere)) {
       message.channel.send('Yay, the author of the message has the role!');
       } else {
       message.channel.send('Nope');
       }
    }
});

错误:message.member.roles.has is not a function

我对使用 JavaScript 编码非常陌生,因此我们将不胜感激! 如果我不够清楚,我会尽我所能回答cmets中的任何问题

【问题讨论】:

  • 将错误添加到您的问题对于帮助回答您的问题非常重要

标签: javascript discord


【解决方案1】:

由于 discord.js v12,您需要使用 cache 访问 roles 集合,因此您的解决方案是:

if(message.member.roles.cache.has(roleidgoeshere)) {

【讨论】:

    猜你喜欢
    • 2021-01-30
    • 1970-01-01
    • 2021-03-16
    • 2021-08-28
    • 2021-01-01
    • 2021-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多