From 3d66449db5291caedfdafaeeb73408498c33673a Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:10:13 +0530 Subject: [PATCH 1/6] Add AFK status to `/whoami` command --- main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.py b/main.py index b72ea83e..ff0ea3b0 100644 --- a/main.py +++ b/main.py @@ -874,6 +874,8 @@ async def whoami(ctx:SlashContext, user:discord.User=None): displayname = user.display_name registered = user.joined_at.strftime("%b %d, %Y, %T") pfp = user.avatar_url + localembed_desc = f"`AKA` {displayname}" + if str(user.id) in user_presence[str(ctx.guild.id)][str(user.id)]: localembed_desc.append(f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - ") localembed = discord.Embed( title=f'User Info on {username}', description=f'`AKA` {displayname}' From 52fe114735a1185ded39b4ca421906451fc3c626 Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:30:11 +0530 Subject: [PATCH 2/6] Fix `user_presence` db read target for AFK user status --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index ff0ea3b0..fbec75a9 100644 --- a/main.py +++ b/main.py @@ -875,7 +875,7 @@ async def whoami(ctx:SlashContext, user:discord.User=None): registered = user.joined_at.strftime("%b %d, %Y, %T") pfp = user.avatar_url localembed_desc = f"`AKA` {displayname}" - if str(user.id) in user_presence[str(ctx.guild.id)][str(user.id)]: localembed_desc.append(f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - ") + if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc.append(f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - ") localembed = discord.Embed( title=f'User Info on {username}', description=f'`AKA` {displayname}' From 463f201962966d19dc517a7c872e11b533e01c07 Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:33:46 +0530 Subject: [PATCH 3/6] Replace `discord.Embed.description` string with localembed_desc variable --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index fbec75a9..685770e2 100644 --- a/main.py +++ b/main.py @@ -878,7 +878,7 @@ async def whoami(ctx:SlashContext, user:discord.User=None): if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc.append(f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - ") localembed = discord.Embed( title=f'User Info on {username}', - description=f'`AKA` {displayname}' + description=localembed_desc ) localembed.set_thumbnail(url=pfp) localembed.add_field(name='Username', value=username, inline=False) From f246771239d94a46aace3b49f9884625e0624e40 Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:37:19 +0530 Subject: [PATCH 4/6] Replace `append()` method with `+=` This was changed because when debugging, I found out that append method couldn't be used with a string. This was the next best option. --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 685770e2..09389db1 100644 --- a/main.py +++ b/main.py @@ -875,7 +875,7 @@ async def whoami(ctx:SlashContext, user:discord.User=None): registered = user.joined_at.strftime("%b %d, %Y, %T") pfp = user.avatar_url localembed_desc = f"`AKA` {displayname}" - if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc.append(f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - ") + if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc += f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - " localembed = discord.Embed( title=f'User Info on {username}', description=localembed_desc From 0fcc798a6583bdb2463efce4aabe076baf1fbc65 Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:40:57 +0530 Subject: [PATCH 5/6] Replace Discord emoji name with raw emoji --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 09389db1..f7ed27bb 100644 --- a/main.py +++ b/main.py @@ -875,7 +875,7 @@ async def whoami(ctx:SlashContext, user:discord.User=None): registered = user.joined_at.strftime("%b %d, %Y, %T") pfp = user.avatar_url localembed_desc = f"`AKA` {displayname}" - if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc += f"\n`:crescent_moon: AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - " + if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc += f"\n`🌙 AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - " localembed = discord.Embed( title=f'User Info on {username}', description=localembed_desc From 1b3692c4a00eb92a36c4e935158bcd05bd38edde Mon Sep 17 00:00:00 2001 From: snipe_blaze <72265661+notsniped@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:45:49 +0530 Subject: [PATCH 6/6] Convert float to integer for timestamp display Turns out that Discord UNIX timestamps doesn't support fractions of a second. I ended up rounding this for support reasons, and that literally no one needs to know the timestamp in such precision. --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index f7ed27bb..9bc52098 100644 --- a/main.py +++ b/main.py @@ -875,7 +875,7 @@ async def whoami(ctx:SlashContext, user:discord.User=None): registered = user.joined_at.strftime("%b %d, %Y, %T") pfp = user.avatar_url localembed_desc = f"`AKA` {displayname}" - if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc += f"\n`🌙 AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - " + if str(user.id) in user_presence[str(ctx.guild.id)]: localembed_desc += f"\n`🌙 AFK` {user_presence[str(ctx.guild.id)][str(user.id)]['response']} - " localembed = discord.Embed( title=f'User Info on {username}', description=localembed_desc