Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
const eris = require('eris');
const { BOT_TOKEN } = require('../config.json');
// Create a Client instance with our bot token.
const bot = new eris.Client(BOT_TOKEN);
// When the bot is connected and ready, log to console.
bot.on('ready', () => {
console.log('Connected and ready.');
});
// Every time a message is sent anywhere the bot is present,
// this event will fire and we will check if the bot was mentioned.
// If it was, the bot will attempt to respond with "Present".
bot.on('messageCreate', async (msg) => {
const botWasMentioned = msg.mentions.find(
mentionedUser => mentionedUser.id === bot.user.id,
);
if (botWasMentioned) {
try {
await msg.channel.createMessage('Present');
} catch (err) {
// There are various reasons why sending a message may fail.
// The API might time out or choke and return a 5xx status,
// or the bot may not have permission to send the
// message (403 status).
console.warn('Failed to respond to mention.');
console.warn(err);
}
}
});
bot.on('error', err => {
console.warn(err);
});
bot.connect();