mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
19 lines
667 B
Python
19 lines
667 B
Python
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:
|
|
gift = data.session.query(self.alchemy.get(XmasGift)).filter_by(drawn=False, gift_id=int(args[0])).order_by(func.random()).first()
|
|
data.session.delete(gift)
|
|
await data.reply(f"🎁 Regalo eliminato (bye bye!):\n"
|
|
f"{gift}")
|
|
await data.session_commit()
|