简体   繁体   English

如何检查用户是否具有来自另一个 Discord 服务器的角色

[英]How to check if a user has a role from another Discord server

So my bot DinoCord has Economy features and I want to lower cooldowns for a specific role ("Premium").所以我的机器人 DinoCord 具有经济功能,我想降低特定角色的冷却时间(“高级”)。 The thing is I don't know how to check if a user has a role across all servers.问题是我不知道如何检查用户是否在所有服务器上都有角色。

Currently we use this if目前我们使用这个如果

(!message.member.roles.some(role => role.id === "678114167902830610"))

but that only checks in our support server where the role is at, and nowhere else.但这只会在我们的支持服务器中检查角色所在的位置,而不会检查其他地方。 So my question is is there a way to check if a user has a role from my support server in all other servers?所以我的问题是有没有办法检查用户是否在所有其他服务器中拥有来自我的支持服务器的角色?

Here is a gif of it.这是它的gif。

For Discord.js v11 (which is what you seem to be using):对于 Discord.js v11(您似乎正在使用):

// your support server
const supportGuild = client.guilds.get('673691776317390868')
const member = supportGuild.members.get(message.author.id)
const hasPremium = member ? member.roles.get('678114167902830610') : false

For v12 and v13:对于 v12 和 v13:

// your support server
const supportGuild = client.guilds.cache.get('673691776317390868')
const member = supportGuild.members.cache.get(message.author.id)
const hasPremium = member ? member.roles.cache.get('678114167902830610') : false

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

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