From 042f90ec493e65673ab129deaa9ec65e91a6ab48 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Wed, 1 May 2024 13:55:51 +0530 Subject: [PATCH 1/5] Add missing `save()` function in `/customize profile_banner` --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index 12a3e8b..86a06e8 100644 --- a/main.py +++ b/main.py @@ -149,6 +149,7 @@ async def banner(ctx: ApplicationContext, image_url: str = None): if (image_url is not None) and ("https://" not in image_url): return await ctx.respond("Your custom banner url must contain `https://`!", ephemeral=True) profile_metadata[str(ctx.author.id)]["profile_banner_url"] = image_url + save() if image_url is None: localembed = discord.Embed(description=":white_check_mark: Your custom profile banner has been successfully removed.", color=discord.Color.green()) else: localembed = discord.Embed(description=":white_check_mark: Your custom profile banner has been successfully set! Check it out using `/profile`.", color=discord.Color.green()) return await ctx.respond(embed=localembed) From 3a5aa1fbc3a32e38b5df8429c81a250ba0f1fb6d Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Wed, 1 May 2024 13:56:29 +0530 Subject: [PATCH 2/5] Add custom profile description support to `/profile` --- main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 86a06e8..445b971 100644 --- a/main.py +++ b/main.py @@ -56,7 +56,10 @@ async def on_ready(): async def on_message(ctx): """Fired whenever someone sends a new rating in a server.""" if str(ctx.author.id) not in user_ratings: user_ratings[str(ctx.author.id)] = {} - if str(ctx.author.id) not in profile_metadata: profile_metadata[str(ctx.author.id)] = {"profile_banner_url": None} + if str(ctx.author.id) not in profile_metadata: profile_metadata[str(ctx.author.id)] = { + "profile_description": "", + "profile_banner_url": None + } save() # Slash Commands @@ -110,7 +113,7 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): if user == None: user = ctx.author localembed = discord.Embed( title=f"{user.display_name}'s profile", - description=f"{user.name}", + description=f"`AKA` {user.name}\n\n*{profile_metadata[str(user.id)]['profile_description']}*", color=discord.Color.random() # Removed user.accent_color from embed color because PyCord can't behave :( ) localembed.set_thumbnail(url=user.display_avatar) @@ -154,6 +157,19 @@ async def banner(ctx: ApplicationContext, image_url: str = None): else: localembed = discord.Embed(description=":white_check_mark: Your custom profile banner has been successfully set! Check it out using `/profile`.", color=discord.Color.green()) return await ctx.respond(embed=localembed) +@customization.command( + name="profile_description", + description="Set a custom description for your /profile command!" +) +@option(name="description", description="The text you want to set as your profile description.", type=str, default="") +async def profile_description(ctx: ApplicationContext, description: str = ""): + """Set a custom description for your /profile command!""" + profile_metadata[str(ctx.author.id)]["profile_description"] = description + save() + if description == "": localembed = discord.Embed(description=":white_check_mark: Your profile description has successfully been removed.", color=discord.Color.green()) + else: localembed = discord.Embed(description=":white_check_mark: Your profile description has been successfully set! Check it out using `/profile`.", color=discord.Color.green()) + await ctx.respond(embed=localembed) + # User Commands @client.user_command(name="View Profile") async def _profile(ctx: ApplicationContext, user: discord.User): From ef680dc287e442e0e162d1e76f36f56a206d06a5 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Wed, 1 May 2024 13:59:58 +0530 Subject: [PATCH 3/5] Add `launch.json` debug configuration --- .vscode/launch.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..983fa33 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Python Bot Client", + "type": "debugpy", + "request": "launch", + "program": "main.py", + "console": "integratedTerminal" + } + ] +} From 92e15b7335246ce36e42545246df4ffea73d8d34 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Wed, 1 May 2024 16:08:07 +0530 Subject: [PATCH 4/5] Fix `customize` slash command group not appearing in bot --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 445b971..c7109f4 100644 --- a/main.py +++ b/main.py @@ -140,7 +140,7 @@ async def rating(ctx: ApplicationContext, user: discord.User = None): await ctx.respond(embed=localembed) # User Profile Customization Commands -customization = client.slash_group("customize", "Commands used to customize the user's /profile command.") +customization = client.create_group("customize", "Commands used to customize the user's /profile command.") @customization.command( name="profile_banner", From 3fc2569ba45a5011ef4d302f1c442fb8e667b304 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Wed, 1 May 2024 16:09:02 +0530 Subject: [PATCH 5/5] Fix some formatting for blank descriptions --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c7109f4..e1d49db 100644 --- a/main.py +++ b/main.py @@ -111,10 +111,11 @@ async def rate(ctx: ApplicationContext, user: discord.User, rating: str): async def profile(ctx: ApplicationContext, user: discord.User = None): """View the profile of a user.""" if user == None: user = ctx.author + profile_desc = profile_metadata[str(user.id)]["profile_description"] localembed = discord.Embed( title=f"{user.display_name}'s profile", - description=f"`AKA` {user.name}\n\n*{profile_metadata[str(user.id)]['profile_description']}*", - color=discord.Color.random() # Removed user.accent_color from embed color because PyCord can't behave :( + description=f"`AKA` {user.name}\n\n{f'*{profile_desc}*' if profile_desc != '' else ''}", + color=discord.Color.random() ) localembed.set_thumbnail(url=user.display_avatar) localembed.add_field(name="Profile Picture URL", value=f"[Click to view]({user.display_avatar})")