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

Change error messages

This commit is contained in:
Steffo 2019-10-14 00:05:20 +02:00
parent 9256c3b3c7
commit 32809ab53f
3 changed files with 8 additions and 6 deletions

View file

@ -71,7 +71,8 @@ class PlayCommand(Command):
raise CommandError("PlayCommand only accepts URLs.\n" raise CommandError("PlayCommand only accepts URLs.\n"
"If you want to search a song on YouTube or Soundcloud, please use YoutubeCommand" "If you want to search a song on YouTube or Soundcloud, please use YoutubeCommand"
" or SoundcloudCommand!") " or SoundcloudCommand!")
response = await self.interface.net_request(Request("music_play", {"url": url, "guild_name": guild_name}), "discord") response = await self.interface.net_request(Request("music_play", {"url": url, "guild_name": guild_name}),
"discord")
if len(response["videos"]) == 0: if len(response["videos"]) == 0:
raise CommandError(f"Nessun file trovato.") raise CommandError(f"Nessun file trovato.")
for video in response["videos"]: for video in response["videos"]:

View file

@ -10,6 +10,7 @@ from ...utils import NetworkHandler, asyncify
from ...network import Request, ResponseSuccess from ...network import Request, ResponseSuccess
from ..commanderrors import CommandError from ..commanderrors import CommandError
from ...audio import YtdlDiscord from ...audio import YtdlDiscord
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from ...bots import DiscordBot from ...bots import DiscordBot
@ -39,8 +40,8 @@ class SoundcloudNH(NetworkHandler):
"outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s"
} }
# Start downloading # Start downloading
dfiles: typing. List[YtdlDiscord] = await asyncify(YtdlDiscord.create_from_url, f'scsearch:{data["search"]}', dfiles: typing.List[YtdlDiscord] = await asyncify(YtdlDiscord.create_from_url, f'scsearch:{data["search"]}',
**ytdl_args) **ytdl_args)
await bot.add_to_music_data(dfiles, guild) await bot.add_to_music_data(dfiles, guild)
# Create response dictionary # Create response dictionary
response = { response = {
@ -71,10 +72,10 @@ class SoundcloudCommand(Command):
raise CommandError("SoundcloudCommand only accepts search queries, and you've sent an URL.\n" 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!") "If you want to add a song from an url, please use PlayCommand!")
response = await self.interface.net_request(Request("music_soundcloud", {"search": search, response = await self.interface.net_request(Request("music_soundcloud", {"search": search,
"guild_name": guild_name}), "guild_name": guild_name}),
"discord") "discord")
if len(response["videos"]) == 0: if len(response["videos"]) == 0:
raise CommandError(f"Nessun audio trovato.") raise CommandError(f"Il video non può essere scaricato a causa di un blocco imposto da Soundcloud.")
for video in response["videos"]: for video in response["videos"]:
if self.interface.name == "discord": if self.interface.name == "discord":
# This is one of the unsafest things ever # This is one of the unsafest things ever

View file

@ -73,7 +73,7 @@ class YoutubeCommand(Command):
"guild_name": guild_name}), "guild_name": guild_name}),
"discord") "discord")
if len(response["videos"]) == 0: if len(response["videos"]) == 0:
raise CommandError(f"Il bot non è riuscito a scaricare il video richiesto a causa di un blocco imposto da YouTube.") raise CommandError(f"Il video non può essere scaricato a causa di un blocco imposto da YouTube.")
for video in response["videos"]: for video in response["videos"]:
if self.interface.name == "discord": if self.interface.name == "discord":
# This is one of the unsafest things ever # This is one of the unsafest things ever