Specific user message command

Asked Mar 5, 2023·10 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.

Hello

I need to know if it's possible to have a !hello command which displays a specific message to a specific user and a normal message to everybody else. The specific people are around 15 and I'd like them to have a specific message for each.

I've seen this code which gets close to what I need

$(eval List=[User1,User2,UserX…];List.includes($(user).toLowerCase())?Response: )

but I don't know how to add more responses and make each of these responses specifically for a specific person

10 replies

Hi. I saw it.

Do I need to create a paste bin? or can I just use that code? how can I add more users to the list?

Hasty Bat said:
Do I need to create a paste bin?

Yes, create an account on Pastebin, and create a public or unlisted paste with the code I said should go in it, it'll be useful to come back and add more people to your command.

Hasty Bat said:
how can I add more users to the list?

As shown by the code example I wrote, you simply add another case.
Let's say you have this:

javascript
switch (u) {
case 'Clauwasaki':
'CLAUWASAKI_MESSAGE';
break;
case 'Nightbot':
'NIGHTBOT_MESSAGE';
break;
default:
'DEFAULT_MESSAGE';
}

...and you want to add a user named Twitch:

javascript
switch (u) {
case 'Clauwasaki':
'CLAUWASAKI_MESSAGE';
break;
case 'Nightbot':
'NIGHTBOT_MESSAGE';
break;
case 'Twitch':
'TWITCH_MESSAGE';
break;
default:
'DEFAULT_MESSAGE';
}

Hi Emily

it's giving me a hard time lol. Sorry

Could you give me some specific info on what to paste in pastebin? I don't know what to edit

No worries, I'll help you kickstart your file; can you give me the default message(s), and the user-specific messages you already thought of (along with their usernames)?

Hello

The default message will be "Welcome"
The specific message I haven't figured out yet but let's say

user1 message1
user2 message2
user3 message3

and so on. I think I'll have to make around 15 of these but with 1 example or 2 I can do the rest

Okay, so this is the command:

$(eval u = '$(user)'; $(urlfetch json https://pastebin.com/raw/XXXXXXXX))

Replace XXXXXXXX with your paste id, you'll see it in the URL once you save it for the first time.

And in your paste, put the following code:

javascript
switch (u) {
case 'user1':
'message1';
break;
case 'user2':
'message2';
break;
case 'user3':
'message3';
break;
default:
'Welcome';
}

Each username need to match the case of the username on Twitch, and if your message contains apostrophes you'll need to escape them with a backslash (\):
Let's imagine your username was typed clauWasaki to illustrate different casing...

javascript
case 'clauWasaki':
'it\'s a sunny day';
break;

it works perfectly, case sensitive by the way. So if I wanted to add more, I just copy from here?

case 'user4':
'message4';
break;
case 'user5':
'message5';
break;

etc? and edit the pastebin code of course

Yup, exactly like this, you got it! Leave the default case to the bottom.

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

Ask on Discord