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

    <tfoot id='D9N7c'></tfoot>
    1. <small id='D9N7c'></small><noframes id='D9N7c'>

        <bdo id='D9N7c'></bdo><ul id='D9N7c'></ul>
    2. <legend id='D9N7c'><style id='D9N7c'><dir id='D9N7c'><q id='D9N7c'></q></dir></style></legend>

      1. Discord.py ctx.guild.edit 有效,但 self.bot.guild.edit 无效

        时间:2023-09-10
        <legend id='x1IKg'><style id='x1IKg'><dir id='x1IKg'><q id='x1IKg'></q></dir></style></legend>

          <bdo id='x1IKg'></bdo><ul id='x1IKg'></ul>
              <tbody id='x1IKg'></tbody>

            • <tfoot id='x1IKg'></tfoot>

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

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

                  本文介绍了Discord.py ctx.guild.edit 有效,但 self.bot.guild.edit 无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  正如标题所说,我正在尝试进行公会编辑,但在一个事件中.这是我的部分代码:

                  Like the title says, I'm trying to do guild edits but on an events. Here's part of my code:

                      @commands.guild_only()
                      async def on_ready(self):
                      server = self.bot.get_guild("serverid")
                          while True:
                              await self.bot.guild.edit(guild=server, name="foo")
                              await asyncio.sleep(1)
                              await self.bot.guild.edit(guild=server, name="bar")
                              await asyncio.sleep(1)
                  

                  我已经使用独立命令对其进行了测试,所以我知道 ctx.guild.edit 可以工作,但我不确定如何让它在事件中工作.

                  I've already tested it with a standalone command, so I know that ctx.guild.edit works but I'm not sure how to get it to work in an event.

                  推荐答案

                  你应该调用 edit 直接来自 Guild 对象 server

                  async def on_ready(self):
                  server = self.bot.get_guild(SERVER_ID)
                  while server is not None:
                      await server.edit(name="foo")
                      await asyncio.sleep(1)
                      await server.edit(name="bar")
                      await asyncio.sleep(1)
                  

                  另外,请确保您将公会的 id 作为 int 而不是字符串传递,并且 guild_only 装饰器只能用于命令.

                  Also, make sure that you're passing the id of the guild as an int and not a string, and the guild_only decorator should only be used on commands.

                  这篇关于Discord.py ctx.guild.edit 有效,但 self.bot.guild.edit 无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:首次完成后取消两个异步协程 下一篇:discord.py @bot.command() 没有运行

                  相关文章

                  最新文章

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

                      <tfoot id='h1Jfv'></tfoot>

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

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