首页 > 解决方案 > Discord.py 不显示它所在的服务器数量

问题描述

我的代码:

@bot.command()
async def servers(ctx):
  await ctx.send( f"I'm in {str(len(client.guilds))} servers")

当我使用命令时,它说:I'm in 0 servers,但它不在 0 个服务器中。

标签: python

解决方案


我试过你的代码。

此代码中没有错误,它按应有的方式运行。我试过这段代码:

使用 str()

@bot.command()
async def servers(ctx):
  await ctx.send( f"I'm in {str(len(client.guilds))} servers")

没有 str()

@bot.command()
async def servers(ctx):
  await ctx.send( f"I'm in {len(client.guilds)} servers")

下图显示了它是如何执行的: 没有错误!


我想先看看你的整个代码。

谢谢你!:)


推荐阅读