diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 673e41e..52608b8 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -13,6 +13,7 @@ class Utils(commands.Cog): def __init__(self, client): self.client = client + self.customTimezone = os.environ['TIMEZONE'] @commands.command(name='ping') @@ -143,7 +144,7 @@ class Utils(commands.Cog): await ctx.message.delete() embed = discord.Embed(description = text, color = discord.Colour.random()) embed.set_author(name = f"Mémo noté depuis {ctx.guild.name}", icon_url = ctx.author.avatar_url) - embed.set_footer(text = f'📝 le {datetime.now(pytz.timezone("Europe/Paris")).strftime("%d/%m/%Y à %H:%M:%S")}') + embed.set_footer(text = f'📝 le {datetime.now(pytz.timezone(self.customTimezone)).strftime("%d/%m/%Y à %H:%M:%S")}') await ctx.author.send(embed = embed) return await ctx.send("Tu viens de recevoir ton mémo !", delete_after = 5) @_memo.error @@ -246,14 +247,14 @@ class Utils(commands.Cog): embed.add_field(name = "ID", value = user[0].id) - value = str(user[0].created_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + value = str(user[0].created_at.astimezone(timezone(self.customTimezone)))[:-13].replace('-', '/').split() embed.add_field(name = "Compte créé le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Âge du compte", value = self._ageLayout(self._get_age(user[0].created_at))) embed.add_field(name = "Mention", value = user[0].mention) - value = str(user[0].joined_at.astimezone(timezone(os.environ['TIMEZONE'])))[:-13].replace('-', '/').split() + value = str(user[0].joined_at.astimezone(timezone(self.customTimezone)))[:-13].replace('-', '/').split() embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Est sur le serveur depuis", value = self._ageLayout(self._get_age(user[0].joined_at))) diff --git a/src/main.py b/src/main.py index 45b0c5a..28d5cc0 100644 --- a/src/main.py +++ b/src/main.py @@ -6,6 +6,7 @@ from random import choice from datetime import datetime from pytz import timezone customPrefix = os.environ['PREFIX'] +customTimezone = os.environ['TIMEZONE'] client = commands.Bot(command_prefix = customPrefix, case_insensitive = True, intents = discord.Intents.all()) @@ -197,9 +198,9 @@ async def on_message_delete(message): embed.set_author(name = user_or_nick(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)}\nSupprimé le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).strftime('%d/%m/%Y à %H:%M:%S')}") + embed.set_footer(text = f"Channel: #{message.channel.name} | Date : {goodTimezone(message.created_at, 1)}\nSupprimé le {datetime.now(pytz.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)}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.timezone(os.environ['TIMEZONE'])).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, 1)}\nSupprimé par {user_or_nick(user_suppressed)} le {datetime.now(pytz.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é @@ -213,8 +214,8 @@ def user_or_nick(user): def goodTimezone(date, type): if type == 0: - return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').split() + return str(pytz.timezone(customTimezone).fromutc(date))[:-13].replace('-', '/').split() elif type == 1: - return str(pytz.timezone(os.environ['TIMEZONE']).fromutc(date))[:-13].replace('-', '/').replace(' ', ' à ') + return str(pytz.timezone(customTimezone).fromutc(date))[:-13].replace('-', '/').replace(' ', ' à ') client.run(os.environ['TOKEN_DISCORD'])