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

I try to create a command that when the “Hi” Emote is used from one in the chat, that Nightbot response with the same “Hi” Emote.
Right now is the command: “Hi Emote” $(user)

the problem is when someone use this emote with a name behind it triggers too.
So i try to find a way that it triggers only when the Emote only is written from a Person or the Emote + @mytwitchname
If someone uses the Emote + Text or a other @twitchname then it should not trigger

I thought this should work with if and else or I’m on the wrong way?

can you show how the command looks like and what output you want?

right now the command is only “Hi Emote” $(user)

In Chat Nightbot would write the “Hi Emote” + “username”

but the problem is that it triggers always as I wrote above

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

I had no code for this command because this worked "Emote” $(user) and I thought that is enough for this command but then I saw in the chat that Nightbot triggers always when the “Emote” comes in the chat and that was the problem.

I tried now your code example:
$(eval ‘$(query)’ === ‘HiEmote’ ? ‘HiEmote’ : ’ ':wink:

or have I understood the code now wrong?

Oooh, wait, I think I got it, the command you’re trying to create has for name an emote, which is a greeting emote, “hi” is how you qualify the emote, not the message you wish Nightbot to reply to. Now everything makes sense!

Then this is quite different if you want the bot to reply only when the message content is the emote by itself:

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

Would have been less confusing if you just said it was an emote, without quotes, and didn’t qualify it. :sweat_smile:
I edited the title of the topic which now gives a clear picture, as it should be.

1 Like

I think i need to learn more coding to know what I can write so other know what i mean ^^

Thanks for your help the command works fine =)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.