Context
In a racing game, you have to complete three laps. I have a !laps command which takes as arguments the times for both lap 1 and lap 2 and gives the time for lap 3 needed to beat the world record (actually this is more complicated than that but it is not relevant for explaining what I am trying to do).
For instance :
!laps 33.6 33.2
Needs a 33.1 lap 3 to improve WR.
NB : In the real version of this command, there are not always two arguments.
If the streamer changes track, he needs to update the WR time.
If the world record time was hardcoded in the laps command, changing its value in the middle of 500 characters of tightly packed javascript code would be annoying (the streamer knows nothing about computer programming, so if he messes up a semicolon for instance, he will not be able to fix it).
Current solution
I’m using a back-end command !__laps_ which takes 3 arguments : first the world record time, then the lap 1 time and the lap 2 time. Then I define the !laps command as an alias.
!addcom !laps -a=!__laps_ wrTime $(query)
The world record time is still hardcoded but this is much nicer to edit.
What I am trying to do
I am trying to make a !setwrtime command which modifies the world record time. This will be more convenient than editing by hand the !laps command. Besides any moderator will be abble to change the world record time (no need to know how !laps works).
My best guess (potatoeaterlove’s solution)
!addcom !setwrtime -ul=moderator -a=!editcom !laps $(1) $(query)
However when I call !laps 1000 for instance, $(query) gets replaced as well.
Minimal working example
NB : I modify the user level for !__laps_ afterwards in order to save characters.
!addcom !__laps_ $(eval $(1) - $(2) - $(3))
!editcom !__laps_ -ul=moderator
!addcom !laps -a=!__laps_ 144.863 $(query)
# does not work
!addcom !setwrtime -ul=moderator -a=!editcom !laps $(1) $(query)
Solution (thanks potatoeaterlove)
!addcom !setwrtime -ul=moderator -a=!editcom !laps $(1) $(eval String.fromCharCode(36,40,113,117,101,114,121,41))
!addcom !laps -a=!__laps_
!addcom !__laps_ -ul=moderator $(eval $(1)-$(2)-$(3))
!setwrtime 1000