Skip to content

Commit

Permalink
Add debug info about new discord accounts to log message #105
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhsm committed May 27, 2023
1 parent d907140 commit 799a020
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dictator/cogs/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import random
from textwrap import wrap
from datetime import timedelta

class User(commands.Cog):

Expand All @@ -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)
Expand Down Expand Up @@ -113,13 +114,19 @@ 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
embed = discord.Embed(title='New game account created', colour=discord.Colour.green())
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}.')
Expand Down

0 comments on commit 799a020

Please sign in to comment.