【问题标题】:Discord.py bot guild countDiscord.py 机器人公会计数
【发布时间】:2021-01-29 10:20:42
【问题描述】:

我正在尝试获取我的机器人所在的公会数量,这是我当前的代码:

@client.command()
async def servers(ctx):
    await ctx.send(f"{str(client.guilds)}")

但机器人只是回复[<Guild id=739683588408082462 name='Epic bot testing' shard_id=None chunked=True member_count=17>] 我该如何解决这个问题?

【问题讨论】:

    标签: python-3.x discord discord.py-rewrite


    【解决方案1】:

    client.guilds 是公会列表,因此您只需将 str 更改为 len 即可获得该列表的长度。

    @client.command()
    async def servers(ctx):
        await ctx.send(f"{len(client.guilds)}")
    

    【讨论】:

      猜你喜欢
      • 2021-09-05
      • 2021-02-27
      • 2021-02-15
      • 2021-05-12
      • 2021-06-17
      • 1970-01-01
      • 2021-05-03
      • 2019-10-17
      • 2022-06-15
      相关资源
      最近更新 更多