Responding to an emote only when there's nothing after it

Hey @WolbaTV!

If I understand properly, your issue is that you want your command to answer only when the chatter sends the following message:

Hi 😉

(the emoji is a placeholder)
and yet Nightbot also answers when the chatter sends:

Hi 😉 otherChatter

and that’s the issue, have I got that correctly?

That’s likely because you’re using .includes() in your code (that’s what I assume since that’s how we build the commands with spaces in their name; I can only assume because you haven’t provided the code, @Bigyan_subba asked you to, but it wasn’t a clear request), while here what you want is a strict match.

So with that in mind, that’s how you set up such command with strict match:

!addcom FIRST_WORD $(eval '$(query)'.toLowerCase() === 'REST_OF_THE_SENTENCE_IN_LOWER_CASE' ? 'YOUR_RESPONSE' : ' ';)

Specific to your case:

!addcom hi $(eval '$(query)' === 'EMOTE_CODE' ? 'YOUR_RESPONSE' : ' ';)

We can remove the .toLowerCase() since an emote code is strict in its syntax and will consistently be the same.

1 Like