我正在尝试检查作者是否在 x 服务器上具有 x 角色以便能够使用该命令但无法使其工作。我只能检查 Author 在该服务器中是否具有 x 角色。
想法:如果用户在 x 服务器中具有 x 角色,将能够在任何服务器上使用特殊命令。
role_id = 569712344226201600
author = ctx.message.author
if role_id in [role.id for role in author.roles]:
await ctx.send("message")
最佳答案
你可以只获取角色对象。
role = discord.utils.get(ctx.guild.roles, id=role_id_here)
然后只是:
if role in ctx.author.roles:
...
您的机器人必须在这些服务器上。
关于python - 如何检查作者是否在 x 服务器中具有 x 角色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56302218/