1
0
Fork 0
mirror of synced 2024-05-19 20:12:30 +12:00

Reorder some parts with join, to ensure we detect the right status

This commit is contained in:
phxntxm 2017-05-14 05:10:40 -05:00
parent dd9b3a4f1b
commit 97ae123c71

View file

@ -308,6 +308,8 @@ class Music:
perms = channel.permissions_for(ctx.message.guild.me)
log.info("Joining channel {} in guild {}".format(channel.id, ctx.message.guild.id))
if not perms.connect or not perms.speak or not perms.use_voice_activation:
await ctx.send("I do not have correct permissions in {}! Please turn on `connect`, `speak`, and `use "
"voice activation`".format(channel.name))
@ -317,13 +319,10 @@ class Music:
try:
if state and state.voice and state.voice.channel:
await state.voice.move_to(channel)
await ctx.send("Joined {} and ready to play".format(channel.name))
return True
else:
self.voice_states[ctx.message.guild.id] = VoiceState(ctx.message.guild, self.bot)
await channel.connect()
await ctx.send("Joined {} and ready to play".format(channel.name))
return True
self.voice_states[ctx.message.guild.id] = VoiceState(ctx.message.guild, self.bot)
return True
except asyncio.TimeoutError:
await ctx.send("Sorry, but I couldn't connect right now! Please try again later")
return False