Optimized code

This commit is contained in:
Choco
2024-04-12 19:36:35 +08:00
parent 61b633f643
commit 88a879f98a
7 changed files with 54 additions and 37 deletions

View File

@@ -147,7 +147,15 @@ async def send(ctx: Union[commands.Context, discord.Interaction], key: str, *par
text = await get_lang(ctx.guild.id, key)
text = text.format(*params)
send_func = ctx.send if isinstance(ctx, commands.Context) else (ctx.followup.send if ctx.response.is_done() else ctx.response.send_message)
if isinstance(ctx, commands.Context):
send_func = ctx.send
else:
if not ctx.response.is_done():
send_func = ctx.response.send_message
else:
return await ctx.followup.send(text, ephemeral=ephemeral, allowed_mentions=ALLOWED_MENTIONS)
return await send_func(text, delete_after=delete_after, ephemeral=ephemeral, allowed_mentions=ALLOWED_MENTIONS)
async def update_db(db: AsyncIOMotorCollection, tempStore: dict, filter: dict, data: dict) -> bool: