feat(bot.py): 增加获取所有 friend 的命令

增加获取所有 friend 的命令

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2023-09-20 17:13:30 +08:00
parent 42b000fe89
commit 07de32c6c8

View File

@ -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) 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']]) 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) @tasks.loop(minutes=1)
async def heartbeat(): async def heartbeat():