1
0
Fork 0
mirror of synced 2024-06-16 09:34:33 +12:00

Temporarily disable error handling of stuck voice channels

This commit is contained in:
phxntxm 2017-11-08 11:00:22 -06:00
parent 3f13f6af6d
commit 8adde44fb1

View file

@ -658,33 +658,37 @@ class Music:
if voice: if voice:
voice.stop() voice.stop()
await voice.disconnect(force=True) await voice.disconnect(force=True)
# Temporarily disabling what's after this
# So discord has a weird case where the connection can be interrupted, and an auto-reconnect is attempted # So discord has a weird case where the connection can be interrupted, and an auto-reconnect is attempted
# Auto-reconnects aren't handled for bot accounts, and this causes the bot to appear to be in the channel while it's actually not # Auto-reconnects aren't handled for bot accounts, and this causes the bot to appear to be in the channel while it's actually not
# Since this means there is no connection (checked by voice being None) there's nothing to disconnect from # Since this means there is no connection (checked by voice being None) there's nothing to disconnect from
# So our workaround here is try to connect (this may timeout, and force it to now be visually disconnected) then disconnect # So our workaround here is try to connect (this may timeout, and force it to now be visually disconnected) then disconnect
else:
if ctx.message.guild.me.voice: #else:
channel = ctx.message.guild.me.voice.channel # if ctx.message.guild.me.voice:
else: # channel = ctx.message.guild.me.voice.channel
# Get a list of all channels that we can connect to # else:
channels = [c for c in ctx.message.guild.voice_channels if c.permissions_for(ctx.message.guild.me).connect] # # Get a list of all channels that we can connect to
if len(channels) > 0: # channels = [c for c in ctx.message.guild.voice_channels if c.permissions_for(ctx.message.guild.me).connect]
channel = channels[0] # if len(channels) > 0:
# If we can't connect to any channels but we're stuck in a voice channel what is this server doing .-. # channel = channels[0]
# Don't handle this, just return # # If we can't connect to any channels but we're stuck in a voice channel what is this server doing .-.
else: # # Don't handle this, just return
return # else:
# return
# Now simply connect then disconnect # Now simply connect then disconnect
try: # try:
await channel.connect() # await channel.connect()
except asyncio.TimeoutError: # except asyncio.TimeoutError:
pass # pass
else: # else:
# Refresh the guild info, as want whatever the new VoiceClient is # # Refresh the guild info, as want whatever the new VoiceClient is
guild = self.bot.get_guild(ctx.message.guild.id) # guild = self.bot.get_guild(ctx.message.guild.id)
if guild.voice_client: # if guild.voice_client:
await guild.voice_client.disconnect(force=True) # await guild.voice_client.disconnect(force=True)
@commands.command() @commands.command()
@commands.guild_only() @commands.guild_only()
@ -954,6 +958,12 @@ class Music:
error = error[0] error = error[0]
await ctx.send(error) await ctx.send(error)
return return
# They may have removed the bot from the channel during this time, so lets check again
if state.voice is None:
await ctx.send("Failed to join the channel...")
return
# Set the current song as the livestream # Set the current song as the livestream
state.current = source state.current = source
# Use the volume transformer # Use the volume transformer