<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离开服务器

        时间:2024-08-10

          <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离开服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Discord.py discord.Embed.from_dict未正确创建嵌入 下一篇:我不能用不和谐的方式得到某些行会。

                  相关文章

                    • <bdo id='rYAER'></bdo><ul id='rYAER'></ul>
                    <tfoot id='rYAER'></tfoot>
                  1. <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>

                  2. <legend id='rYAER'><style id='rYAER'><dir id='rYAER'><q id='rYAER'></q></dir></style></legend>

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