Skip to content

Commit 60f5bbb

Browse files
fix: simplify trophy URL generation and enhance username extraction from arguments
1 parent 36223c1 commit 60f5bbb

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

bot_cmds.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,9 @@ async def trophy(self, ctx, trophy_arg: str = None):
839839
username = "QuantumChemist"
840840
else:
841841
# Parse trophy_arg for username, column, theme
842-
parts = trophy_arg.split()
843-
username = parts[0] if len(parts) > 0 else "QuantumChemist"
844-
column = parts[1] if len(parts) > 1 else "-1"
845-
theme = parts[2] if len(parts) > 2 else "discord"
846-
bg = parts[3] if len(parts) > 3 else "true"
847-
kwargs = ""
848-
if len(parts) > 4:
849-
for extra in parts[4:]:
850-
kwargs += f"&{extra}"
851-
trophy_url = f"http://localhost:8080/?username={username}&column={column}&theme={theme}&no-bg={bg}{kwargs}"
842+
trophy_url = f"http://localhost:8080/?{trophy_arg}"
843+
username_match = re.search(r"username=([^&]+)", trophy_arg)
844+
username = username_match.group(1) if username_match else "QuantumChemist"
852845
local_file = f"trophy_{username}.svg"
853846

854847
response = requests.get(trophy_url)

0 commit comments

Comments
 (0)