Save&load different files

This commit is contained in:
Yohann D'ANELLO 2021-11-09 00:55:15 +01:00
parent d41eb3fc4c
commit 9c041387d1
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 4 deletions

View File

@ -187,15 +187,17 @@ async def on_ready():
@bot.command(help="Sauvegarde la partie")
@commands.has_permissions(administrator=True)
async def save(ctx: commands.Context):
Game.INSTANCE.save('game.save')
async def save(ctx: commands.Context, filename: str = 'game.save'):
Game.INSTANCE.save(filename)
await ctx.reply("La partie a été sauvegardée.")
@bot.command(help="Recharger la partie")
@commands.has_permissions(administrator=True)
async def load(ctx: commands.Context):
Game.load('game.save')
async def load(ctx: commands.Context, filename: str = 'game.save'):
game = Game.load(filename)
if not game:
return await ctx.reply("Une erreur est survenue : le fichier n'existe pas ?")
await ctx.reply("La partie a été rechargée.")