Advertisement
Guest User

Untitled

a guest
May 27th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. const Discord = require('discord.js');
  2.  
  3. const client = new Discord.Client();
  4.  
  5. const prefix = "!";
  6.  
  7. client.on("ready", () => {
  8. console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels.`);
  9. });
  10.  
  11.  
  12. client.on("message", async message => {
  13.  
  14. console.log(`${message.content}, -${message.author.username}`);
  15.  
  16. //Don't do anything if the message is sent by a bot
  17. if(message.author.bot) return;
  18.  
  19.  
  20. /* Global messages */
  21. if (message.content.toLowerCase().includes('hello bot')) {
  22. message.channel.send(`Hekke ${message.author}`);
  23. }
  24.  
  25.  
  26. /* Commands */
  27. if(message.content.indexOf(prefix) !== 0) return;
  28.  
  29. const arguments = message.content.slice(prefix.length).trim().split(/ +/g);
  30. const command = arguments.shift().toLowerCase();
  31.  
  32. console.log('arguments:', arguments);
  33. console.log('command:', command);
  34.  
  35. if(command === "ping") {
  36. const m = await message.channel.send("Ping?");
  37. m.edit(`Pong! Latency is ${m.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms`);
  38. }
  39.  
  40. if(command === "say") {
  41. const sayMessage = arguments.join(" ");
  42. message.delete().catch(O_o=>{});
  43. message.channel.send(sayMessage);
  44. }
  45. });
  46.  
  47.  
  48. client.login("ADD_YOUR_BOT_TOKEN_HERE");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement