From df0ebbb4ad182896f95cadae96922cc01ce39fc2 Mon Sep 17 00:00:00 2001 From: GZod01 Date: Sun, 15 Dec 2024 15:15:27 +0100 Subject: [PATCH] Ajout de l'encodage d'image en base64 pour les commandes de personnage --- perso_commands.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/perso_commands.py b/perso_commands.py index b2b6367..e00c969 100644 --- a/perso_commands.py +++ b/perso_commands.py @@ -2,6 +2,9 @@ from discord import app_commands import discord from GammaRPBot_Define import GammaRPBot import aiosqlite +import base64 + + async def setup(bot:GammaRPBot): bot.tree.add_command(PersoCommands(bot)) class PersoCommands(app_commands.Group): @@ -25,7 +28,10 @@ class PersoCommands(app_commands.Group): pouvoirs = powers uuid=interaction.user.id guild_id = interaction.guild.id - image_blob=await image.read() + image_blob_raw=await image.read() + image_blob_b64 = base64.b64encode(image_blob_raw).decode("utf-8") + ext = image.filename.split(".")[-1] + image_blob=f"data:image/{ext};base64,{image_blob_b64}" print(nom_court,nom_complet,histoire,pouvoirs,age,sexe,uuid,guild_id) print(image.filename) print(image.url)