From 7f65c0c1170a6104568ef4ce8e3167f93669a59d Mon Sep 17 00:00:00 2001 From: benji7425 Date: Sat, 29 Oct 2016 18:31:16 +0100 Subject: [PATCH] Added basic ping pong bot Requires a config.json file with a token --- .gitignore | 2 ++ feed-bot.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 feed-bot.js diff --git a/.gitignore b/.gitignore index 100aec0..715d005 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,5 @@ jspm_packages # Output of 'npm pack' *.tgz + +/config.json diff --git a/feed-bot.js b/feed-bot.js new file mode 100644 index 0000000..4c6c115 --- /dev/null +++ b/feed-bot.js @@ -0,0 +1,21 @@ +var Discord = require("discord.io"); +var Config = require("./config.json"); +var console = require("console"); + +var bot = new Discord.Client({ + token: Config.token, + autorun: true +}); + +bot.on("ready", function () { + console.log(bot.username + " - (" + bot.id + ")"); +}); + +bot.on("message", function (user, userID, channelID, message) { + if (message === "ping") { + bot.sendMessage({ + to: channelID, + message: "pong" + }); + } +}); \ No newline at end of file