Created
May 24, 2018 16:01
-
-
Save Dmunch04/f879bc60eb1e49336c11ed91032f5fce to your computer and use it in GitHub Desktop.
Discord Bot
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
| { | |
| "token": "NDQ5MjMyNTc4NzIyMTM2MTA1.DehsIQ.XyZmE-yk7VI0yGCQHGKRFzx3uaA" | |
| } |
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
| var Discord = require('discord.io'); | |
| var logger = require('winston'); | |
| var auth = require('./auth.json'); | |
| // Configure logger settings | |
| logger.remove(logger.transports.Console); | |
| logger.add(logger.transports.Console, { | |
| colorize: true | |
| }); | |
| logger.level = 'debug'; | |
| // Initialize Discord Bot | |
| var bot = new Discord.Client({ | |
| token: auth.token, | |
| autorun: true | |
| }); | |
| bot.on('ready', function (evt) { | |
| logger.info('Connected'); | |
| logger.info('Logged in as: '); | |
| logger.info(bot.username + ' - (' + bot.id + ')'); | |
| }); | |
| bot.on('message', function (user, userID, channelID, message, evt) { | |
| // Our bot needs to know if it will execute a command | |
| // It will listen for messages that will start with `!` | |
| if (message.substring(0, 1) == '>') { | |
| var args = message.substring(1).split(' '); | |
| var cmd = args[0]; | |
| args = args.splice(1); | |
| switch(cmd) { | |
| // !ping | |
| case 'hi': | |
| bot.sendMessage({ | |
| to: channelID, | |
| message: 'Hello!' | |
| }); | |
| break; | |
| // Just add any case commands if you want to.. | |
| } | |
| } | |
| }); |
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
| { | |
| "name": "Munchii's Master Bot", | |
| "version": "1.0.0", | |
| "description": "Helu:)", | |
| "main": "bot.js", | |
| "author": "Munchii", | |
| "dependencies": {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment