Last active
February 17, 2017 12:49
-
-
Save Restioson/31bb49a7d26340366df1298075996a66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Half-Life Discord Cleverbot bot | |
var Discord = require("discord.js"); | |
var bot = new Discord.Client(); | |
var cleverbot = require("cleverbot.io") | |
// Cleverbot | |
var cleverbot = new cleverbot("API_USER", "API_KEY") | |
// Startup message | |
bot.on("ready", () => { | |
console.log('Ready to talk'); | |
}); | |
// Message received | |
bot.on("message", message => { | |
// If bot sent message | |
if (message.author.bot) { | |
return; // Return | |
} | |
// If mentions cleverbot | |
if (messageSplit[0] === "@cleverbot") { | |
// Pass on to cleverbot | |
cleverbot.ask(messageSplit.slice(1).join(" "), function (err, response) { | |
message.reply(response); // Send reply | |
}); | |
} | |
}); | |
// Login to discord | |
bot.login("BOT_KEY"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment