Triz
February 26, 2019, 3:27am
1
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
Twitch IRC Tags Most IRC messages provide enough information that you can figure out what happened. For example, in the following PRIVMSG message, you know that user abc posted HeyGuys in the xyz channel. :abc!abc@abc.tmi.twitch.tv PRIVMSG #xyz...
and then you can read tags.bits
Twitch IRC Tags Most IRC messages provide enough information that you can figure out what happened. For example, in the following PRIVMSG message, you know that user abc posted HeyGuys in the xyz channel. :abc!abc@abc.tmi.twitch.tv PRIVMSG #xyz...
Triz
February 26, 2019, 4:25pm
3
How do I enable tags?
(As I said before I have no coding experience)
Triz
February 26, 2019, 4:28pm
5
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
Triz
February 26, 2019, 5:02pm
7
That help library makes no sense to me
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
Twitch Chat & Chatbots
Triz
February 26, 2019, 5:08pm
9
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.
Triz
February 26, 2019, 5:12pm
11
Okay Thank you. Like I said, I had a friend make this for me so I wasn’t sure what he used.
Triz
February 26, 2019, 5:25pm
13
I dont think that libary helps either. I tried client.broadcast
from that library and it throws errors in my command prompt.
Alca
February 26, 2019, 6:34pm
14
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!');
});
system
Closed
March 28, 2019, 6:34pm
15
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.