I’m writing a command that updates a command, and I want the updated command to include $(user).
!commands add !com1 -a=!commands edit !com2 $(user) some message
Unfortunately, $(user) is being replaced when I add !com1 not when someone types !com2. Is there a way to escape the variable so that it’s applied when the second command is used?
I mod for Failstream and regularly troll him and chat with updated titles. Recently he’s been playing SMM2 levels made by other streamers, and inevitably randos pop in and type !add <level code> just assuming he’s playing viewer levels.
Because it amuses me, I’ve been updating his title to
Viewer levels, where the viewer is exclusively <current streamer>
and updating the !add command to
$(user) is your name <current streamer>?
Since the format is the same every time and Fail plays 5-10 levels per stream, I didn’t want to type out the whole !editcom command every time, so I added two helper commands:
!addcom !vlt -a=!title Viewer levels, where the viewer is exclusively $(query)
!addcom !vla -a=!commands edit !add $(user) is your name $(query)?
Now when Fail starts a new level, I just type
!vlt <current streamer>
!vla <current streamer>
!vlt works as expected. !vla always inserts my username rather than that of the person who types !add.
I just thought of a convoluted way I could do it.
!addcom !vla -a=!commands edit !add $(eval '$' + '(user)') is your name $(query)?
Still, I’d be interested to know if there’s a better way to escape things.
That’s pretty much the only way to inject variables, using other variables to output those variables, eval being the easiest one to use; a bit janky but it does the job. Nice one for figuring that out.