有什么办法可以做到这一点?我还没有找到任何可以回答这个问题的答案。
@bot.command()
async def check_rank(ctx)
if "Administrator" in ctx.author.roles
color = ctx.author.color
await ctx.send("Checked rank!")
类似的东西?我有这个 modmail 代码,我希望它在嵌入中使用用户角色颜色和名称。
答案 0 :(得分:1)
您可以从 member.roles
获取顶级角色,从 member.color
获取颜色
@bot.commmand()
async def check_rank(ctx):
author = ctx.author # we get the member object
top_role = author.roles[-1] # first element in roles is `@everyone` and last is top role
color = author.color
答案 1 :(得分:0)
您可以使用 .roles 获取 discord.Guild 对象的所有角色。 (不和谐公会是不和谐服务器。)https://discordpy.readthedocs.io/en/latest/api.html?highlight=roles#discord.Guild.roles
https://discordpy.readthedocs.io/en/latest/api.html?highlight=roles#discord.Member.colour
@client.command()
async def roles_colors(ctx):
for role in ctx.guild.roles:
await ctx.send(role.name)