Give permission to players to pin messages in their own channel

This commit is contained in:
Elnath 2021-07-26 22:39:56 +02:00
parent f0c164fd51
commit 75a653270e
1 changed files with 5 additions and 5 deletions

View File

@ -332,15 +332,11 @@ class Game:
async def create_player_channels(): async def create_player_channels():
create_player_channel_tasks = [] create_player_channel_tasks = []
# Discord channel positions are not relative to the category and not necessarily absolute, but a channel in same category than another with a higher
# position attribute will be sorted lower.
# See https://github.com/Rapptz/discord.py/issues/2392#issuecomment-707455919
observer_channel_position = self.get_observer_channel().position
async def create_player_channel(player: discord.Member, channel_position: int): async def create_player_channel(player: discord.Member, channel_position: int):
perms = { perms = {
self.guild.default_role: discord.PermissionOverwrite(read_messages = False), self.guild.default_role: discord.PermissionOverwrite(read_messages = False),
player: discord.PermissionOverwrite(read_messages = True), player: discord.PermissionOverwrite(read_messages = True, manage_messages = True), # Allow the player to pin messages in its own channel
gm_role: discord.PermissionOverwrite(read_messages = True), gm_role: discord.PermissionOverwrite(read_messages = True),
observer_role: discord.PermissionOverwrite(read_messages = True, send_messages = False), observer_role: discord.PermissionOverwrite(read_messages = True, send_messages = False),
} }
@ -349,6 +345,10 @@ class Game:
logger.debug(f"[{self.guild.name}] Created channel for player {player.name}") logger.debug(f"[{self.guild.name}] Created channel for player {player.name}")
asyncio.create_task(player_channel.send(f"Hello! This is your private channel.\nIn here you can cast your votes, interact with the <@&{self.get_gm_role_id()}>, and write freely.\nHave a nice game!", allowed_mentions = discord.AllowedMentions(roles = True))) asyncio.create_task(player_channel.send(f"Hello! This is your private channel.\nIn here you can cast your votes, interact with the <@&{self.get_gm_role_id()}>, and write freely.\nHave a nice game!", allowed_mentions = discord.AllowedMentions(roles = True)))
# Discord channel positions are not relative to the category and not necessarily absolute, but a channel in same category than another with a higher
# position attribute will be sorted lower.
# See https://github.com/Rapptz/discord.py/issues/2392#issuecomment-707455919
observer_channel_position = self.get_observer_channel().position
for i, player in enumerate(self.get_players()): for i, player in enumerate(self.get_players()):
create_player_channel_tasks.append(asyncio.create_task(create_player_channel(player, observer_channel_position + i + 1))) create_player_channel_tasks.append(asyncio.create_task(create_player_channel(player, observer_channel_position + i + 1)))
await asyncio.wait(create_player_channel_tasks) await asyncio.wait(create_player_channel_tasks)