goodtimezone better args

This commit is contained in:
Mylloon 2021-06-06 23:46:41 +02:00
parent 5cd3ef088d
commit c249ece3a5
3 changed files with 10 additions and 6 deletions

View file

@ -96,9 +96,9 @@ class ConfrerieDuKassoulait(commands.Cog):
embed.set_author(name = userOrNick(message.author), icon_url = message.author.avatar_url)
if not user_suppressed:
embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1, customTimezone)}\nSupprimé le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}")
embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, customTimezone, 1)}\nSupprimé le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}")
else:
embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1, customTimezone)}\nSupprimé par {userOrNick(user_suppressed)} le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}")
embed.set_footer(icon_url = user_suppressed.avatar_url, text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, customTimezone, 1)}\nSupprimé par {userOrNick(user_suppressed)} le {datetime.now(timezone(customTimezone)).strftime('%d/%m/%Y à %H:%M:%S')}")
await channel.send(embed = embed)
# ne fonctionne pas quand un message a été supprimé avant que le bot ai démarré

View file

@ -110,14 +110,14 @@ async def on_message(message):
embed.set_author(name = "Citation", icon_url = msgID.author.avatar_url)
icon_url = message.author.avatar_url
date_1 = goodTimezone(msgID.created_at, 0, customTimezone)
date_1 = goodTimezone(msgID.created_at, customTimezone)
edit = ""
if msgID.edited_at:
date_edit = goodTimezone(msgID.edited_at, 0, customTimezone)
date_edit = goodTimezone(msgID.edited_at, customTimezone)
edit = f" et modifié le {date_edit[0][8:]}/{date_edit[0][5:-3]}/{date_edit[0][:4]} à {date_edit[1]}"
messageDuBas = f"Posté le {date_1[0][8:]}/{date_1[0][5:-3]}/{date_1[0][:4]} à {date_1[1]}{edit}"
date_2 = goodTimezone(message.created_at, 0, customTimezone)
date_2 = goodTimezone(message.created_at, customTimezone)
date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}"
if auteur == "Auteur":

View file

@ -8,7 +8,7 @@ from datetime import datetime, timedelta
myTimezone = os.environ['TIMEZONE']
def goodTimezone(date, type, tz):
def goodTimezone(date, tz, type = 0):
"""renvoie une date en fonction d'un timezone"""
if type == 0:
return str(timezone(tz).fromutc(date))[:-13].replace('-', '/').split()
@ -204,3 +204,7 @@ def timedeltaToString(time):
age[2] = f"{age[2]}m " if a[2] == 1 else ''
age[3] = f"{age[3]}s" if a[3] == 1 else ''
return ''.join(age)
def timestampFR(timestamp):
date_edit = str(timestamp).replace('-', '/').split(' ')
return f"{date_edit[0][8:]}/{date_edit[0][5:-3]}/{date_edit[0][:4]} à {date_edit[1]}"