<i id='dwoIP'><tr id='dwoIP'><dt id='dwoIP'><q id='dwoIP'><span id='dwoIP'><b id='dwoIP'><form id='dwoIP'><ins id='dwoIP'></ins><ul id='dwoIP'></ul><sub id='dwoIP'></sub></form><legend id='dwoIP'></legend><bdo id='dwoIP'><pre id='dwoIP'><center id='dwoIP'></center></pre></bdo></b><th id='dwoIP'></th></span></q></dt></tr></i><div id='dwoIP'><tfoot id='dwoIP'></tfoot><dl id='dwoIP'><fieldset id='dwoIP'></fieldset></dl></div>
        <tfoot id='dwoIP'></tfoot>
        <legend id='dwoIP'><style id='dwoIP'><dir id='dwoIP'><q id='dwoIP'></q></dir></style></legend>

        <small id='dwoIP'></small><noframes id='dwoIP'>

        • <bdo id='dwoIP'></bdo><ul id='dwoIP'></ul>
      1. 如何检查用户是否在 on_message 中具有特定角色?

        时间:2023-09-10

          <legend id='ujp9o'><style id='ujp9o'><dir id='ujp9o'><q id='ujp9o'></q></dir></style></legend>
        1. <i id='ujp9o'><tr id='ujp9o'><dt id='ujp9o'><q id='ujp9o'><span id='ujp9o'><b id='ujp9o'><form id='ujp9o'><ins id='ujp9o'></ins><ul id='ujp9o'></ul><sub id='ujp9o'></sub></form><legend id='ujp9o'></legend><bdo id='ujp9o'><pre id='ujp9o'><center id='ujp9o'></center></pre></bdo></b><th id='ujp9o'></th></span></q></dt></tr></i><div id='ujp9o'><tfoot id='ujp9o'></tfoot><dl id='ujp9o'><fieldset id='ujp9o'></fieldset></dl></div>

          <small id='ujp9o'></small><noframes id='ujp9o'>

              <bdo id='ujp9o'></bdo><ul id='ujp9o'></ul>

              <tfoot id='ujp9o'></tfoot>
                    <tbody id='ujp9o'></tbody>
                  本文介绍了如何检查用户是否在 on_message 中具有特定角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  目前,如果您执行命令,我有一个机器人会给您一个角色.我想让机器人检查执行命令的用户是否具有特定角色.截至目前,我只看到人们在获得权限的情况下这样做.基本的例子也很棒!

                  Currently I have a bot will give you a role if you do a command. I want to make the bot check if the user that does the command has a specific role. As of now I've only seen people do it with permissions. Basic examples would be also great!

                  if message.content.lower().startswith('/role'):
                      user = message.author
                      role = discord.utils.get(user.server.roles, id="437923291047526402")
                      await client.add_roles(user, role)
                  

                  推荐答案

                  要检查on_message中的角色,可以访问作者的角色属性.

                  To check for roles in on_message, you can access the author's roles attribute.

                  if message.content.lower().startswith('/role'):
                      user = message.author
                  
                      if message.channel.is_private or discord.utils.get(user.roles, name="admin") is None:
                          return
                  
                      role = discord.utils.get(user.server.roles, id="437923291047526402")
                      await client.add_roles(user, role)
                  

                  有关命令,请参阅链接的欺骗答案.

                  For commands, see the linked dupe answer.

                  这篇关于如何检查用户是否在 on_message 中具有特定角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:on_reaction_add 未运行 下一篇:background_task.py 不显示消息 - Python

                  相关文章

                  最新文章

                    <legend id='vkd5a'><style id='vkd5a'><dir id='vkd5a'><q id='vkd5a'></q></dir></style></legend>

                      <bdo id='vkd5a'></bdo><ul id='vkd5a'></ul>
                  1. <i id='vkd5a'><tr id='vkd5a'><dt id='vkd5a'><q id='vkd5a'><span id='vkd5a'><b id='vkd5a'><form id='vkd5a'><ins id='vkd5a'></ins><ul id='vkd5a'></ul><sub id='vkd5a'></sub></form><legend id='vkd5a'></legend><bdo id='vkd5a'><pre id='vkd5a'><center id='vkd5a'></center></pre></bdo></b><th id='vkd5a'></th></span></q></dt></tr></i><div id='vkd5a'><tfoot id='vkd5a'></tfoot><dl id='vkd5a'><fieldset id='vkd5a'></fieldset></dl></div>
                    <tfoot id='vkd5a'></tfoot>

                    <small id='vkd5a'></small><noframes id='vkd5a'>