1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/giftpack/commands/delgift.py

20 lines
654 B
Python
Raw Permalink Normal View History

2019-12-25 01:41:52 +00:00
from typing import *
from royalnet.commands import *
from ..tables import XmasGift
from sqlalchemy.sql.expression import func
class DelgiftCommand(Command):
name: str = "delgift"
description: str = "Elimina dal database il regalo con l'id specificato."
syntax: str = ""
async def run(self, args: CommandArgs, data: CommandData) -> None:
2019-12-25 01:49:51 +00:00
gift = data.session.query(self.alchemy.get(XmasGift)).filter_by(gift_id=int(args[0])).order_by(func.random()).first()
2019-12-25 01:41:52 +00:00
data.session.delete(gift)
await data.reply(f"🎁 Regalo eliminato (bye bye!):\n"
f"{gift}")
await data.session_commit()