[Audio] Fix [p]stop error when user is not in the channel (#480)

This commit is contained in:
Sentry 2016-11-20 21:30:48 +01:00 committed by Twentysix
parent 5acf2f8ec7
commit fba3a079dd

View File

@ -1714,8 +1714,7 @@ class Audio:
reply += " (%d%% out of %d%% needed)" % (vote, thresh)
await self.bot.reply(reply)
else:
await self.bot.reply("you aren't in the current playback"
" channel.")
await self.bot.say("You need to be in the voice channel to skip the music.")
else:
await self.bot.say("Can't skip if I'm not playing.")
@ -1732,6 +1731,7 @@ class Audio:
is_admin = discord.utils.get(member.roles, name=admin_role) is not None
is_mod = discord.utils.get(member.roles, name=mod_role) is not None
nonbots = sum(not m.bot for m in member.voice_channel.voice_members)
alone = nonbots <= 1
@ -1786,13 +1786,16 @@ class Audio:
"""Stops a currently playing song or playlist. CLEARS QUEUE."""
server = ctx.message.server
if self.is_playing(server):
if self.can_instaskip(ctx.message.author):
await self.bot.say('Stopping...')
self._stop(server)
if ctx.message.author.voice_channel == server.me.voice_channel:
if self.can_instaskip(ctx.message.author):
await self.bot.say('Stopping...')
self._stop(server)
else:
await self.bot.say("You can't stop music when there are other"
" people in the channel! Vote to skip"
" instead.")
else:
await self.bot.say("You can't stop music when there are other"
" people in the channel! Vote to skip"
" instead.")
await self.bot.say("You need to be in the voice channel to stop the music.")
else:
await self.bot.say("Can't stop if I'm not playing.")
@ -2081,7 +2084,7 @@ def verify_ffmpeg_avconv():
def setup(bot):
check_folders()
check_files()
if youtube_dl is None:
raise RuntimeError("You need to run `pip3 install youtube_dl`")
if opus is False:
@ -2105,7 +2108,7 @@ def setup(bot):
"and do ALL the steps in order.\n"
"https://twentysix26.github.io/Red-Docs/\n"
"".format(msg))
n = Audio(bot, player=player) # Praise 26
bot.add_cog(n)
bot.add_listener(n.voice_state_update, 'on_voice_state_update')