Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. //--------------------------------------------Constants--------------------------------------------
  2. const Discord =require('discord.js');
  3. const bot = new Discord.Client();
  4.  
  5. const token = 'NjQ0MzExMjk5NDQ2MTQ1MDM0.Xc4E4Q.VRAaYzSlbjy3uzHlTZdR-XSH42U';
  6.  
  7. const PREFIX = ".";
  8. //const being constant, basically a variable that wont change.
  9. //--------------------------------------------Variables--------------------------------------------
  10. var commands = [ ".help: This message",".purge: purges (x) amount of messages from chat [x being the number of messages]", ".info: learn a little more about me.", ".profile: shows user profile", ".battle: FIGHT TO THE DEATH"]
  11. //command variable. If another command is created add it and its description here.
  12. bot.on('ready', () =>{
  13. console.log('This bot is online');
  14. })
  15. //The message the console sends when the bot is turned online. Use "node ." to turn it on.
  16.  
  17. //--------------------------------------------Message Content--------------------------------------------
  18. bot.on('message', msg=>{
  19.  
  20. if (msg.author.equals(bot.user)) return;
  21. //So the bot wont respond to itself
  22. if (msg.content.startsWith(PREFIX)) return;
  23. //So only commands with the prefix work
  24.  
  25. if(msg.content.includes("Back in my day")){
  26. msg.reply('Ok boomer');
  27. }
  28.  
  29.  
  30. if(msg.content.includes("EthonSon")){
  31. msg.reply('You speak of my creator?')
  32. }
  33.  
  34. //messages sent based on what is typed, still a WIP
  35. //say "sendMessage" so it sends without a ping
  36. //includes is for a message in a sentence
  37.  
  38. //--------------------------------------------Arguments (Bot Commands)--------------------------------------------
  39.  
  40. let args = msg.content.substring(PREFIX.length).split(" ")
  41.  
  42. switch(args[0]){
  43. case 'ping':
  44. msg.channel.send ("pong")
  45. msg.channel.send ( new Date().getTime() - msg.createdTimestamp + " ms");
  46. break;
  47. }
  48.  
  49. //ping pong; first command use of the PREFIX. Shows how long it takea for the bot to reply.
  50.  
  51.  
  52. switch(args[0]){
  53. case 'help':
  54. msg.channel.send(commands);
  55. break;
  56. case 'purge':
  57. if(!args[1]) return msg.reply('Purge how much ya dingus?')
  58. msg.channel.bulkDelete(args[1]);
  59. break;
  60. case 'info':
  61. msg.channel.send('Hello, I am a bot created by user @EthonSon [JOYCONBOYZ]#0168. I\'m still in developement but if you have any questions ask my creator or say !help')
  62. }
  63.  
  64.  
  65. //commands for the bot. HEY YOU ETHAN! MAKE SURE YOU USE "msg" INSTEAD OF "message"!!!
  66. //The backslash tells JavaScript (this has nothing to do with jQuery, by the way) that the next character should be interpreted as "special". In this case, an apostrophe after a backslash means to use a literal apostrophe but not to end the string.
  67.  
  68.  
  69. switch(args[0]){
  70. case 'profile':
  71. const profile = new Discord.RichEmbed()
  72. .setTitle('Profile')
  73. .addField('Player Name', msg.author.username)
  74. .addField('Class', msg.member.roles.map(role => role.name).join(" , "))
  75. .setThumbnail(msg.author.avatarURL)
  76. .setColor(0xB20B0B)
  77. msg.channel.send(profile);
  78. break;
  79. }
  80.  
  81.  
  82.  
  83. switch(args[0]){
  84. case 'battle':
  85. const battle = new Discord.RichEmbed()
  86. .setTitle('FIGHT')
  87. .addField(('Player Name', msg.author.username) +" V.S "+ ('Player Name', msg.author.mentions))
  88.  
  89. // .setThumbnail(msg.author.avatarURL()) this is wrong but you'll figure it out
  90. .setColor(0xB20B0B)
  91. msg.channel.send(battle);
  92. break;
  93.  
  94.  
  95. }
  96.  
  97. })
  98. //profile embed. add ", true" to display embeds in a line
  99. bot.login(token);
  100. //token === bot user/passcode/ID. Used to log into the bot and turn it on.
  101. //don't wrap a bot.on("message") in a bot.on("message")
  102. //You shouldn't have too many event listeners
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement