I am writing a bot for the twitch platform, and I want to make it respond to users who have subscribed to the channel.
I found USERNOTICE for this in the documentation https://dev.twitch.tv/docs/irc/commands#usernotice
But I didn't quite understand how to use it.
Something like this?
client.on("message", () => {
client.say(config.get('channel'), '/usernotice message');
});
Just call the /usernotice
command and it should respond to this subscription message?
It's just difficult to test all this and I would like to have a more or less specific solution.
UPDATE
Also in old documentation I found this code
chatClient.onSub((channel, user) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel!`);
});
chatClient.onResub((channel, user, subInfo) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel for a total of ${subInfo.months} months!`);
});
chatClient.onSubGift((channel, user, subInfo) => {
chatClient.say(channel, `Thanks to ${subInfo.gifter} for gifting a subscription to ${user}!`);
});
But it throws an error - TypeError: client.onSub is not a function
Is there any way to use it now?
chatClient.on('sub', (channel, user) => {
chatClient.say(channel, `Thanks to @${user} for subscribing to the channel!`);
});
On the assumption you are using tmi.js you should be looking at the tmi.js documentation rather than twitch's documentation. This documentation can be located here
in the documentation they have an example for a subscription event which can be found here: https://github.com/tmijs/docs/blob/gh-pages/_posts/v1.4.2/2019-03-03-Events.md#subscription
client.on("subscription", (channel, username, method, message, userstate) => {
// Do your stuff.
});