mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Audio] Respect voice channel permissions (#1878)
* [V3 Audio] Respect voice channel permissions * [V3 Audio] Respect the user limit * [V3 Audio] Exemption for channels with no limit
This commit is contained in:
parent
cd6af7f185
commit
eb73e48192
@ -15,7 +15,7 @@ from .manager import shutdown_lavalink_server
|
||||
|
||||
_ = Translator("Audio", __file__)
|
||||
|
||||
__version__ = "0.0.6b"
|
||||
__version__ = "0.0.6c"
|
||||
__author__ = ["aikaterna", "billy/bollo/ati"]
|
||||
|
||||
|
||||
@ -586,6 +586,12 @@ class Audio:
|
||||
shuffle = await self.config.guild(ctx.guild).shuffle()
|
||||
if not self._player_check(ctx):
|
||||
try:
|
||||
if not ctx.author.voice.channel.permissions_for(
|
||||
ctx.me
|
||||
).connect == True or self._userlimit(ctx.author.voice.channel):
|
||||
return await self._embed_msg(
|
||||
ctx, "I don't have permission to connect to your channel."
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
@ -993,6 +999,12 @@ class Audio:
|
||||
return False
|
||||
if not self._player_check(ctx):
|
||||
try:
|
||||
if not ctx.author.voice.channel.permissions_for(
|
||||
ctx.me
|
||||
).connect == True or self._userlimit(ctx.author.voice.channel):
|
||||
return await self._embed_msg(
|
||||
ctx, "I don't have permission to connect to your channel."
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
@ -1210,6 +1222,12 @@ class Audio:
|
||||
"""
|
||||
if not self._player_check(ctx):
|
||||
try:
|
||||
if not ctx.author.voice.channel.permissions_for(
|
||||
ctx.me
|
||||
).connect == True or self._userlimit(ctx.author.voice.channel):
|
||||
return await self._embed_msg(
|
||||
ctx, "I don't have permission to connect to your channel."
|
||||
)
|
||||
await lavalink.connect(ctx.author.voice.channel)
|
||||
player = lavalink.get_player(ctx.guild.id)
|
||||
player.store("connect", datetime.datetime.utcnow())
|
||||
@ -1887,6 +1905,15 @@ class Audio:
|
||||
track_obj[key] = value
|
||||
return track_obj
|
||||
|
||||
@staticmethod
|
||||
def _userlimit(channel):
|
||||
if channel.user_limit == 0:
|
||||
return False
|
||||
if channel.user_limit < len(channel.members) + 1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
async def on_voice_state_update(self, member, before, after):
|
||||
if after.channel != before.channel:
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user