I want my twitch chat bot to respond to a specific user with a specific reply

Im building a twitch chat bot using nodejs and i am bit stuck. So i want the bot to reply with a specific message only if a specific user write something. i already set up some replies to basic stuff but i cannot figure out how to do it. so im guessing i need an if statement … if x says whatever - return this. but im not sure how to set it up to reply with the same thing no matter what that specific user does. ps. its my first time using nodejs or anything coding related.

thank you.

Sounds like you need to obtain the userID from the tags in a PRIVMSG and react accordingly.

If you are using a library, then the library should expose this.

or if you are libraryless parsing a PRIVMSG should spit it out something along the lines of message.tags['user-id']

Wihthout any code can only suggest where to look!

client.connect();

client.on('message', (channel, tags, message, self) => {
	if(self) return;
	if(message.toLowerCase() === 'hi') {
		client.say(channel, `@${tags.username} peepoHey`);
	}
});

with this command he must respond to a specific user

I am not sure what you are asking.

You code shows that if the message is hi you @ the user that wrote hi with the message @username peepoHey

This looks like TMI.js and based on your OP you want

client.on('message', (channel, tags, message, self) => {
	if(self) return;
        if(message.toLowerCase() === 'hi' && tags.username == 'somename') {
		client.say(channel, `@${tags.username} peepoHey`);
	}
});

I’d usually grab the user-id rather than username but it’s all in the tags

2 posts were split to a new topic: How to make threaded replies

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