Implement reboot

This commit is contained in:
Yohann D'ANELLO 2021-11-09 00:47:49 +01:00
parent 774fec0e32
commit d41eb3fc4c
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 21 additions and 1 deletions

2
.gitignore vendored
View File

@ -5,5 +5,5 @@ __pycache__/
venv/ venv/
config.yml config.yml
game.save *.save
*.log *.log

View File

@ -1,3 +1,4 @@
import os
from functools import partial from functools import partial
import disnake import disnake
@ -392,6 +393,25 @@ async def cheat(ctx: commands.Context, player_name: str, vote: Vote | None):
await ctx.reply(f"Le vote de **{current_player.name}** a bien été falsifié (nouveau vote : *{vote}**).") await ctx.reply(f"Le vote de **{current_player.name}** a bien été falsifié (nouveau vote : *{vote}**).")
@bot.command(help="Reboot")
@commands.has_permissions(administrator=True)
async def reboot(ctx: commands.Context):
game: Game = Game.INSTANCE
for player in game.players.values():
channel = bot.get_channel(player.private_channel_id)
await channel.send("REB0OT.")
os.rename('game.save', 'game-prereboot.save')
game = Game()
for player in bot.config.PLAYERS:
game.register_player(player, bot.config.vote_channels[player.lower()])
game.rounds.append(game.default_first_round())
game.save('game.save')
await ctx.reply("REB0OT.")
class VoteView(disnake.ui.View): class VoteView(disnake.ui.View):
@disnake.ui.button(label="S'allier", style=disnake.ButtonStyle.green) @disnake.ui.button(label="S'allier", style=disnake.ButtonStyle.green)
async def confirm(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction): async def confirm(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):