Printing a URL with 2 Queries and 2 defaults

Hi all, I am newb at this stuff.

I’m trying to create a lookup command for players to type in twitch chat that will spit out a link to their game/match history on OP.GG.

The command would use 2 arguments/queries (in-game-name and server) and then the link will be the output. These are the same inputs needed for the League of Legends commands.
If no queries are entered, then I’d like the output to use the user’s name (twitch user name) and NA (server).

I have found similar topics, but none involving 2 queries which could default to something else.
This is what I have so far:

https://$(eval $(query)||na)$(eval $(query)||$(user))

WITHOUT query entries, the result is perfect:
MajinSona: !opgg

WITH query entries, the result is scuffed but the link still works LMAO:
MajinSona: !opgg majinsona na
ALSO scuffed with only one query entry and the link does not work:
MajinSona: !opgg majinsona
I’ve also tried using $(2) for the SERVER and $(1) for the IN-GAME-NAME for arguments which replace $(query). But when no query in entered, “null” is printed on the link. Query entries work fine.
MajinSona: !opgg
Anyways, this is where I’m at and any help is appreciated. Thanks!

Hey @MajinSona!

Here’s a solution:

$(eval q=[]; if(`$(query)`){q=decodeURIComponent(`$(querystring)`).toLowerCase().split(` `);} q[0]==`help`?`!opgg <in-game username if different than Twitch username, required if <server> is used> <server if different than NA>`:q.length==0?`$(user)`:q.length==1?`${q}`:q.length==2?`https://${q[1]}${q[0]}`:`Please enter no more than two arguments, for help type: !opgg help`;)

Here are the possible uses:
!opgg → gives a link with the Twitch username on NA server
!opgg USERNAME → gives a link with in-game username on NA server
!opgg USERNAME SERVER → gives a link with in game username on a different server than NA
!opgg help → gives a help guide

OMG @Emily you’re amazing! Wow… I definitely couldn’t do this myself. Everything works excellently 10/10 :+1: Thank you sooo much~! <3

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.