1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/royalpack/commands/diarioshuffle.py
2020-05-11 00:46:12 +02:00

29 lines
805 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import *
import royalnet.commands as rc
import royalnet.utils as ru
from sqlalchemy import func
from ..tables import Diario
class DiarioshuffleCommand(rc.Command):
name: str = "diarioshuffle"
description: str = "Cita una riga casuale del diario."
aliases = ["dis", "dishuffle", "dish"]
syntax = ""
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
DiarioT = self.alchemy.get(Diario)
entry: List[Diario] = await ru.asyncify(
data.session
.query(DiarioT)
.order_by(func.random())
.limit(1)
.one_or_none
)
if entry is None:
raise rc.CommandError("Nessuna riga del diario trovata.")
await data.reply(f" {entry}")