Queries in an editing command

So i want to be able to add a second $(query) to a command based on a query… so i have

!addcom !leaderboard Current Leaderboard :
!addcom !setleaderboard -a=!commands edit !leaderboard Current Leaderboard: $(query)

And that works fine but i’d like to see if i could add a query to the !leaderboard command without having to add it to the !setleaderboard command. The variables $(1) and $(2) could be used in the “set” command however id like to be able to check anyone’s status in the posted leaderboard link without having it be preset. Is there any work around to this?

Hey @kanarenee!

Yes, there’s a workaround, it’s to use a Pastebin.

So for example you want your !leaderboard command’s response to be:

Current leaderboard: blablabla $(query)

Then you should set up your !setleaderboard command like so:

!addcom !setleaderboard -a=!commands edit !leaderboard Current Leaderboard: $(query) $(urlfetch https://pastebin.com/raw/XXXXXXXX)

Don’t forget to replace XXXXXXXX with your paste ID.

And in your unlisted never-expiring paste, simply write: $(query)

1 Like

In general if we want an alias of !editcom to edit a command to have a variable $(varname) in its response, we can output it by eval to stop Nightbot from parsing it.

$(eval `$`+`(varname)`)

If we want !setleaderboard to have $(query) in its response we can do

!addcom !setleaderboard -a=!editcom !leaderboard Current Leaderboard: $(eval `$`+`(query)`)
1 Like

Thank you so much, I dont know why this work around never occured to me but i did figure out how to make it work with this!

This format didnt quite end up working the way i needed it to but thank you nonetheless! This particular format should help in different commands if i try to modify them! It also helped me remember that !editcom works as the full alias command rather than the -a=!commands edit

Oh right, I forgot we could do it this way… I’m so used to needing more than just a $(query), in which case a Pastebin makes more sense. Thank you for the reminder.

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