Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require( 'discord.js' );
- const commando = require( 'discord.js-commando' );
- const path = require( 'path' );
- const settings = require( path.join( __dirname, '../settings.json' ) );
- const timeString = {
- year: 'numeric',
- month: 'long',
- day: 'numeric',
- hour: 'numeric',
- minute: 'numeric',
- second: 'numeric',
- timeZone: 'America/New_York',
- timeZoneName: 'short'
- };
- const bot = 'BluLightShow';
- function clean( text ) {
- if ( typeof( text ) === 'string' ) {
- return text.replace( /`/g, '`' + String.fromCharCode( 8203 ) ).replace( /@/g, '@' + String.fromCharCode( 8203 ) );
- } else {
- return text;
- }
- }
- const client = new commando.Client( {
- unknownCommandResponse: settings[ bot ].unknownCommandResponse,
- owner: settings[ bot ].owners
- } );
- client.login( settings[ bot ].token );
- client.on( 'ready', async () => {
- Promise.all( [
- await client.user.setPresence( {
- status: settings[ bot ].status,
- game: {
- name: settings[ bot ].game
- url: 'https://twitch.tv/communities/movember'// For #Movember
- },
- afk: false
- } )
- ] ).then( () => {
- var readyTime = ( new Date() ).toLocaleDateString( 'en-US', timeString );
- console.log( '\n' + readyTime + ':\t' + settings[ bot ].name + ' is now ready to do it\'s thing!\n' ) } );
- } );
- client.on( 'message', async message => {
- if ( message.author !== client.user ) {
- return;
- } else {
- var arrMessage = message.content.split( ' ' );
- const arrCommands = [ 'ack', 'afk', 'clean', 'clear', 'community', 'game', 'host', 'me', 'restart', 'sigh', 'shrug', 'status', 'stream', 'tableflip', 'unflip', 'unhost' ];
- var strCommand = arrMessage[ 0 ].toLowerCase();
- var arrArgs = arrMessage.slice( 1 );
- var strArgs = arrArgs.join( ' ' );
- if (
- strCommand.substr( 0, 1 ) === '.' || (
- strCommand.toUpperCase() === '!CLEAN' ||
- strCommand.toUpperCase() === '!CLEAR'
- ) || (
- strCommand.toUpperCase() === '/ME' ||
- // strCommand.toUpperCase() === '/NICK' ||
- strCommand.toUpperCase() === '/SIGH' ||
- strCommand.toUpperCase() === '/SHRUG' ||
- strCommand.toUpperCase() === '/TABLEFLIP' ||
- // strCommand.toUpperCase() === '/TTS' ||
- strCommand.toUpperCase() === '/UNFLIP'
- ) ) {
- strCommand = strCommand.substr( 1 ).toLowerCase();
- if ( arrCommands.indexOf( strCommand ) !== -1 ) {
- message.delete().then( () => {
- switch ( strCommand ) {
- case 'ack' :
- client.guilds.array().forEach( function( guild ) {
- guild.acknowledge().then( result => { console.log( 'Acknowledged messages in: ' + result.name ); } ).catch( console.error );
- } );
- break;
- case 'afk' :
- if ( arrArgs.length === 1 && arrArgs[ 0 ] === 'off' ) {
- isAFK = false;
- client.user.setPresence( { status: preStreamStatus, game: { name: settings[ bot ].game }, afk: true } );
- client.user.setAFK( false ).catch( );
- message.channel.send( 'I\'m back.' );
- } else {
- Promise.all( [
- preStreamStatus = 'online',//client.user.presence.status;
- client.user.setPresence( { status: 'dnd', game: { name: strArgs }, afk: true } ),
- isAFK = true
- ] ).then( () => {
- var strAfkMessage = 'I\'m AFK';
- if ( !strArgs ) {
- strAfkMessage += '.';
- } else {
- strAfkMessage += ': ' + strArgs;
- }
- message.channel.send( strAfkMessage );
- } );
- }
- break;
- case 'clean' :
- case 'clear' :
- var intMessagesToDelete = ( arrArgs.length === 0 ? 1 : parseInt( arrArgs[ 0 ] ) );
- message.channel.fetchMessages( {
- limit: 100
- } ).then( messages => {
- let arrMessages = messages.array();
- arrMessages = arrMessages.filter( thisMessage => thisMessage.author.id === client.user.id );
- arrMessages.length = intMessagesToDelete;
- arrMessages.map( thisMessage => thisMessage.delete().catch( error => { console.error( error ) } ) );
- } );
- break;
- case 'community' :
- Promise.all( [
- client.user.setPresence( { game: { name: 'support of the ' + arrArgs[ 0 ] + ' community on Twitch.tv', url: 'https://www.twitch.tv/communities/' + arrArgs[ 0 ].toLowerCase() } } ),
- 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!' )
- ] ).then( () => {
- message.author.lastMessage.react( '%F0%9F%8E%A5' ).catch( error => { console.error( error ); } );
- } );
- break;
- case 'game' :
- client.user.setPresence( { game: { name: strArgs } } );
- break;
- case 'host' :
- Promise.all( [
- client.user.setPresence( { game: { name: 'a host of ' + arrArgs[ 0 ], url: 'https://www.twitch.tv/' + arrArgs[ 0 ].toLowerCase() } } ),
- message.channel.send( 'I\'m hosting **' + client.user.presence.game.name.replace( 'a host of ', '' ) + '** on <' + client.user.presence.game.url + '>, check it out!' )
- ] ).then( () => {
- message.author.lastMessage.react( '%F0%9F%8E%A5' ).catch( error => { console.error( error ); } );
- } );
- break;
- case 'me' :
- if ( arrMessage[ 0 ].substr( 0, 1 ) === '.' ) {
- var meContent = 'Here\'s an embed with some information about me:';
- var presenceInfo = client.user;
- if ( !client.user.presence.game || !client.user.presence.game.name ) {
- if ( client.user.presence.status === 'invisible' ) {
- presenceInfo += ' is an enigma.';
- } else {
- presenceInfo += ' is ' + client.user.presence.status;
- }
- } else {
- if ( !client.user.presence.game.url ) {
- presenceInfo += ' is playing **' + ( client.user.presence.game.name ? client.user.presence.game.name : 'a game' ) + '**. :video_game:';
- } else if ( client.user.presence.game.url.indexOf( 'twitch.tv/URL' ) !== -1 ) {
- presenceInfo += ' is streaming **' + client.user.presence.game.name + '** on <https://www.twitch.tv/URL>. :movie_camera:';
- meContent += '\n:link: https://www.twitch.tv/URL';
- } else if ( client.user.presence.game.url.indexOf( 'twitch.tv/communities/' ) !== -1 ) {
- 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:';
- meContent += '\n:link: ' + client.user.presence.game.url;
- } else {
- presenceInfo += ' is hosting [**' + client.user.presence.game.name.replace( 'a host of ', '' ) + '**](' + client.user.presence.game.url + '). :movie_camera:';
- meContent += '\n:link: ' + client.user.presence.game.url;
- }
- }
- var meEmbed = new Discord.RichEmbed()
- .setColor( '#FF00FF' )
- .setThumbnail( 'https://cdn.discordapp.com/attachments/guildID/channelID/Filename.png' )
- .addField( 'Name/ID', client.user + '#' + client.user.discriminator + ' - `' + client.user.id + '`' )
- .addField( 'eMail:', '[' + client.user.email + '](mailto:' + client.user.email + ')' )
- .addField( 'Status:', presenceInfo )
- .addField( 'Stats:',
- '**Join date:**' +
- '\n**Guilds:**' +
- '\n**Friends:**' +
- '\n**Blocked:**',
- true )
- .addField( 'Data:',
- client.user.createdAt.toLocaleDateString( 'en-US', timeString ) +
- '\n' + client.guilds.size +
- '\n' + client.user.friends.array().length +
- '\n' + client.user.blocked.array().length, true )
- .addField( 'Find me on...',
- '[Discord](https://discordapp.com/):' +
- '\n[Github](https://github.com/):' +
- '\n[Twitch](https://twitch.tv/):' +
- '\n[Twitter](https://twitter.com/):' +
- '\n[YouTube](https://youtube.com/):', true )
- .addField( '...link',
- '\n[NAME](https://discord.me/URL)' +
- '\n[NAME](https://github.com/URL)' +
- '\n[NAME](https://twitch.tv/URL)' +
- '\n[NAME](https://twitter.com/URL)' +
- '\n[NAME](https://youtube.com/user/URL)', true )
- .setTimestamp()
- .setFooter( 'About me!', client.user.avatarURL );
- message.channel.send( meContent, { embed: meEmbed } );
- }
- else if ( arrMessage[ 0 ].substr( 0, 1 ) === '/' ) {
- message.channel.send( '_' + strArgs + '_' );
- }
- break;
- case 'restart':
- Promise.all( [
- timeNow = ( new Date() ).toLocaleDateString( 'en-US', timeString ),
- message.client.user.setStatus( 'dnd' )
- ] ).then( () => {
- process.exit( );
- } );
- break;
- case 'shrug':
- message.channel.send( strArgs + ' ¯\_(ツ)_/¯' );
- break;
- case 'sigh':
- message.channel.send( '_sighs..._' );
- break;
- case 'status' :
- client.user.setPresence( { status: arrArgs[ 0 ] } );
- break;
- case 'stream' :
- var strSanitizeURL
- if ( arrArgs[ 0 ].indexOf( /twitch.tv/i ) !== -1 ) {
- strSanitizeURL = 'https://www.twitch.tv' + arrArgs[ 0 ].substr( arrArgs[ 0 ].lastIndexOf( '/') ).toLowerCase();
- } else {
- strSanitizeURL = arrArgs[ 0 ];
- }
- if ( !client.user.presence.game.name ) {
- client.user.setPresence( { game: { name: 'some stupid game or something' } } );
- }
- client.user.setPresence( { game: { url: strSanitizeURL } } );
- message.channel.send( 'I\'m streaming ' + client.user.presence.game.name + ' on <' + client.user.presence.game.url + '>, check it out!' );
- break;
- case 'tableflip':
- message.channel.send( strArgs + ' (╯°□°)╯︵ ┻━┻' );
- break;
- case 'unflip':
- message.channel.send( strArgs + ' ┬─┬ ノ( ゜-゜ノ)' );
- break;
- case 'unhost' :
- Promise.all( [
- message.channel.send( 'I\'m no longer hosting **' + client.user.presence.game.name.replace( 'a host of ', '' ) + '** on <' + client.user.presence.game.url + '>.' )
- ] ).then( () => {
- message.client.user.setGame( settings[ bot ].game ).then( () => {
- message.author.lastMessage.react( '%E2%9C%85' ).catch( error => { console.error( error ) } );
- } ).catch( err => { console.error( err ); } )
- } );
- default :
- }
- } );
- }
- }
- }
- } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement