Advertisement
Guest User

Untitled

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