Facebook
From Arnnav Kudale, 4 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 181
  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.                 });
  36.                 case 'youtube':
  37.                 bot.sendMessage({
  38.                     to: channelID,
  39.                     message: 'Its thebeastatFNBR or say "!yt link"if you want to go directly to the channel!'
  40.                 });
  41.                  case 'yt link':
  42.                 bot.sendMessage({
  43.                     to: channelID,
  44.                     message: 'Here you go!https://www.youtube.com/channel/UCJBQemgOjflI4ie7XCGs-cA?view_as=subscriber '
  45.                 });
  46.             break;
  47.             // Just add any case commands if you want to..
  48.          }
  49.      }
  50. });

Replies to JS 1 rss

Title Name Language When
JS 2 Arnnav Kudale javascript 4 Years ago.