const tmi = require('tmi.js');
const client = new tmi.Client({
options: { debug: true },
identity: {
username: 'beebot_v1',
password:
},
channels: [ 'smobee_' ]
});
// Register our event handlers (defined below)
client.on('message', onMessageHandler);
client.on('connected', onConnectedHandler);
client.connect();
client.on('connected', (address, port) => {
client.action('smobee_', 'BeeBot est connecté ! VoHiYo');
});
function onMessageHandler (target, context, msg, self) {
if (self) { return; } // Ignore messages from the bot
const commandName = msg.trim();
if (commandName === '!hnum') {
const num = rollDice();
client.say(target, `ID USER as tiré un ${num} !`);
console.log(`* Executed ${commandName} command`);
} else {
console.log(`* Commande inconnue ${commandName}`);
}
}
function rollDice () {
const sides = 6;
return Math.floor(Math.random() * sides) + 1;
}
function onConnectedHandler (addr, port) {
console.log(`* Connecté à ${addr}:${port}`);
}
ID USER it’s for id the user who used the command