Skip to content

how do i send a message to a channel. #549

Answered by Khyretos
Khyretos asked this question in Q&A
Discussion options

You must be logged in to vote

i dont know if this is the correct way but this is what i came up with:

const tmi = require('tmi.js');
let message = ''

const client = new tmi.Client({
	options: {
		skipUpdatingEmotesets: true,
	},
	identity: {
		username: config.settings.TWITCH.USERNAME,
		password: `oauth:${config.settings.TWITCH.OAUTH_TOKEN}`,
	},
	channels: [config.settings.TWITCH.CHANNEL_NAME],
});

client.on('connected', () => {
	console.log(`${message}`);
	if(message !== ''){
		client.say(config.settings.TWITCH.CHANNEL_NAME, message);
	}
	message = '';
});

function sendMessage(text) {
	client.connect().catch(console.error);
	message = text
}

client.connect().catch(console.error);

sendMessage("test");

i dont kn…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@AlcaDesign
Comment options

@Khyretos
Comment options

@Khyretos
Comment options

Answer selected by Khyretos
Comment options

You must be logged in to vote
2 replies
@Khyretos
Comment options

@AlcaDesign
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants