ToUser command calling the same user

Asked Nov 30, 2023·1 reply·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

The ToUser more info is very confusing because it says the same thing twice and nothing more.
"$(touser)
would result in
nightdev
if the first argument after the command was nightdev"
As if that's informative enough it then also used the same explanation if no argument is given after the command.
I'd really like to know specifically what the variable looks like in the use of a command.
Can I somehow use ToUser to just have the user in the command so that anytime we run the command it recalls the same user without having to add it to the end while writing it in chat?

1 reply

Defined in the Docs, $(touser) with an argument in the command will be that argument, for example,

Aaron128l: !commands add !test $(touser)
Aaron128l: !test apple123
Nightbot: apple123

If there is no argument after the command $(touser) will be the username of the executor of the command.

Aaron128l: !commands add !test $(touser)
Aaron128l: !test
Nightbot: Aaron128l
Can I somehow use ToUser to just have the user in the command so that anytime we run the command it recalls the same user without having to add it to the end while writing it in chat?

If you always want the command to say the same thing I'd recommend removing the $(touser) variable. Custom variables allow dynamic commands that can change depending on the arguments and are not required.