Catch a few edge cases
This commit is contained in:
parent
eedcd9572a
commit
8abe27e85c
|
@ -121,7 +121,7 @@ class VoiceState:
|
|||
except IndexError:
|
||||
song = None
|
||||
else:
|
||||
song = await self.dj.get_next_entry()
|
||||
song = await dj.get_next_entry()
|
||||
if song is None:
|
||||
self.djs.remove(dj)
|
||||
await self.next_song()
|
||||
|
@ -345,12 +345,18 @@ class Music:
|
|||
|
||||
# If we can send messages, edit it to let the channel know we have succesfully joined
|
||||
if msg:
|
||||
await msg.edit(content="Ready to play audio in channel {}".format(channel.name))
|
||||
try:
|
||||
await msg.edit(content="Ready to play audio in channel {}".format(channel.name))
|
||||
except discord.NotFound:
|
||||
pass
|
||||
return True
|
||||
# If we time out trying to join, just let them know and return False
|
||||
except asyncio.TimeoutError:
|
||||
if msg:
|
||||
await msg.edit(content="Sorry, but I couldn't connect right now! Please try again later")
|
||||
try:
|
||||
await msg.edit(content="Sorry, but I couldn't connect right now! Please try again later")
|
||||
except discord.NotFound:
|
||||
pass
|
||||
return False
|
||||
# Theoretically this should never happen, however in rare cirumstances it does
|
||||
# This error arises when we are already in a channel and don't use "move"
|
||||
|
|
|
@ -336,10 +336,11 @@ class Playlist:
|
|||
else:
|
||||
delete_msgs.append(await ctx.send("That is not a valid option!"))
|
||||
|
||||
if len(delete_msgs) == 1:
|
||||
await delete_msgs[0].delete()
|
||||
elif len(delete_msgs) > 1:
|
||||
await ctx.message.channel.delete_messages(delete_msgs)
|
||||
if not isinstance(ctx.message.channel, discord.DMChannel):
|
||||
if len(delete_msgs) == 1:
|
||||
await delete_msgs[0].delete()
|
||||
elif len(delete_msgs) > 1:
|
||||
await ctx.message.channel.delete_messages(delete_msgs)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
|
@ -52,7 +52,10 @@ class Playlist(EventEmitter):
|
|||
except Exception as e:
|
||||
if "gaierror" in str(e) or "unknown url type" in str(e):
|
||||
song_url = "ytsearch:" + song_url
|
||||
info = await self.downloader.extract_info(self.loop, song_url, download=False)
|
||||
try:
|
||||
info = await self.downloader.extract_info(self.loop, song_url, download=False)
|
||||
except Exception as e2:
|
||||
raise ExtractionError('Could not extract information from {}\n\n{}'.format(song_url, e))
|
||||
else:
|
||||
raise ExtractionError('Could not extract information from {}\n\n{}'.format(song_url, e))
|
||||
|
||||
|
@ -265,4 +268,4 @@ class Playlist(EventEmitter):
|
|||
return datetime.timedelta(seconds=estimated_time)
|
||||
|
||||
def count_for_user(self, user):
|
||||
return sum(1 for e in self.entries if e.meta.get('author', None) == user)
|
||||
return sum(1 for e in self.entries if e.meta.get('author', None) == user)
|
||||
|
|
Loading…
Reference in a new issue