Added StopGame command to reveal all secret channels

This commit is contained in:
Elnath 2021-07-06 10:38:08 +02:00
parent ccda132bf5
commit 54a4e6cade
2 changed files with 30 additions and 0 deletions

View File

@ -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):

View File

@ -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)