Cheer Announcement for NodeJS Chatbot

I’m tryna setup a “cheer announcement” for my bot. I have NO coding experience at all. I had a friend write me up a bot and I’m sort of learning through the code currently on said bot. I’ve done most of the cheer announcement part “correctly”. The only problem I’m having is the “variables” for the user that cheers and the cheer amount. Any help would be appreciated.

This is what I have so far:

`client.on('cheer', (channel, username, userstate, message) => {
switch(channel) {
	case '#ExampleChannel':
		client.say(channel, username + ' has cheered ' + userstate.bits + ' bits!');
		break;
}`

I’ve tried “username” and “userstate.bits” and they both don’t work.

Not enough information to answer here

You need to enable tags

and then you can read tags.bits

How do I enable tags?

(As I said before I have no coding experience)

You send

CAP REQ :twitch.tv/tags

Where do I type that? Is there a specific section it goes into or just in the main .js file itself?

At the same point you send password. So yes in the JS file. Didn’t know it was JS till just now.

You might want to look at a helper library such as TMI isntead of custom as you have

That help library makes no sense to me :confused:

And do I put that

< CAP REQ :twitch.tv/tags
> :tmi.twitch.tv CAP * ACK :twitch.tv/tags

directly UNDER the identity part of the JS file?

It would save a lot of time to implement that than to scratch build.

No idea. I cannot see your code, identity is not a thing you do when connecting to Twitch Chat, you do

< PASS oauth:<Twitch OAuth token>
< NICK <user>

as documented

This is what’s on the top of the file:

const twitchjs = require('twitch-js');
const request = require('request-promise');
const client = new twitchjs.client({
	options: { debug: true },
	connection: { reconnect: true, secure: true },
	identity: { username: 'itsjusttriz', password: '<*HIDDEN*>' },
	channels: ['#itsjusttriz'] // Add more channels here.
});

const allowedUsers = ['itsjusttriz'];

[removed wrong library notes]

It’s documentation may be of more use. I do not use this library and can’t help too much.

This forum is for general third party support rather than specific library support.

Okay Thank you. Like I said, I had a friend make this for me so I wasn’t sure what he used.

I got the wrong library it could be this one

https://twitch-devs.github.io/twitch-js/docs/getting-started

I dont think that libary helps either. I tried client.broadcast from that library and it throws errors in my command prompt.

Throw in your token into the client options and give this a try. I think the switch-case was tripping you up.

const twitchjs = require('twitch-js');
const client = new twitchjs.client({
    options: { debug: true },
    connection: { reconnect: true, secure: true },
    identity: { username: 'itsjusttriz', password: '<*HIDDEN*>' },
    channels: [ '#itsjusttriz' ]
});
client.on('cheer', (channel, username, userstate, message) => {
    client.say(channel, username + ' has cheered ' + userstate.bits + ' bits!');
});

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