Implemented player killing

This commit is contained in:
Elnath 2021-06-13 20:20:49 +02:00
parent cc4990093e
commit d06954b1a3
2 changed files with 24 additions and 0 deletions

View File

@ -461,3 +461,13 @@ class Game:
" ".join([Policy.FASCIST.square_emoji()] * enacted_count[Policy.FASCIST] + [":black_small_square:"] * (6 - enacted_count[Policy.FASCIST])),
]
await self.get_announcements_channel().send("\n".join(message_content), allowed_mentions = discord.AllowedMentions(roles = True))
@game_started
@save_on_success
async def kill_player(self, player: discord.Member):
if player.id not in self.get_players_id():
raise ValueError(f"Trying to kill a player ({player.name}) which is not in the game")
self.config["players"].remove(player.id)
await player.remove_roles(self.get_player_role())
await self.get_announcements_channel().send(f":skull: <@{player.id}> has been killed! :skull:", allowed_mentions = discord.AllowedMentions(users = True))
await self.get_player_channel(player).send("u ded lol")

View File

@ -289,6 +289,20 @@ class SecretBot(commands.Cog):
]
await ctx.reply("\n".join(message_content))
@commands.command("Kill", help = "Kill a player and remove them from the game")
async def kill_player_with_confirmation(self, ctx: commands.Context, player: discord.Member):
game = await self.get_running_game_or_error_message(ctx)
await self.check_is_administrator_or_gm(ctx)
if player.id in game.get_players_id():
await self.confirm_action(f"Do you really want to kill <@{player.id}>? This will completely remove them from the game", ctx.channel, self.kill_player(ctx, player), ctx.message)
else:
await ctx.reply(f":x: <@{player.id}> is not in the game", allowed_mentions = discord.AllowedMentions.none())
async def kill_player(self, ctx: commands.Context, player: discord.Member):
game = await self.get_running_game_or_error_message(ctx)
await game.kill_player(player)
await ctx.reply(":dagger: The order has been executed.")
if __name__ == '__main__':
argparser = argparse.ArgumentParser(description = "Secret Hitler helper bot", formatter_class = argparse.ArgumentDefaultsHelpFormatter)