Deno Twitch Message Interface
this package is very similar to tmi.js but for Deno. This package is still very early in development.
What it does
tmi.ts allows you to create bots and automate tasks in a users Twitch Chat.
What you need in order to use
- OAuth token -- https://twitchapps.com/tokengen/ -- make sure that your app's redirect url matches the websites redirect url
- Twitch Client ID
- Your Twitch username in lower-case
Example
import { TwitchChat } from "https://deno.land/x/tmi/mod.ts";
const tc = new TwitchChat({ userName, clientId, oauth });
const channel = await tc.joinChannel("xqc");
// Listen to the channels messages
for await (const pmsg of channel) {
// do something with msg here
if (pmsg.directMsg) {
channel.send(`@${msg.userName} hey whats up! Poggies!`);
}
}
// OR
// Listen to multiple channels
await tc.connect();
const channels: string[] = ["xqc", "sodapoppin", "ninja"];
const listeners = async () => {
for (const channel of channels) {
const connChan = await tc.joinChannel(channel);
(async () => {
for await (const pmsg of connChan) {
// do something with msg here
}
})();
}
};
listeners();