Advertisement
Technical_13

Discord selfbot

Nov 7th, 2017
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require( 'discord.js' );
  2. const commando = require( 'discord.js-commando' );
  3. const path = require( 'path' );
  4. const settings = require( path.join( __dirname, '../settings.json' ) );
  5. const timeString = {
  6.   year: 'numeric',
  7.   month: 'long',
  8.   day: 'numeric',
  9.   hour: 'numeric',
  10.   minute: 'numeric',
  11.   second: 'numeric',
  12.   timeZone: 'America/New_York',
  13.   timeZoneName: 'short'
  14.   };
  15.  
  16. const bot = 'BluLightShow';
  17.  
  18. function clean( text ) {
  19.   if ( typeof( text ) === 'string' ) {
  20.     return text.replace( /`/g, '`' + String.fromCharCode( 8203 ) ).replace( /@/g, '@' + String.fromCharCode( 8203 ) );
  21.   } else {
  22.     return text;
  23.   }
  24. }
  25.  
  26. const client = new commando.Client( {
  27.   unknownCommandResponse: settings[ bot ].unknownCommandResponse,
  28.   owner: settings[ bot ].owners
  29. } );
  30.  
  31. client.login( settings[ bot ].token );
  32.  
  33. client.on( 'ready', async () => {
  34.   Promise.all( [
  35.     await client.user.setPresence( {
  36.       status: settings[ bot ].status,
  37.       game: {
  38.         name: settings[ bot ].game
  39.         url: 'https://twitch.tv/communities/movember'// For #Movember
  40.       },
  41.       afk: false
  42.     } )
  43.   ] ).then( () => {
  44.     var readyTime = ( new Date() ).toLocaleDateString( 'en-US', timeString );
  45.     console.log( '\n' + readyTime + ':\t' + settings[ bot ].name + ' is now ready to do it\'s thing!\n' ) } );
  46. } );
  47.  
  48. client.on( 'message', async message => {
  49.   if ( message.author !== client.user ) {
  50.     return;
  51.   } else {
  52.     var arrMessage = message.content.split( ' ' );
  53.     const arrCommands = [ 'ack', 'afk', 'clean', 'clear', 'community', 'game', 'host', 'me', 'restart', 'sigh', 'shrug', 'status', 'stream', 'tableflip', 'unflip', 'unhost' ];
  54.     var strCommand = arrMessage[ 0 ].toLowerCase();
  55.     var arrArgs = arrMessage.slice( 1 );
  56.     var strArgs = arrArgs.join( ' ' );
  57.     if (
  58.       strCommand.substr( 0, 1 ) === '.' || (
  59.         strCommand.toUpperCase() === '!CLEAN' ||
  60.         strCommand.toUpperCase() === '!CLEAR'
  61.       ) || (
  62.         strCommand.toUpperCase() === '/ME' ||
  63. //        strCommand.toUpperCase() === '/NICK' ||
  64.         strCommand.toUpperCase() === '/SIGH' ||
  65.         strCommand.toUpperCase() === '/SHRUG' ||
  66.         strCommand.toUpperCase() === '/TABLEFLIP' ||
  67. //        strCommand.toUpperCase() === '/TTS' ||
  68.         strCommand.toUpperCase() === '/UNFLIP'
  69.     ) ) {
  70.       strCommand = strCommand.substr( 1 ).toLowerCase();
  71.       if ( arrCommands.indexOf( strCommand ) !== -1 ) {
  72.         message.delete().then( () => {
  73.           switch ( strCommand ) {
  74.             case 'ack'    :
  75.               client.guilds.array().forEach( function( guild ) {
  76.                 guild.acknowledge().then( result => { console.log( 'Acknowledged messages in: ' + result.name ); } ).catch( console.error );
  77.               } );
  78.               break;
  79.             case 'afk'    :
  80.               if ( arrArgs.length === 1 && arrArgs[ 0 ] === 'off' ) {
  81.                 isAFK = false;
  82.                 client.user.setPresence( { status: preStreamStatus, game: { name: settings[ bot ].game }, afk: true } );
  83.                 client.user.setAFK( false ).catch( );
  84.                 message.channel.send( 'I\'m  back.' );
  85.               } else {
  86.                 Promise.all( [
  87.                   preStreamStatus = 'online',//client.user.presence.status;
  88.                   client.user.setPresence( { status: 'dnd', game: { name: strArgs }, afk: true } ),
  89.                   isAFK = true
  90.                 ] ).then( () => {
  91.                   var strAfkMessage = 'I\'m AFK';
  92.                   if ( !strArgs ) {
  93.                     strAfkMessage += '.';
  94.                   } else {
  95.                     strAfkMessage += ': ' + strArgs;
  96.                   }
  97.                   message.channel.send( strAfkMessage );
  98.                 } );
  99.               }
  100.               break;
  101.             case 'clean'  :
  102.             case 'clear'  :
  103.               var intMessagesToDelete = ( arrArgs.length === 0 ? 1 : parseInt( arrArgs[ 0 ] ) );
  104.               message.channel.fetchMessages( {
  105.                 limit: 100
  106.               } ).then( messages => {
  107.                 let arrMessages = messages.array();
  108.                 arrMessages = arrMessages.filter( thisMessage => thisMessage.author.id === client.user.id );
  109.                 arrMessages.length = intMessagesToDelete;
  110.                 arrMessages.map( thisMessage => thisMessage.delete().catch( error => { console.error( error ) } ) );
  111.               } );
  112.               break;
  113.             case 'community' :
  114.               Promise.all( [
  115.                 client.user.setPresence( { game: { name: 'support of the ' + arrArgs[ 0 ] + ' community on Twitch.tv', url: 'https://www.twitch.tv/communities/' + arrArgs[ 0 ].toLowerCase() } } ),
  116.                 message.channel.send( 'I\'m supporting the **' + client.user.presence.game.name.replace( 'support of the ', '' ).replace( ' community on Twitch.tv', '' ) + '** community on <' + client.user.presence.game.url + '>, check it out!' )
  117.               ] ).then( () => {
  118.                 message.author.lastMessage.react( '%F0%9F%8E%A5' ).catch( error => { console.error( error ); } );
  119.               } );
  120.               break;
  121.             case 'game'   :
  122.               client.user.setPresence( { game: { name: strArgs } } );
  123.               break;
  124.             case 'host'   :
  125.               Promise.all( [
  126.                 client.user.setPresence( { game: { name: 'a host of ' + arrArgs[ 0 ], url: 'https://www.twitch.tv/' + arrArgs[ 0 ].toLowerCase() } } ),
  127.                 message.channel.send( 'I\'m hosting **' + client.user.presence.game.name.replace( 'a host of ', '' ) + '** on <' + client.user.presence.game.url + '>, check it out!' )
  128.               ] ).then( () => {
  129.                 message.author.lastMessage.react( '%F0%9F%8E%A5' ).catch( error => { console.error( error ); } );
  130.               } );
  131.               break;
  132.             case 'me'     :
  133.               if ( arrMessage[ 0 ].substr( 0, 1 ) === '.' ) {
  134.                 var meContent = 'Here\'s an embed with some information about me:';
  135.                 var presenceInfo = client.user;
  136.                 if ( !client.user.presence.game || !client.user.presence.game.name ) {
  137.                   if ( client.user.presence.status === 'invisible' ) {
  138.                     presenceInfo += ' is an enigma.';
  139.                   } else {
  140.                     presenceInfo += ' is ' + client.user.presence.status;
  141.                   }
  142.                 } else {
  143.                   if ( !client.user.presence.game.url ) {
  144.                     presenceInfo += ' is playing **' + ( client.user.presence.game.name ? client.user.presence.game.name : 'a game' ) + '**. :video_game:';
  145.                   } else if ( client.user.presence.game.url.indexOf( 'twitch.tv/URL' ) !== -1 ) {
  146.                     presenceInfo += ' is streaming **' + client.user.presence.game.name + '** on <https://www.twitch.tv/URL>. :movie_camera:';
  147.                     meContent += '\n:link: https://www.twitch.tv/URL';
  148.                   } else if ( client.user.presence.game.url.indexOf( 'twitch.tv/communities/' ) !== -1 ) {
  149.                     presenceInfo += ' is supporting the **' + client.user.presence.game.name.replace( 'support of the ', '' ).replace( ' community on Twitch.tv', '' ) + '** community on <' + client.user.presence.game.url + '> :movie_camera:';
  150.                     meContent += '\n:link: ' + client.user.presence.game.url;
  151.                   } else {
  152.                     presenceInfo += ' is hosting [**' + client.user.presence.game.name.replace( 'a host of ', '' ) + '**](' + client.user.presence.game.url + '). :movie_camera:';
  153.                     meContent += '\n:link: ' + client.user.presence.game.url;
  154.                   }
  155.                 }
  156.                 var meEmbed = new Discord.RichEmbed()
  157.                   .setColor( '#FF00FF' )
  158.                   .setThumbnail( 'https://cdn.discordapp.com/attachments/guildID/channelID/Filename.png' )
  159.                   .addField( 'Name/ID', client.user + '#' + client.user.discriminator + ' - `' + client.user.id + '`' )
  160.                   .addField( 'eMail:', '[' + client.user.email + '](mailto:' + client.user.email + ')' )
  161.                   .addField( 'Status:', presenceInfo )
  162.                   .addField( 'Stats:',
  163.                     '**Join date:**' +
  164.                     '\n**Guilds:**' +
  165.                     '\n**Friends:**' +
  166.                     '\n**Blocked:**',
  167.                     true )
  168.                   .addField( 'Data:',
  169.                     client.user.createdAt.toLocaleDateString( 'en-US', timeString ) +
  170.                     '\n' + client.guilds.size +
  171.                     '\n' + client.user.friends.array().length +
  172.                     '\n' + client.user.blocked.array().length, true )
  173.                   .addField( 'Find me on...',
  174.                     '[Discord](https://discordapp.com/):' +
  175.                     '\n[Github](https://github.com/):' +
  176.                     '\n[Twitch](https://twitch.tv/):' +
  177.                     '\n[Twitter](https://twitter.com/):' +
  178.                     '\n[YouTube](https://youtube.com/):', true )
  179.                   .addField( '...link',
  180.                     '\n[NAME](https://discord.me/URL)' +
  181.                     '\n[NAME](https://github.com/URL)' +
  182.                     '\n[NAME](https://twitch.tv/URL)' +
  183.                     '\n[NAME](https://twitter.com/URL)' +
  184.                     '\n[NAME](https://youtube.com/user/URL)', true )
  185.                   .setTimestamp()
  186.                   .setFooter( 'About me!', client.user.avatarURL );
  187.                 message.channel.send( meContent, { embed: meEmbed } );
  188.               }
  189.               else if ( arrMessage[ 0 ].substr( 0, 1 ) === '/' ) {
  190.                 message.channel.send( '_' + strArgs + '_' );
  191.               }
  192.               break;
  193.             case 'restart':
  194.               Promise.all( [
  195.                 timeNow = ( new Date() ).toLocaleDateString( 'en-US', timeString ),
  196.                 message.client.user.setStatus( 'dnd' )
  197.               ] ).then( () => {
  198.                 process.exit( );
  199.               } );
  200.               break;
  201.             case 'shrug':
  202.               message.channel.send( strArgs + ' ¯\_(ツ)_/¯' );
  203.               break;
  204.             case 'sigh':
  205.               message.channel.send( '_sighs..._' );
  206.               break;
  207.             case 'status' :
  208.               client.user.setPresence( { status: arrArgs[ 0 ] } );
  209.               break;
  210.             case 'stream' :
  211.               var strSanitizeURL
  212.               if ( arrArgs[ 0 ].indexOf( /twitch.tv/i ) !== -1 ) {
  213.                 strSanitizeURL = 'https://www.twitch.tv' + arrArgs[ 0 ].substr( arrArgs[ 0 ].lastIndexOf( '/') ).toLowerCase();
  214.               } else {
  215.                 strSanitizeURL = arrArgs[ 0 ];
  216.               }
  217.               if ( !client.user.presence.game.name ) {
  218.                 client.user.setPresence( { game: { name: 'some stupid game or something' } } );
  219.               }
  220.               client.user.setPresence( { game: { url: strSanitizeURL } } );
  221.               message.channel.send( 'I\'m streaming ' + client.user.presence.game.name + ' on <' + client.user.presence.game.url + '>, check it out!' );
  222.               break;
  223.             case 'tableflip':
  224.               message.channel.send( strArgs + ' (╯°□°)╯︵ ┻━┻' );
  225.               break;
  226.             case 'unflip':
  227.               message.channel.send( strArgs + ' ┬─┬ ノ( ゜-゜ノ)' );
  228.               break;
  229.             case 'unhost' :
  230.               Promise.all( [
  231.                 message.channel.send( 'I\'m no longer hosting **' + client.user.presence.game.name.replace( 'a host of ', '' ) + '** on <' + client.user.presence.game.url + '>.' )
  232.               ] ).then( () => {
  233.                 message.client.user.setGame( settings[ bot ].game ).then( () => {
  234.                   message.author.lastMessage.react( '%E2%9C%85' ).catch( error => { console.error( error ) } );
  235.                 } ).catch( err => { console.error( err ); } )
  236.               } );
  237.             default :
  238.           }
  239.         } );
  240.       }
  241.     }
  242.   }
  243. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement