diff --git a/GameFiles/Game.py b/GameFiles/Game.py index e7b2390..e457b61 100644 --- a/GameFiles/Game.py +++ b/GameFiles/Game.py @@ -171,6 +171,14 @@ class Game: def get_observer_channel(self) -> discord.TextChannel: return self.guild.get_channel(self.get_observer_channel_id()) + @game_started + def get_discussion_channel_id(self) -> int: + return self.config["discussion_chan"] + + @game_started + def get_discussion_channel(self) -> discord.TextChannel: + return self.guild.get_channel(self.get_discussion_channel_id()) + @game_started def is_vote_running(self) -> bool: return self.config["vote"] is not None @@ -330,6 +338,14 @@ class Game: await asyncio.wait(create_player_channel_tasks) await create_player_channels() + @game_started + @save_on_success + async def open_secret_channels(self): + tasks = [] + for channel in [self.get_discussion_channel(), self.get_observer_channel()] + [self.get_player_channel(player_id) for player_id in self.get_players_id()]: + tasks.append(asyncio.create_task(channel.edit(overwrites = {}))) + await asyncio.wait(tasks) + @game_started @save_on_success async def delete(self): diff --git a/SecretBot.py b/SecretBot.py index 68fa80c..57c5ef8 100755 --- a/SecretBot.py +++ b/SecretBot.py @@ -181,6 +181,20 @@ class SecretBot(commands.Cog): await game.start(player_role, self.bot.user.id) await ctx.reply(":white_check_mark: Game started!") + @commands.command("StopGame", help = "Open all secret channels, to be done when a game has ended") + async def stop_game_with_confirmation(self, ctx: commands.Context): + game = await self.get_running_game_or_error_message(ctx) + await self.check_in_admin_channel_or_error_message(ctx, game) + await self.check_is_administrator_or_gm(ctx) + await self.confirm_action("Do you really want to open all secret channels, giving everyone access to all information?", ctx.channel, self.open_all_channels(ctx), ctx.message) + + async def open_all_channels(self, ctx: commands.Context): + game = await self.get_running_game_or_error_message(ctx) + await self.check_in_admin_channel_or_error_message(ctx, game) + await self.check_is_administrator_or_gm(ctx) + await game.open_secret_channels() + await ctx.reply(":white_check_mark: All secret channels have been opened") + @commands.command("DeleteGame", help = "Delete a running game and all of its associated channels") async def delete_game_with_confirmation(self, ctx: commands.Context): await self.get_running_game_or_error_message(ctx)