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

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

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

        在单个嵌入中列出所有具有多个服务器的公会

        时间:2023-09-10

        1. <tfoot id='HD4sc'></tfoot>
        2. <small id='HD4sc'></small><noframes id='HD4sc'>

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

                <i id='HD4sc'><tr id='HD4sc'><dt id='HD4sc'><q id='HD4sc'><span id='HD4sc'><b id='HD4sc'><form id='HD4sc'><ins id='HD4sc'></ins><ul id='HD4sc'></ul><sub id='HD4sc'></sub></form><legend id='HD4sc'></legend><bdo id='HD4sc'><pre id='HD4sc'><center id='HD4sc'></center></pre></bdo></b><th id='HD4sc'></th></span></q></dt></tr></i><div id='HD4sc'><tfoot id='HD4sc'></tfoot><dl id='HD4sc'><fieldset id='HD4sc'></fieldset></dl></div>
                  <tbody id='HD4sc'></tbody>
                • <bdo id='HD4sc'></bdo><ul id='HD4sc'></ul>
                • 本文介绍了在单个嵌入中列出所有具有多个服务器的公会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是我当前的代码,它显示了它当前所在的服务器.这是我想要做的,但它效率不高,可以避免,而不是为它获得的每个服务器发送嵌入消息.

                  This is my current code which shows the servers it is currently in. Which this does what I would like it to do, but it is not efficient and can be avoided instead of sending an embed message for each server it gets.

                  @client.command()
                  @commands.is_owner()
                  async def list_guilds(ctx):
                      servers = client.guilds
                      for guild in servers:
                          embed = discord.Embed(colour=0x7289DA)
                          embed.set_footer(text=f"Guilds requested by {ctx.author}", icon_url=ctx.author.avatar_url)
                          embed.add_field(name=(str(guild.name)), value=str(guild.member_count)+ " members", inline=False)
                          await ctx.send(embed=embed)
                  

                  我想要做的是循环它所在的所有服务器并仅在单个嵌入中包含 10 个服务器后发送一个嵌入,然后它会发送另一个,避免使用嵌入垃圾邮件.

                  What I would like to do is loop though all servers it is in and send an embed only after it has included 10 servers on a single embed, then it would send another, avoiding the use of embed spam.

                  for client.guilds in range(10):
                  

                  例如,嵌入应该如下所示:

                  Then for example, the embed should look like:

                  Guilds list (page 1) showing 10 per embed
                  
                  Discord server 0
                  Discord server 1
                  Discord server 2
                  Discord server 3
                  Discord server 4
                  ...
                  ....
                  

                  这将简单地创建一个包含 10 个服务器的嵌入,名称和服务器所有者等,但目前只需要帮助在一个嵌入上发送多个服务器名称,而不是为每个服务器发送多个嵌入,它会发送目前600+.有人可以帮忙吗?

                  Which would simply create an embed with 10 servers on it, the name and the server owner etc, but currently just need help with sending multiple server names on one embed, instead of sending multiple embeds for each server, which it would send 600+ currently. Would anyone please be able to help?

                  推荐答案

                  迭代列表的每十个值,这里是一个例子:

                  Iterate every ten values of the list, here's an example:

                  >>> lst = list(range(1, 26))
                  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 25]
                  >>>
                  >>> for i in range(0, len(lst), 10):
                  ...     print(lst[i:i + 10])
                  ...
                  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                  [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
                  [21, 22, 23, 24, 25]
                  

                  这里适用于您的代码:

                  for i in range(0, len(client.guilds), 10):
                      embed = discord.Embed(title='Guilds', colour=0x7289DA)
                      guilds = client.guilds[i:i + 10]
                  
                      for guild in guilds:
                          embed.add_field(name=guild.name, value='whatever')
                  
                      await ctx.send(embed=embed)
                  

                  这篇关于在单个嵌入中列出所有具有多个服务器的公会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Python discord bot 中获取提到的用户的 ID? 下一篇:Py.test:对类中的测试用例进行参数化

                  相关文章

                  最新文章

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

                      <tfoot id='yd3HP'></tfoot>

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

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

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