【问题标题】:How can I get the role of the author of the message using Discord.js?如何使用 Discord.js 获得消息作者的角色?
【发布时间】:2020-04-29 19:09:14
【问题描述】:

我想为我的 discord 服务器创建一个机器人,当有人发送消息时我需要获取作者的角色以执行某些功能。

我查看了文档和其他帖子上的很多答案,但我找不到。

如何获取消息作者的角色?

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:
    var author = guild.members.resolve(message.author.id);
    var isSiteAdmin = author.roles.cache.some(role => role.name === 'site-admin');
    

    【讨论】:

      猜你喜欢
      • 2020-08-06
      • 2021-02-06
      • 2021-08-05
      • 2019-11-17
      • 1970-01-01
      • 2020-12-17
      • 2021-05-12
      • 2021-01-30
      • 2020-12-08
      相关资源
      最近更新 更多