Implement reboot
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -5,5 +5,5 @@ __pycache__/
 | 
			
		||||
venv/
 | 
			
		||||
 | 
			
		||||
config.yml
 | 
			
		||||
game.save
 | 
			
		||||
*.save
 | 
			
		||||
*.log
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import os
 | 
			
		||||
from functools import partial
 | 
			
		||||
 | 
			
		||||
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}**).")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@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):
 | 
			
		||||
    @disnake.ui.button(label="S'allier", style=disnake.ButtonStyle.green)
 | 
			
		||||
    async def confirm(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user