支持列出所有服务器

This commit is contained in:
xtaodada 2021-07-25 18:19:48 +08:00
parent d763bf94d6
commit 9598d241fb
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736

View File

@ -44,7 +44,10 @@ class Info(commands.Cog):
embed.add_field(name="主机平台", value=sys.platform) embed.add_field(name="主机平台", value=sys.platform)
embed.add_field(name="Kernel", value=uname().release) embed.add_field(name="Kernel", value=uname().release)
embed.add_field(name="数据库", value=database) embed.add_field(name="数据库", value=database)
embed.add_field(name="服务器数", value=str(len(self.bot.guilds)))
embed.add_field(name="交流群", value='[点击加入](https://discord.gg/A4mWpa83e6)') embed.add_field(name="交流群", value='[点击加入](https://discord.gg/A4mWpa83e6)')
embed.add_field(name="邀请", value=f'[点击邀请](https://discord.com/oauth2/authorize'
f'?client_id={app_info.id}&scope=bot)')
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command() @commands.command()
@ -77,11 +80,19 @@ class Info(commands.Cog):
else: else:
await context.reply('您好像输入了一个无效的参数。') await context.reply('您好像输入了一个无效的参数。')
@commands.command()
async def servers(self, context):
guilds = sorted(self.bot.guilds, key=lambda s: s.name.lower())
msg = "\n".join(f"{guild.name} (`{guild.id}`)" for guild in guilds)
await context.send(msg)
des_handler('info', '查看程序信息。') des_handler('info', '查看程序信息。')
par_handler('info', '') par_handler('info', '')
des_handler('trace', '追踪重定向。') des_handler('trace', '追踪重定向。')
par_handler('trace', '<url>') par_handler('trace', '<url>')
des_handler('servers', '列出所有服务器。')
par_handler('servers', '')
def setup(bot): def setup(bot):