From 268c46f68b2f607b5a85fa08b5cc3fa467236ee5 Mon Sep 17 00:00:00 2001 From: Jason Khan <43140671+khanjason@users.noreply.github.com> Date: Mon, 30 Nov 2020 17:05:22 +0000 Subject: [PATCH] youtubedl error msg --- cogs/Chair.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/cogs/Chair.py b/cogs/Chair.py index e188114..a0b4150 100644 --- a/cogs/Chair.py +++ b/cogs/Chair.py @@ -5,7 +5,7 @@ from collections import defaultdict from discord.ext import commands, tasks from discord.utils import get -from youtube_dl import YoutubeDL +from youtube_dl import YoutubeDL, utils class Chair(commands.Cog): def __init__(self, bot): self.bot = bot @@ -195,10 +195,14 @@ def check(message): }], 'outtmpl': 'song.%(ext)s', } - with YoutubeDL(YDL_OPTIONS) as ydl: - ydl.download([url]) - voice_client.play(FFmpegPCMAudio("song.mp3")) - voice_client.is_playing() + try: + with YoutubeDL(YDL_OPTIONS) as ydl: + ydl.download([url]) + voice_client.play(FFmpegPCMAudio("song.mp3")) + voice_client.is_playing() + except utils.DownloadError: + embedVar = discord.Embed(title="Error", description="YoutubeDL failed to download Gavel Sound Effect.", color=discord.Color.from_rgb(78,134,219)) + m= await ctx.channel.send(embed=embedVar) @@ -236,10 +240,15 @@ def check(message): }], 'outtmpl': 'song.%(ext)s', } - with YoutubeDL(YDL_OPTIONS) as ydl: - ydl.download([url]) - voice_client.play(FFmpegPCMAudio("song.mp3")) - voice_client.is_playing() + try: + with YoutubeDL(YDL_OPTIONS) as ydl: + ydl.download([url]) + voice_client.play(FFmpegPCMAudio("song.mp3")) + voice_client.is_playing() + + except utils.DownloadError: + embedVar = discord.Embed(title="Error", description="YoutubeDL failed to download Gavel Sound Effect.", color=discord.Color.from_rgb(78,134,219)) + m= await ctx.channel.send(embed=embedVar) @commands.has_role('Chair') @commands.command(pass_context=True,brief='Register a delegate.', description='Requires !register [delegate name] [status].\n Status can be present (p),present and voting(pv) or absent (a)') async def register(self,ctx,*,args):