Bugfix: Created channel permissions were not inherited from the category's

This commit is contained in:
Elnath 2021-01-03 23:38:56 +01:00
parent 9bdd0113e2
commit 6cdd236d48
1 changed files with 12 additions and 3 deletions

View File

@ -166,10 +166,19 @@ class VocalMaisBot(commands.Cog):
# The user is not a bot and connected to one of our special watched channels # The user is not a bot and connected to one of our special watched channels
# We create a channel for them and move them into it # We create a channel for them and move them into it
category = channel.category category = channel.category
user_name = user.display_name # Creating the permissions of the channel
user_channel = await category.create_voice_channel(f"{user_name}'s channel", overwrites = {user: discord.PermissionOverwrite(manage_channels = True)}) channel_permissions = category.overwrites # We base them on the category's permissions
if user not in channel_permissions:
channel_permissions[user] = discord.PermissionOverwrite()
channel_permissions[user].manage_channels = True # We allow the user for which we created the channel to change the channel's name
# Computing the channel name
channel_name = f"{user.display_name}'s channel"
# Creating the channel and moving the user into it
user_channel = await category.create_voice_channel(channel_name, overwrites = channel_permissions)
await user.move_to(user_channel) await user.move_to(user_channel)
logger.info(f"[{channel.guild.name}({channel.guild.id})] Created channel {user_channel.name}({user_channel.id}) for {user.display_name}({user.id})") logger.info(f"[{channel.guild.name}({channel.guild.id})] Created channel {user_channel.name}({user_channel.id}) for {user.name}#{user.discriminator}({user.id})")
# Saving the channel in the configuration # Saving the channel in the configuration
self.channels_config.add_channel_to_created(user_channel.guild, user_channel) self.channels_config.add_channel_to_created(user_channel.guild, user_channel)