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

Create diarioquote command (closes #81)

This commit is contained in:
Steffo 2019-11-05 10:56:45 +01:00
parent 36c13bb23b
commit d8bc4b792c
2 changed files with 27 additions and 0 deletions

View file

@ -21,6 +21,7 @@ from .soundcloud import SoundcloudCommand
from .zawarudo import ZawarudoCommand from .zawarudo import ZawarudoCommand
from .emojify import EmojifyCommand from .emojify import EmojifyCommand
from .leagueoflegends import LeagueoflegendsCommand from .leagueoflegends import LeagueoflegendsCommand
from .diarioquote import DiarioquoteCommand
# Enter the commands of your Pack here! # Enter the commands of your Pack here!
available_commands = [ available_commands = [
@ -46,6 +47,7 @@ available_commands = [
ZawarudoCommand, ZawarudoCommand,
EmojifyCommand, EmojifyCommand,
LeagueoflegendsCommand, LeagueoflegendsCommand,
DiarioquoteCommand,
] ]
# Don't change this, it should automatically generate __all__ # Don't change this, it should automatically generate __all__

View file

@ -0,0 +1,25 @@
from royalnet.commands import *
from royalnet.utils import *
from ..tables import Diario
class DiarioquoteCommand(Command):
name: str = "diarioquote"
description: str = "Cita una riga del diario."
aliases = ["dq", "quote", "dquote"]
syntax = "{id}"
tables = {Diario}
async def run(self, args: CommandArgs, data: CommandData) -> None:
try:
entry_id = int(args[0].lstrip("#"))
except ValueError:
raise CommandError("L'id che hai specificato non è valido.")
entry: Diario = await data.session.query(self.alchemy.Diario).get(entry_id)
if entry is None:
raise CommandError("Nessuna riga con quell'id trovata.")
await data.reply(str(entry))