From 07de32c6c83509f058a28eca820e220f177544a6 Mon Sep 17 00:00:00 2001 From: Ching Date: Wed, 20 Sep 2023 17:13:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(bot.py):=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=89=80=E6=9C=89=20friend=20=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加获取所有 friend 的命令 Signed-off-by: Ching --- discord_bot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/discord_bot.py b/discord_bot.py index 8295ce3..9d5bc02 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -51,6 +51,17 @@ async def get_friends_recent_matches(ctx, name, match_count=5): # a slash comman data = dota.Friend.serialize_recent_matches_for_discord(friends, match_count) await ctx.respond(content=data['content'], embeds=[discord.Embed.from_dict(embed) for embed in data['embeds']]) +@bot.command(description='获取朋友', name='list_friends') +async def get_friends(ctx): + logger.info(f'get_friends') + friends = dota.Friend.select() + msg = '' + if friends.count() == 0: + msg = '没有朋友' + else: + for friend in friends: + msg += f'{friend.name} {friend.steam_id}\n' + await ctx.respond(content=msg) @tasks.loop(minutes=1) async def heartbeat():