mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
Properly handle connect and speak permissions
This commit is contained in:
parent
e8d0c25eee
commit
371f8d0f61
@ -70,6 +70,12 @@ class AuthorNotConnected(NotConnected):
|
||||
class VoiceNotConnected(NotConnected):
|
||||
pass
|
||||
|
||||
class UnauthorizedConnect(Exception):
|
||||
pass
|
||||
|
||||
class UnauthorizedSpeak(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ConnectTimeout(NotConnected):
|
||||
pass
|
||||
@ -976,9 +982,12 @@ class Audio:
|
||||
await self.bot.say("You must join a voice channel before I can"
|
||||
" play anything.")
|
||||
return
|
||||
if not can_connect:
|
||||
except UnauthorizedConnect:
|
||||
await self.bot.say("I don't have permissions to join your"
|
||||
" voice channel.")
|
||||
except UnauthorizedSpeak:
|
||||
await self.bot.say("I don't have permissions to speak in your"
|
||||
" voice channel.")
|
||||
else:
|
||||
await self._join_voice_channel(voice_channel)
|
||||
else: # We are connected but not to the right channel
|
||||
@ -1049,9 +1058,12 @@ class Audio:
|
||||
await self.bot.say("You must join a voice channel before I can"
|
||||
" play anything.")
|
||||
return
|
||||
if not can_connect:
|
||||
except UnauthorizedConnect:
|
||||
await self.bot.say("I don't have permissions to join your"
|
||||
" voice channel.")
|
||||
except UnauthorizedSpeak:
|
||||
await self.bot.say("I don't have permissions to speak in your"
|
||||
" voice channel.")
|
||||
else:
|
||||
await self._join_voice_channel(voice_channel)
|
||||
else: # We are connected but not to the right channel
|
||||
@ -1472,7 +1484,11 @@ class Audio:
|
||||
channel = author.voice_channel
|
||||
if channel is None:
|
||||
raise AuthorNotConnected
|
||||
if channel.permissions_for(server.me):
|
||||
elif channel.permissions_for(server.me).connect is False:
|
||||
raise UnauthorizedConnect
|
||||
elif channel.permissions_for(server.me).speak is False:
|
||||
raise UnauthorizedSpeak
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user