Advertisement
Technical_13

Discord selfbot

Nov 8th, 2017
1,269
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',// Your timezone goes here
  13.   timeZoneName: 'short'
  14.   };
  15.  
  16. const bot = 'spaghetti';
  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: settings[ bot ].url
  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', 'me', 'restart', 'sigh', 'shrug', 'tableflip', 'unflip' ];
  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 'me'     :
  114.               if ( arrMessage[ 0 ].substr( 0, 1 ) === '.' ) {
  115.                 var meContent = 'Here\'s an embed with some information about me:';
  116.                 var meEmbed = new Discord.RichEmbed()
  117.                   .setColor( '#FF00FF' )
  118.                   .setThumbnail( 'https://cdn.discordapp.com/attachments/guildID/channelID/Filename.png' )
  119.                   .addField( 'Name/ID', client.user + '#' + client.user.discriminator + ' - `' + client.user.id + '`' )
  120.                   .addField( 'eMail:', '[' + client.user.email + '](mailto:' + client.user.email + ')' )
  121.                   .addField( 'Stats:',
  122.                     '**Join date:**' +
  123.                     '\n**Guilds:**' +
  124.                     '\n**Friends:**' +
  125.                     '\n**Blocked:**',
  126.                     true )
  127.                   .addField( 'Data:',
  128.                     client.user.createdAt.toLocaleDateString( 'en-US', timeString ) +
  129.                     '\n' + client.guilds.size +
  130.                     '\n' + client.user.friends.array().length +
  131.                     '\n' + client.user.blocked.array().length, true )
  132.                   .addField( 'Find me on...',
  133.                     '[Discord](https://discordapp.com/):' +
  134.                     '\n[Github](https://github.com/):' +
  135.                     '\n[Twitch](https://twitch.tv/):' +
  136.                     '\n[Twitter](https://twitter.com/):' +
  137.                     '\n[YouTube](https://youtube.com/):', true )
  138.                   .addField( '...link',
  139.                     '\n[NAME](https://discord.me/URL)' +
  140.                     '\n[NAME](https://github.com/URL)' +
  141.                     '\n[NAME](https://twitch.tv/URL)' +
  142.                     '\n[NAME](https://twitter.com/URL)' +
  143.                     '\n[NAME](https://youtube.com/user/URL)', true )
  144.                   .setTimestamp()
  145.                   .setFooter( 'About me!', client.user.avatarURL );
  146.                 message.channel.send( meContent, { embed: meEmbed } );
  147.               }
  148.               else if ( arrMessage[ 0 ].substr( 0, 1 ) === '/' ) {
  149.                 message.channel.send( '_' + strArgs + '_' );
  150.               }
  151.               break;
  152.             case 'restart':
  153.               Promise.all( [
  154.                 timeNow = ( new Date() ).toLocaleDateString( 'en-US', timeString ),
  155.                 message.client.user.setStatus( 'dnd' )
  156.               ] ).then( () => {
  157.                 process.exit( );
  158.               } );
  159.               break;
  160.             case 'shrug':
  161.               message.channel.send( strArgs + ' ¯\_(ツ)_/¯' );
  162.               break;
  163.             case 'sigh':
  164.               message.channel.send( '_sighs..._' );
  165.               break;
  166.             case 'tableflip':
  167.               message.channel.send( strArgs + ' (╯°□°)╯︵ ┻━┻' );
  168.               break;
  169.             case 'unflip':
  170.               message.channel.send( strArgs + ' ┬─┬ ノ( ゜-゜ノ)' );
  171.               break;
  172.             default :
  173.           }
  174.         } );
  175.       }
  176.     }
  177.   }
  178. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement