diff --git a/discord_bot.py b/discord_bot.py index 032d784..2249ac4 100644 --- a/discord_bot.py +++ b/discord_bot.py @@ -75,6 +75,16 @@ async def mod_friend(ctx, steam_id, name): else: await ctx.respond(content=f'找不到 {steam_id}') +@bot.command(description='添加朋友', name='add_friend') +async def add_friend(ctx, steam_id, name): + logger.info(f'add_friend {steam_id} {name}') + friend = dota.Friend.get_or_none(steam_id=steam_id) + if friend: + await ctx.respond(content=f'已经存在 {steam_id} {name}') + else: + friend = dota.Friend.create(steam_id=steam_id, name=name) + await ctx.respond(content=f'添加成功 {steam_id} {name}') + @tasks.loop(minutes=1) async def heartbeat(): utils.heartbeat()