From 754019084cee150b82ac6c1384a7a24aaf8a90ec Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 25 Oct 2019 12:34:19 +0200 Subject: [PATCH] Improve error messages (as suggested by @Viktya) --- royalnet/packs/royal/commands/play.py | 7 ++++--- royalnet/packs/royal/commands/soundcloud.py | 5 +++-- royalnet/packs/royal/commands/videochannel.py | 2 +- royalnet/packs/royal/commands/youtube.py | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/royalnet/packs/royal/commands/play.py b/royalnet/packs/royal/commands/play.py index 1602b2fa..844d5a99 100644 --- a/royalnet/packs/royal/commands/play.py +++ b/royalnet/packs/royal/commands/play.py @@ -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 diff --git a/royalnet/packs/royal/commands/soundcloud.py b/royalnet/packs/royal/commands/soundcloud.py index 70a1b654..6245b660 100644 --- a/royalnet/packs/royal/commands/soundcloud.py +++ b/royalnet/packs/royal/commands/soundcloud.py @@ -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 diff --git a/royalnet/packs/royal/commands/videochannel.py b/royalnet/packs/royal/commands/videochannel.py index bbec1327..a09cd17a 100644 --- a/royalnet/packs/royal/commands/videochannel.py +++ b/royalnet/packs/royal/commands/videochannel.py @@ -47,4 +47,4 @@ class VideochannelCommand(Command): await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n" f"") else: - raise UnsupportedError(f"This command is not supported on {self.interface.name.capitalize()}.") + raise UnsupportedError() diff --git a/royalnet/packs/royal/commands/youtube.py b/royalnet/packs/royal/commands/youtube.py index 3a97f312..ed608765 100644 --- a/royalnet/packs/royal/commands/youtube.py +++ b/royalnet/packs/royal/commands/youtube.py @@ -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