Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
26 changes: 22 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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})")
Expand All @@ -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",
Expand All @@ -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):
Expand Down