Implement reboot
This commit is contained in:
parent
774fec0e32
commit
d41eb3fc4c
|
@ -5,5 +5,5 @@ __pycache__/
|
||||||
venv/
|
venv/
|
||||||
|
|
||||||
config.yml
|
config.yml
|
||||||
game.save
|
*.save
|
||||||
*.log
|
*.log
|
||||||
|
|
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue