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

Improve error messages (as suggested by @Viktya)

This commit is contained in:
Steffo 2019-10-25 12:34:19 +02:00
parent 633dd37383
commit 754019084c
4 changed files with 11 additions and 8 deletions

View file

@ -61,9 +61,10 @@ class PlayCommand(Command):
async def run(self, args: CommandArgs, data: CommandData) -> None:
guild_name, url = args.match(r"(?:\[(.+)])?\s*<?(.+)>?")
if not (url.startswith("http://") or url.startswith("https://")):
raise CommandError("PlayCommand only accepts URLs.\n"
"If you want to search a song on YouTube or Soundcloud, please use YoutubeCommand"
" or SoundcloudCommand!")
raise CommandError(f"Il comando [c]{self.interface.prefix}play[/c] funziona solo per riprodurre file da"
f" un URL.\n"
f"Se vuoi cercare un video, usa [c]{self.interface.prefix}youtube[/c] o"
f" [c]{self.interface.prefix}soundcloud[/c]!")
response: dict = await self.interface.call_herald_action("discord", self._event_name, {
"guild_name": guild_name,
"url": url

View file

@ -59,8 +59,9 @@ class SoundcloudCommand(Command):
async def run(self, args: CommandArgs, data: CommandData) -> None:
guild_name, search = args.match(r"(?:\[(.+)])?\s*<?(.+)>?")
if search.startswith("http://") or search.startswith("https://"):
raise CommandError("SoundcloudCommand only accepts search queries, and you've sent an URL.\n"
"If you want to add a song from an url, please use PlayCommand!")
raise CommandError(f"Il comando [c]{self.interface.prefix}soundcloud[/c] funziona solo per cercare audio su"
f" Soundcloud con un dato nome.\n"
f"Se vuoi riprodurre una canzone da un URL, usa [c]{self.interface.prefix}play[/c]!")
response = await self.interface.call_herald_action("discord", self._event_name, {
"guild_name": guild_name,
"search": search

View file

@ -47,4 +47,4 @@ class VideochannelCommand(Command):
await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n"
f"<https://discordapp.com/channels/{channel.guild.id}/{channel.id}>")
else:
raise UnsupportedError(f"This command is not supported on {self.interface.name.capitalize()}.")
raise UnsupportedError()

View file

@ -58,8 +58,9 @@ class YoutubeCommand(Command):
async def run(self, args: CommandArgs, data: CommandData) -> None:
guild_name, search = args.match(r"(?:\[(.+)])?\s*<?(.+)>?")
if search.startswith("http://") or search.startswith("https://"):
raise CommandError("YoutubeCommand only accepts search queries, and you've sent an URL.\n"
"If you want to add a song from an url, please use PlayCommand!")
raise CommandError(f"Il comando [c]{self.interface.prefix}youtube[/c] funziona solo per cercare video su"
f" YouTube con un dato nome.\n"
f"Se vuoi riprodurre una canzone da un URL, usa [c]{self.interface.prefix}play[/c]!")
response = await self.interface.call_herald_action("discord", self._event_name, {
"guild_name": guild_name,
"search": search