1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Migrate /pug to /dog

This commit is contained in:
Steffo 2020-07-18 16:29:43 +02:00
parent e6f5170bd7
commit d70477ec6d
Signed by: steffo
GPG key ID: 896A80F55F7C97F0
2 changed files with 13 additions and 9 deletions

View file

@ -43,7 +43,7 @@ from .ping import PingCommand
from .play import PlayCommand
from .playmode import PlaymodeCommand
from .pmots import PmotsCommand
from .pug import PugCommand
from .dog import DogCommand
from .queue import QueueCommand
from .rage import RageCommand
from .reminder import ReminderCommand
@ -110,7 +110,7 @@ available_commands = [
PlayCommand,
PlaymodeCommand,
PmotsCommand,
PugCommand,
DogCommand,
QueueCommand,
RageCommand,
ReminderCommand,

View file

@ -4,18 +4,22 @@ import aiohttp
import io
class PugCommand(rc.Command):
name: str = "pug"
class DogCommand(rc.Command):
name: str = "dog"
description: str = "Invia un carlino casuale in chat."
description: str = "Invia un cane della razza specificata in chat."
syntax: str = ""
aliases = ["carlino", "carlo", "mallllco"]
syntax: str = "[razza]"
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
breed = args.joined()
if breed:
url = f"https://dog.ceo/api/breed/{breed}/images/random"
else:
url = f"https://dog.ceo/api/breeds/image/random"
async with aiohttp.ClientSession() as session:
async with session.get("https://dog.ceo/api/breed/pug/images/random") as response:
async with session.get(url) as response:
if response.status >= 400:
raise rc.ExternalError(f"Request returned {response.status}")
result = await response.json()