Custom Greeting

Asked Jan 30, 2023·8 replies·Last activity 3 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.

Hi folks,

I am trying to make nightbot respond to good morning, good afternoon, good evening and good night.

Would the following work:

$(eval if ($(querystring $(1)).toLowerCase().includes(morning)) {Response😄 Good morning $(user)!`} else if ($(querystring $(1)).toLowerCase().includes(afternoon)) {Response😄 Good afternoon $(user)!} else if ($(querystring $(1)).toLowerCase().includes(evening)) {Response😄 Good evening $(user)!} else if ($(querystring $(1)).toLowerCase().includes(night)) {Response😄 sweet dreams $(user)!`}

Also, I exceed the character limit using the web interface so should I use !addcom for this?

Thanks for your help!

8 replies

I got the following to work due to youtube's character limit:

$(eval $(querystring $(1)).toLowerCase().includes(morning)querystring $(1)).toLowerCase().includes(afternoon`)querystring $(1)).toLowerCase().includes(evening)?:smile: Hey $(user)!: `)

Hey @Calm Ox!

Very happy you got it to work, however, allow me to show you a more compact way to do it:

!addcom good $(eval q = `$(1)`.toLowerCase().replace(/[^a-z]/g, ''); q === 'night' ? '😄 sweet dreams $(user)!' : ['morning', 'afternoon', 'evening'].includes(q) ? `😄 good ${q} $(user)!` : ' ';)

Really appreciate your help! I will give this a try.

This doesn't work unfortunately.

Nightbot just gives a blank output.

This is my bad, I misplaced a character in my code: /^[a-z]/ instead of /[^a-z]/... 😅
I fixed the code above, it should work as expected now.

However, you shouldn't get empty responses when the message doesn't match any valid inputs, I suspect this might be a difference between Twitch and YouTube: Twitch doesn't accept empty messages (made of only spaces), maybe YouTube does when it comes from their API?

I suggest testing the command as is with a sentence like "good game."
If Nightbot responds with an empty message you can try removing the space between the last two single quote marks: ' ';)'';)
And although it usually produces error, I hope it'll work because there's no other solution.

Quick question, did you have to remove the space or not?

I did not as removing it gave an error on YouTube.

Didn't find your answer? The community is on Discord.

Ask on Discord