Should I just trigger the /usernotice command to catch subscription events?
I also found some older code snippets that look like this:
botClient.onSubscription((channelName, username) => {
botClient.say(channelName, `Thank you @${username} for the sub!`);
});
botClient.onResubscription((channelName, username, subData) => {
botClient.say(channelName, `Thanks @${username} for ${subData.months} months of support!`);
});
botClient.onGiftSub((channelName, username, subData) => {
botClient.say(channelName, `Shoutout to ${subData.gifter} for gifting to ${username}!`);
});
But when I try this I get “TypeError: botClient.onSubscription is not a function”.
Had the same confusion when I started with Twitch events last year. You’re mixing up different library versions and approaches. Most modern JavaScript Twitch libraries handle subscription events through USERNOTICE IRC messages, not dedicated subscription methods like those old snippets you found. What worked for me: build a message parser that checks for specific message types. When someone subscribes, Twitch sends a USERNOTICE message with metadata telling you exactly what happened. Check the message tags to see if it’s a sub, resub, gift sub, etc. For testing, set up a test channel and use Twitch’s EventSub simulator or create mock message objects that copy real subscription events. You can verify your parsing logic without waiting for actual subs. Key thing to remember: subscriptions are just specialized chat messages with specific metadata attached.
the /usernotice cmd ain’t gonna do it - you gotta listen for events instead. what library u usin? if it’s tmi.js, it treats USERNOTICE msgs diff from those old methods. give client.on('subscription', ...) a shot, but first peep ur library’s docs, they all differ.
You’re on the right track but your approach has some issues. The /usernotice command trigger won’t work - that’s not how event handling works. Those older code snippets you found are probably from an outdated library version, which explains the TypeError. For modern Twitch bots, you need to listen for USERNOTICE messages properly. If you’re using tmi.js, here’s how to do it: client.on('message', (channel, tags, message, self) => { if (tags['msg-id'] === 'sub' || tags['msg-id'] === 'resub') { client.say(channel, Thanks @${tags[‘display-name’]} for the subscription!); } });. Just check the msg-id tag in the message metadata. Different subscription types have different msg-id values like ‘sub’, ‘resub’, ‘subgift’, etc. This works reliably across library versions and gives you access to all subscription details through the tags object.
also worth checking out twitch’s websocket api if ur library keeps giving u trouble. eventsub webhooks handle all the subscription types cleanly - no need to parse irc msgs manually.
Dealing with message parsing edge cases and library version differences is such a pain. Been there - it gets messy fast.
What saved me time? I automated the whole subscription handling flow instead of wrestling with IRC message parsing and figuring out which tags to check. Set everything up through Latenode.
You can connect Twitch EventSub directly to your bot without writing all that parsing code. Someone subscribes, the webhook triggers automatically, and you format your thank you messages however you want. No more guessing about msg-id values or dealing with library quirks.
You get proper event data structure instead of digging through IRC tags. Gift subs, resubs - everything just works without the headache.
For testing, simulate the webhooks in the workflow editor so you don’t need actual subscribers to test your logic.
Saved me hours compared to debugging message handlers and dealing with library documentation.