From b9393a87e0a6bcc9d9fbd2763f1b3066dd05bf7e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 7 Jun 2021 21:58:34 +0200 Subject: [PATCH] replace deprecated method --- src/cogs/citation.py | 16 ++++++---------- src/utils/time.py | 7 ------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/cogs/citation.py b/src/cogs/citation.py index 2eb8732..aeb0cdc 100644 --- a/src/cogs/citation.py +++ b/src/cogs/citation.py @@ -4,7 +4,7 @@ import os from discord.ext import commands customTimezone = os.environ['TIMEZONE'] from utils.core import userOrNick -from utils.time import goodTimezone +from utils.time import timestampScreen def setup(client): client.add_cog(Citation(client)) @@ -73,18 +73,14 @@ class Citation(commands.Cog): embed.set_author(name = "Citation", icon_url = msgID.author.avatar_url) icon_url = message.author.avatar_url - date_1 = goodTimezone(msgID.created_at, customTimezone) - edit = "" if msgID.edited_at: - 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, customTimezone) - date_2 = f"{date_2[0][8:]}/{date_2[0][5:-3]}/{date_2[0][:4]} à {date_2[1]}" + edit = f" et modifié le {timestampScreen(msgID.edited_at)}" + else: + edit = "" + messageDuBas = f"Posté le {timestampScreen(msgID.created_at)}{edit}" if auteur == "Auteur": - messageDuBas = messageDuBas + f"\nCité par {userOrNick(message.author)} le {date_2}" + messageDuBas = messageDuBas + f"\nCité par {userOrNick(message.author)} le {timestampScreen(message.created_at)}" embed.set_footer(icon_url = icon_url, text = messageDuBas) if message.content == linkURL.replace(' ',''): await message.channel.send(embed = embed) diff --git a/src/utils/time.py b/src/utils/time.py index 341e7bb..10950f6 100644 --- a/src/utils/time.py +++ b/src/utils/time.py @@ -105,10 +105,3 @@ def ageLayout(tuple): for i in affichage: message = message + f", {tuple[i]} {time[i]}" return message[2:] - -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() - elif type == 1: - return str(timezone(tz).fromutc(date))[:-13].replace('-', '/').replace(' ', ' à ')