• <small id='GLU5j'></small><noframes id='GLU5j'>

      <tfoot id='GLU5j'></tfoot>

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

        更改用户的昵称——Discord.py

        时间:2023-10-10

      3. <tfoot id='6CxDZ'></tfoot>

        1. <small id='6CxDZ'></small><noframes id='6CxDZ'>

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

                  本文介绍了更改用户的昵称——Discord.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当用户的角色更新时,我希望机器人在 Admin 之后以他们的名字附加他们的用户名,例如.管理员 |用户名 但它不起作用.这是我的代码:

                  When a user's role gets updated, I would like the bot to append their username after Admin in their name Eg. Admin | username But it doesn't work. Here's my code:

                  @client.event
                  async def on_member_update(before, after):
                      role = discord.utils.get(before.guild.roles, name="Admin")
                      if after in role.members:
                            await after.edit(nick="Admin | " + discord.user, reason=None)
                  

                  推荐答案

                  discord.user 是一个类,我们想要一个字符串,它是用户的昵称,user_name.

                  discord.user is a class, we want a string that is the nick, user_name of the user.

                  @client.event
                  async def on_member_update(before, after):
                      role = discord.utils.get(before.guild.roles, name="Admin")
                      if after.nick is not None and after.nick.startswith("Admin |"):
                          return
                      if after in role.members:
                            await after.edit(nick="Admin | " + after.display_name, reason=None) #discord.user is a class, we want the member's new display name.
                  

                  这篇关于更改用户的昵称——Discord.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 discord.py 获取不和谐服务器中所有成员 下一篇:Discord.py:NameError:未定义名称“意图"

                  相关文章

                  最新文章

                  • <bdo id='axLth'></bdo><ul id='axLth'></ul>
                  <legend id='axLth'><style id='axLth'><dir id='axLth'><q id='axLth'></q></dir></style></legend>
                  1. <small id='axLth'></small><noframes id='axLth'>

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

                    1. <tfoot id='axLth'></tfoot>