Advertisement
jdm001

JimmerBot

Sep 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Discord = require('discord.io');
  2. var logger = require('winston');
  3. var auth = require('./auth.json');
  4. // Configure logger settings
  5. logger.remove(logger.transports.Console);
  6. logger.add(new logger.transports.Console, {
  7.     colorize: true
  8. });
  9. logger.level = 'debug';
  10. // Initialize Discord Bot
  11. var bot = new Discord.Client({
  12.    token: auth.token,
  13.    autorun: true
  14. });
  15. bot.on('ready', function (evt) {
  16.     logger.info('Connected');
  17.     logger.info('Logged in as: ');
  18.     logger.info(bot.username + ' - (' + bot.id + ')');
  19. });
  20. bot.on('message', function (user, userID, channelID, message, evt) {
  21.     // Our bot needs to know if it will execute a command
  22.     // It will listen for messages that will start with `!`
  23.     if (message.substring(0, 1) == '$') {
  24.         var args = message.substring(1).split(' ');
  25.         var cmd = args[0];
  26.        
  27.         args = args.splice(1);
  28.         switch(cmd) {
  29.             // !ping
  30.             case 'ping':
  31.                 bot.sendMessage({
  32.                     to: channelID,
  33.                     message: 'Pong!'
  34.                 });
  35.             break;
  36.             // Just add any case commands if you want to..
  37.          }
  38.      }
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement