Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   A ping pong bot, whenever you send "ping", it replies "pong".
  3. */
  4.  
  5. // import the file config
  6. const config = require('./config')
  7. // import the discord.js module
  8. const Discord = require('discord.js');
  9.  
  10. // create an instance of a Discord Client, and call it bot
  11. const bot = new Discord.Client();
  12.  
  13. // the token of your bot - https://discordapp.com/developers/applications/me
  14. const token = config.botToken;
  15.  
  16. // the ready event is vital, it means that your bot will only start reacting to information
  17. // from Discord _after_ ready is emitted.
  18. bot.on('ready', () => {
  19.   console.log('I am ready!');
  20. });
  21.  
  22. // create an event listener for messages
  23. bot.on('message', message => {
  24.   // if the message is "ping",
  25.   if (message.content === 'ping') {
  26.     // send "pong" to the same channel.
  27.     message.channel.sendMessage('pong');
  28.   }
  29. });
  30.  
  31. // log our bot in
  32. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement