Python Discord.py获取所有行会的名称bot都在1嵌入/消息中
我想让TotalGuillds命令变成1 msg,而不是其中的许多。我该怎么做Python Discord.py获取所有行会的名称bot都在1嵌入/消息中,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,我想让TotalGuillds命令变成1 msg,而不是其中的许多。我该怎么做 @bot.command() async def showguilds(ctx): for guild in bot.guilds: await ctx.send(guild.name) 这可以通过查看bot.guilds并将其添加到变量中来实现 @bot.command() 异步def显示协会(ctx): message=“” 对于bot.guilds中的帮会: message
@bot.command()
async def showguilds(ctx):
for guild in bot.guilds:
await ctx.send(guild.name)
这可以通过查看bot.guilds并将其添加到变量中来实现
@bot.command()
异步def显示协会(ctx):
message=“”
对于bot.guilds中的帮会:
message+=f“{guild.name}\n”
等待ctx发送(消息)
或者,您可以使用以下列表:
@bot.command()
异步def显示协会(ctx):
消息=[]
对于bot.guilds中的帮会:
messages.append(f“{guild.name}”)
等待ctx.send(“\n.join(消息))
如果你想让所有的公会都在一行一条信息中,那么乌卡斯·科维茨基的解决方案是:
@bot.command()
异步def显示协会(ctx):
等待ctx.send(“\n.join(bot.guilds))
bot.guilds
已经是一个列表,你只需做等待ctx.send(“\n.join(bot.guilds))
一行@ukaszKwieciński tellme为什么要他们的名字,我的答案允许tellme为什么在末尾添加ID,如果他们愿意的话