From 799a02077effd1b6d524ff2aea0199afbcfbbfbf Mon Sep 17 00:00:00 2001 From: Connor Smith Date: Sat, 27 May 2023 19:27:46 +1000 Subject: [PATCH] Add debug info about new discord accounts to log message #105 --- dictator/cogs/user.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dictator/cogs/user.py b/dictator/cogs/user.py index 0883488..8ac1bec 100644 --- a/dictator/cogs/user.py +++ b/dictator/cogs/user.py @@ -9,6 +9,7 @@ import re import random from textwrap import wrap +from datetime import timedelta class User(commands.Cog): @@ -35,7 +36,7 @@ async def account(self, interaction: discord.Interaction) -> None: user = await self.search_user(interaction.user.id) if user is None: - await interaction.followup.send(f'{interaction.user.mention} You don\'t have an account, I\'m creating one for you now. I\'ll send you a message soon!', ephemeral=True) + await interaction.followup.send(f'{interaction.user.mention} You don\'t have an account, I\'m creating one for you now. I\'ll send you a message soon!', ephemeral=True) print( f'{interaction.user} attempted to retrieve their key but didn\'t have an account, we\'ll create them one.') await self.create_user(interaction.user) @@ -113,6 +114,11 @@ async def create_user(self, user: discord.User, username: str = None) -> None: else: notify_user = True + one_week_ago = discord.utils.utcnow() - timedelta(weeks=1) + new_discord_account = False + if user.created_at > one_week_ago: + new_discord_account = True + debug_log_channel = self.dictator.get_channel(DEBUG_CHANNEL_ID) # Embed log @@ -120,6 +126,7 @@ async def create_user(self, user: discord.User, username: str = None) -> None: embed.add_field(name='Member:', value=f'{user.mention}', inline=True) embed.add_field(name='Username:', value=f'{username}', inline=True) embed.add_field(name='User notification:', value='Successful' if notify_user else 'Failed', inline=True) + embed.add_field(name='User account age:', value='New discord account' if new_discord_account else 'Existing discord account', inline=True) await debug_log_channel.send(embed=embed) print(f'Successfully created an account for {user.name} using the username {username}.')