Advertisement
iKnight

NukeBot

Dec 19th, 2017
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Details:
  2. ###############################
  3. #                             #
  4. #    Name: NukeBot            #
  5. #    Version: 1.0.3           #
  6. #    Author: Oliver Chapman   #
  7. #                             #
  8. ###############################
  9. */
  10.  
  11. // Checks to see if the modules are installed
  12. const Discord = require('discord.js');
  13. var timestamp = require('console-timestamp');
  14.  
  15. // Other const stuff
  16. const client = new Discord.Client();
  17. const token = '**************************************'; // Sets the client token for the bot
  18. const prefix = '.';
  19.  
  20. // Other Variables
  21. var now = new Date();
  22. var number = 478921;
  23.  
  24. var _quote = [
  25.     'The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.',
  26.     'If I won the award for laziness, I would send somebody to pick it up for me.',
  27.     'The greatest thing you will ever learn is just to love, and be loved in return.',
  28.     'Do not cry because it is over, smile because it happened.'
  29. ];
  30.  
  31. var _joke = [
  32.     "Why do Java developers wear glasses? Because they don't C#!",
  33.     "What do you call a bad Italian neighbourhood? A Spaghetto!",
  34.     "What time did the man go to the dentist? Tooth hurt-y!",
  35.     "5/4 of people admit that they are bad with fractions.",
  36.     'The protester sat down in his chair and said, "I will not stand for this!',
  37.     "What do you call a cow that deals with money? An accowtant",
  38.     "What do you call a snake that is 3.14 meters long? A pi-thon!",
  39. ];
  40.  
  41. // When the bot is ready, display a msg on Command Prompt
  42. client.on('ready', () => {
  43.     console.log('Ready!');
  44.     console.log('\n#--------- Log ---------#');
  45.     client.user.setGame('Type .help or .h for help!')
  46. });
  47.  
  48. client.on('guildMemberAdd', member => {
  49.    member.send('Welcome to the server!');
  50.    console.log(('DD-MM-YY hh:mm'.timestamp) + ' | ' + `${member.user.username} has joined!`);
  51. });
  52.  
  53. // Command setup
  54. client.on('message', message => {
  55.     // If a msg is .ping.
  56.     if (message.content == '.ping') {
  57.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  58.         message.channel.send('```Pong!```'); // Sends the message 'Pong!' to the current channel.
  59.     }
  60.     // If a msg is .pong.
  61.     if (message.content.startsWith(prefix + 'pong')) {
  62.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  63.         message.channel.send('```Ping!```'); // Sends the message 'Ping!' to the current channel.
  64.     }
  65.         // If a msg is .nuke.
  66.     if (message.content.startsWith(prefix + 'nuke')) {    // If a msg is !nuke.
  67.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  68.         if (message.member.hasPermission("MANAGE_CHANNELS", true)) {
  69.             message.channel.permissionsFor(message.member).serialize()
  70.             message.channel.delete('50000'); // Deletes upto 50,000 messages from the current channel.
  71.         }
  72.         else {
  73.             console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  74.             message.reply('```You do not have permission to do that!```');
  75.         }
  76.     }
  77.     // If a msg is .help.
  78.     if (message.content == '.help') {
  79.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  80.         message.channel.send('```.ping / .pong - Plays a game of Ping Pong.\n.nuke - Deletes 5000 messages from the current text channel.\n.help/.h - Displays the commands and what they do.\n.cat - Shows an image of a smiling cat\n.quote - Posts a random quote.\n.joke - Posts a random joke.```');
  81.     }
  82.     if (message.content == '.h') {
  83.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  84.         message.channel.send('```.ping / .pong - Plays a game of Ping Pong.\n.nuke - Deletes 5000 messages from the current text channel.\n.help/.h - Displays the commands and what they do.\n.cat - Shows an image of a smiling cat\n.quote - Posts a random quote.\n.joke - Posts a random joke.```');
  85.     }  
  86.     // If a msg is .cat.
  87.     if (message.content.startsWith(prefix + 'cat')) {
  88.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  89.         message.channel.send({
  90.             "embed": { // Prepares and embedded msg
  91.                 title: 'Happy Cat!', // Sets the image title
  92.                 url: 'https://www.google.com/', // URL for search engine
  93.                 "image": { // Properties for the image.
  94.                     "url": "https://cms.hostelbookers.com/hbblog/wp-content/uploads/sites/3/2012/02/cat-happy-cat-e1329931204797.jpg", // URL for the image
  95.                 }
  96.             }
  97.         });
  98.     }
  99.     if (message.content.startsWith(prefix + 'quote')) {
  100.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  101.         var rquote = Math.floor(Math.random() * _quote.length);
  102.         message.reply(`${_quote[rquote]}`)
  103.     }
  104.     if (message.content.startsWith(prefix + 'joke')) {
  105.         console.log(('DD-MM-YY hh:mm'.timestamp) + ' | Received #' + message.id + ': ' + message.content);
  106.         var rjoke = Math.floor(Math.random() * _joke.length);
  107.         message.reply(`${_joke[rjoke]}`);
  108.     }
  109. });
  110.  
  111. client.login(token); // Login to a Discord Client with the bot token.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement