feat(discord_bot): 增加添加朋友功能

增加添加朋友功能

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2024-02-01 11:49:15 +08:00
parent fa6bef2c73
commit fa94f38536

View File

@ -75,6 +75,16 @@ async def mod_friend(ctx, steam_id, name):
else: else:
await ctx.respond(content=f'找不到 {steam_id}') 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) @tasks.loop(minutes=1)
async def heartbeat(): async def heartbeat():
utils.heartbeat() utils.heartbeat()