Reputation: 35
I am trying to make it so I can register the second part of this in my twitch bot : !test [var]. Basically if they say !test @jeff it could say hello @jeff.
I am using tmi
client.on('chat', function(channel, user, message, self) {
if(message === "!twitter") {
client.action("kong_plays", user['display-name'] + " my twitter is x !");
}
if(message === "!youtube") {
client.action("kong_plays", user['display-name'] + " my youtube is x !");
}
if(message === "!discord") {
client.action("kong_plays", user['display-name'] + " you can join my discord with the link : https://discord.gg/GdbZea !");
}
if(message === "!sub") {
client.action("kong_plays", user['display-name'] + " It helps me out if you can sub. Also you receive access to exclusive perks such as: Sub Games, Sub only emotes, Sub Only Discord. Sub here x !");
}
if(message === "!tip") {
client.action("kong_plays", user['display-name'] + " Tipping helps me out a ton whether it be only $1 x !");
}
if(message === "!alerts") {
client.action("kong_plays", user['display-name'] + " The alerts are shown in chat as I stream with shadowplay not allowing me to show alerts!");
}
if(//someone inputs !test [var] ) {
register [var]
say something + [var]
}
Upvotes: 0
Views: 334
Reputation: 138497
Maybe just split by spaces to get the different words:
const [command, ...args] = message.split(" ");
So you can access it like:
if(command === "!test") {
client.action("idk", "Hello " + args[0] + "!");
}
Upvotes: 1