@twurple/auth-tmi
TypeScript icon, indicating that this package has built-in type declarations

7.1.0 • Public • Published

Twurple - Authentication for TMI.js

GitHub license npm version PRs welcome

Use tmi.js with the added benefits of @twurple/auth's automatic token handling.

Installation

yarn add @twurple/auth @twurple/auth-tmi

or using npm:

npm install @twurple/auth @twurple/auth-tmi

How to use

This package is generally used like tmi.js is normally, with just a single minor change.

It completely ignores the identity option, and instead takes an authProvider option which takes an AuthProvider instance that can be used for other @twurple packages as well.

This also offers the additional benefit of being able to refresh tokens internally using a refreshing AuthProvider.

Example

Taken from the tmi.js README and adapted for this package:

const tmi = require('@twurple/auth-tmi');
const { StaticAuthProvider } = require('@twurple/auth');
const authProvider = new StaticAuthProvider('my-client-id', 'my-bot-token');
const client = new tmi.Client({
	options: { debug: true, messagesLogLevel: 'info' },
	connection: {
		reconnect: true,
		secure: true
	},
	authProvider: authProvider,
	channels: ['my-channel']
});
client.connect().catch(console.error);
client.on('message', (channel, tags, message, self) => {
	if (self) return;
	if (message.toLowerCase() === '!hello') {
		client.say(channel, `@${tags.username}, heya!`);
	}
});

If you're getting stuck...

You can join the Twitch API Libraries Discord Server and ask in #twurple for support.

Dependents (1)

Package Sidebar

Install

npm i @twurple/auth-tmi

Weekly Downloads

47

Version

7.1.0

License

MIT

Unpacked Size

9.95 kB

Total Files

9

Last publish

Collaborators

  • d-fischer