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

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

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

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

        Discord.py离开服务器

        Discord.py Leaving a server(Discord.py离开服务器)

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

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

          <tfoot id='KZNsj'></tfoot>

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

                    <tbody id='KZNsj'></tbody>
                  本文介绍了Discord.py离开服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我无法访问我的机器人所在的某些测试服务器,我希望机器人离开它们,我的代码是

                  @bot.command()
                  @commands.is_owner()
                  async def guilds(ctx):
                    await ctx.channel.purge(limit=1)
                    guild = ""
                    servers = bot.guilds
                    for a in servers:
                      guild += f"{a}
                  "
                      if a == "Fleshy's server":
                        b = a.id()
                        await bot.leave(b)
                    await ctx.author.send(guild)
                  
                  当我使用它时,我没有得到任何错误,但它也不会离开肉体的服务器 这些是他所在的服务器 my server The Judas Cradle 7 test server yosh’s rock Fleshy's server Retronized Cafe Fleshy's server Fleshy's server Able's Hub

                  推荐答案

                  如果您希望通过知道工会名称来离开该工会,可以运行以下命令:

                  @bot.command()
                  async def leaveg(ctx, *, guild_name):
                      guild = discord.utils.get(bot.guilds, name=guild_name) # Get the guild by name
                      if guild is None:
                          print("No guild with that name found.") # No guild found
                          return
                      await guild.leave() # Guild found
                      await ctx.send(f"I left: {guild.name}!")
                  
                  • 我们使用*是为了还允许名称中包含空格
                  • 导入from discord.utils import get

                  如果您知道服务器的ID,还可以运行以下命令:

                  @bot.command()
                  async def leave(ctx, guild_id):
                      await bot.get_guild(int(guild_id)).leave()
                      await ctx.send(f"I left: {guild_id}")
                  
                  • 导入from discord.utils import get
                  • 请务必填入ID:leave ServerID

                  您还可以查看docs。

                  这篇关于Discord.py离开服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                  How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                  Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                  How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                  Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                  How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                    • <bdo id='rYAER'></bdo><ul id='rYAER'></ul>
                      <tfoot id='rYAER'></tfoot>

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

                        • <legend id='rYAER'><style id='rYAER'><dir id='rYAER'><q id='rYAER'></q></dir></style></legend>

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

                              <tbody id='rYAER'></tbody>