From 9c041387d1a98a9044034b2300ae1229094b861b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 9 Nov 2021 00:55:15 +0100 Subject: [PATCH] Save&load different files --- orochi/bot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/orochi/bot.py b/orochi/bot.py index 1d0cd2f..2e45151 100644 --- a/orochi/bot.py +++ b/orochi/bot.py @@ -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.")