简体   繁体   English

如何使用 Discord.js 获得消息作者的角色?

[英]How can I get the role of the author of the message using Discord.js?

I want to create a bot for my discord server and I need to get the role of the author when someone sends a message in order to execute some functions.我想为我的 discord 服务器创建一个机器人,当有人发送消息以执行某些功能时,我需要获取作者的角色。

I've looked at the documentation and a lot of answers on other posts but I can't find.我查看了文档和其他帖子上的很多答案,但我找不到。

How can I get the role of the author of the message?如何获得消息作者的角色?

var author = guild.members.resolve(message.author.id);
var isSiteAdmin = author.roles.cache.some(role => role.name === 'site-admin');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM