python - Discord.py 不显示它有多少台服务器

标签 python

我的代码:

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

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

最佳答案

我试过你的代码。

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

使用 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")

下图显示了它是如何执行的: No Error!


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

谢谢! :)

关于python - Discord.py 不显示它有多少台服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67055184/

相关文章:

python - AttributeError:模块 Django.contrib.auth.views 没有属性

python - 使用 mplfinance/matplotlib 时可能出现内存泄漏。如何解决?

python - 在 Matplotlib 中,如何将 3D 图作为插图包含在内?

python - 为什么 abc.ABCMeta 抽象实例化检查不适用于 `list` 和 `dict` 的衍生物?

python - 在 Python 中,测试函数的标准输出

python - aiopg 现在支持 python 3.6 吗?

python - 在关系一侧的子集上查询多对多关系

python - 使用 pywin32 更改打印机托盘

python - Elasticsearch -无法解析查询

python - python模块.exe文件的无人值守安装