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" + } + ] +} diff --git a/main.py b/main.py index 12a3e8b..e1d49db 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 @@ -108,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"{user.name}", - 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})") @@ -137,7 +141,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", @@ -149,10 +153,24 @@ 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) +@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):