this is the code :
const tmi = require('tmi.js');
// Define configuration options
const opts = {
identity: {
username: process.env.BOT_USERNAME,
password: process.env.OAUTH_TOKEN
},
channels: [
process.env.CHANNEL_NAME
]
};
// Create a client with our options
const client = new tmi.client(opts);
// Register our event handlers (defined below)
client.on('message', onMessageHandler);
client.on('connected', onConnectedHandler);
// Connect to Twitch:
client.connect();
// Called every time a message comes in
function onMessageHandler (target, context, msg, self) {
if (self) {return}
const commandName = msg.trim();
if (commandName === '!discord') {
client.say('Join my discord, and chat with me there! discord.gg/b3W2nNaVTEA And if you would like to be notified for streams, just go on the roles channel and react to Twitch Pings! :D')
} else if (commandName === '!donate') {
client.say(' Here is the donation link for my twitch if ya wanna support me! https://streamlabs.com/')
} else if (commandName === '!guild') {
client.say('I have a hypixel guild! Feel free to join by typing /g join DartSyndicate in hypixel!')
} else if (commandName === '!lurk') {
client.say(` Thank you for lurking ${context.username}! Hope to see you around soon! `)
} else if (commandName === '!editor') {
client.say(' The best editor Dart could ever ask for, in return please do check her out on her instagram socials! instagram.com/t')
} else if (commandName === 'hi') {
client.say('Hi!')
} else if(commandName === 'bye') {
client.say('Cya')
} else if(commandName === 'cya') {
client.say("Cya")
} else {
console.log('Just a Message')
}
}
// Function called when the "dice" command is issued
function rollDice () {
const sides = 20;
return Math.floor(Math.random() * sides) + 1;
}
// Called every time the bot connects to Twitch chat
function onConnectedHandler (addr, port) {
console.log(`* Connected to ${addr}:${port}`);
console.log(`* Connected to ${addr}:${port}`);
client.say('Bot Has Loaded! (Made By TheGreatArki) ')
}