mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-16 22:32:30 -05:00
check both connect and speak permissions before performing audio actions (#5012)
This commit is contained in:
@@ -532,14 +532,16 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
return False
|
||||
try:
|
||||
if (
|
||||
not ctx.author.voice.channel.permissions_for(ctx.me).connect
|
||||
not self.can_join_and_speak(ctx.author.voice.channel)
|
||||
or not ctx.author.voice.channel.permissions_for(ctx.me).move_members
|
||||
and self.is_vc_full(ctx.author.voice.channel)
|
||||
):
|
||||
await self.send_embed_msg(
|
||||
ctx,
|
||||
title=_("Unable To Get Playlists"),
|
||||
description=_("I don't have permission to connect to your channel."),
|
||||
description=_(
|
||||
"I don't have permission to connect and speak in your channel."
|
||||
),
|
||||
)
|
||||
return False
|
||||
await lavalink.connect(
|
||||
|
||||
@@ -53,6 +53,10 @@ class ValidationUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||
def is_vc_full(self, channel: discord.VoiceChannel) -> bool:
|
||||
return not (channel.user_limit == 0 or channel.user_limit > len(channel.members))
|
||||
|
||||
def can_join_and_speak(self, channel: discord.VoiceChannel) -> bool:
|
||||
current_perms = channel.permissions_for(channel.guild.me)
|
||||
return current_perms.speak and current_perms.connect
|
||||
|
||||
async def is_query_allowed(
|
||||
self,
|
||||
config: Config,
|
||||
|
||||
Reference in New Issue
Block a user