I am creating some custom Nightbot commands used to answer frequently asked questions in chat.
Example command: !addcom !FAQ Here is the response to your question @$(touser)
I’d like to overload the command such that:
- you may type the command by itself and get a non-tagged response (ie !FAQ)
(reply from Nightbot would be:Here is the response to your question.
OR - you may type the command with a username to tag the response for the specified username (ie !FAQ Muhalo)
(reply from Nightbot would be:Here is the response to your question @Muhalo.
I understand the behavior of the $(touser) variable is to default to the command issuer if there is no parameter.
This is not ideal as it will appear the command issuer is somehow answering their own question.
I also know I cannot use $(1) or $(query) in this case, as they return undefined
and none
respectively.
Does there exist a variable that returns null if the parameter is not supplied?
Or, in this specific case, is there a way to suppress a chat tag variable if there is no parameter passed to it?
Thank you.