Suppression des messages de débogage dans la fonction say_message pour un code plus propre
This commit is contained in:
parent
b45d99ff84
commit
4f02b4c342
1 changed files with 12 additions and 11 deletions
23
main-bot.py
23
main-bot.py
|
@ -51,33 +51,34 @@ async def say(interaction:discord.Interaction,id:str,message:str):
|
||||||
|
|
||||||
|
|
||||||
async def say_message(userid:int, guildid:int, shortname:str, message:str,channel:discord.TextChannel):
|
async def say_message(userid:int, guildid:int, shortname:str, message:str,channel:discord.TextChannel):
|
||||||
print("HELLOWORODL")
|
# print("HELLOWORODL")
|
||||||
print(userid,guildid,shortname,message,channel)
|
# print(userid,guildid,shortname,message,channel)
|
||||||
res = await bot.db.execute("SELECT * FROM personnages WHERE uuid=? AND (guild_id=? OR guild_id IS NULL) AND nom_court=?",(userid,guildid,shortname))
|
res = await bot.db.execute("SELECT * FROM personnages WHERE uuid=? AND (guild_id=? OR guild_id IS NULL) AND nom_court=?",(userid,guildid,shortname))
|
||||||
row = await res.fetchone()
|
row = await res.fetchone()
|
||||||
await res.close()
|
await res.close()
|
||||||
if row is None:
|
if row is None:
|
||||||
return False
|
return False
|
||||||
print("ok")
|
# print("ok")
|
||||||
short_name = row["nom_court"]
|
short_name = row["nom_court"]
|
||||||
full_name = row["nom_complet"]
|
full_name = row["nom_complet"]
|
||||||
perso_image = row["image"] #data:image/png;base64,xxxxxx
|
perso_image = row["image"] #data:image/png;base64,xxxxxx
|
||||||
perso_image_b64=perso_image.split(",")[1]
|
perso_image_b64=perso_image.split(",")[1]
|
||||||
perso_image_raw = base64.b64decode(perso_image_b64)
|
perso_image_raw = base64.b64decode(perso_image_b64)
|
||||||
print(short_name,full_name,perso_image)
|
print(perso_image_raw)
|
||||||
|
# print(short_name,full_name,perso_image)
|
||||||
webhook = None
|
webhook = None
|
||||||
print("ok2")
|
# print("ok2")
|
||||||
if discord.utils.get(await channel.webhooks(),name=short_name) is None:
|
if discord.utils.get(await channel.webhooks(),name=short_name) is None:
|
||||||
print("ok3");
|
# print("ok3");
|
||||||
webhook = await channel.create_webhook(name=short_name,avatar=perso_image_raw)
|
webhook = await channel.create_webhook(name=short_name,avatar=perso_image_raw)
|
||||||
print("ok4")
|
# print("ok4")
|
||||||
else:
|
else:
|
||||||
print("ok5")
|
# print("ok5")
|
||||||
webhook = discord.utils.get(await channel.webhooks(),name=short_name)
|
webhook = discord.utils.get(await channel.webhooks(),name=short_name)
|
||||||
print("ok6")
|
# print("ok6")
|
||||||
print("ok7")
|
# print("ok7")
|
||||||
await webhook.send(message,username=full_name)
|
await webhook.send(message,username=full_name)
|
||||||
print("ok8")
|
# print("ok8")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
bot.run(bot_token)
|
bot.run(bot_token)
|
Loading…
Reference in a new issue