import * as tmi from 'tmi.js';
const client = new tmi.Client({
identity: {
name: 'my-bot-name',
auth: 'oauth:my-bot-auth'
}
});
client.connect();
client.on('connected', async () => {
console.log('Connected');
try {
await client.join('alca');
} catch(error) {
console.error(error);
}
});
client.on('join', ({ channel, user }) => {
if(user.isClientUser) {
// "Joined #alca"
console.log(`Joined ${channel.name}`);
}
});
client.on('message', ({ channel, message, user, reply, isClientUser }) => {
// "[#alca] Alca: !hello"
console.log(`[${channel.name}] ${user.displayName}: ${message}`);
if(isClientUser) {
return;
}
if(message.toLowerCase() === '!hello') {
// "@alca, heya!""
reply(`@${user.login}, heya!`);
}
});
See the guidelines.
git clone -b v2 --single-branch [email protected]:tmijs/tmi.js.git
npm install
npm run build
npm run test