如何从Discord消息中的提及中获取角色ID?

时间:2020-09-08 19:11:44

标签: python discord discord.py discord.py-rewrite

我正在为Discord机器人开发项目,并且已经陷入僵局(Python和Discord API的初学者)。我几乎想做的就是让功能测试消息以检查其中是否提到了角色。

这里有一个我固定的部分的sudo示例:

def test(message):
  if @role (given role) in message:
     then do this

我非常感谢您的帮助,在这一部分我一无所知,我已经做了几乎所有的事情。

1 个答案:

答案 0 :(得分:0)

可能您可以执行此操作,只是使用命令来检查roleid

@bot.command(aliases=['cri'])
async def checkroleid(ctx, role: discord.Role):
    await ctx.send(f"Here the role id `{role.id}`")