diff --git a/hydrabot/commands.js b/hydrabot/commands.js index d40980650..64caa2b03 100644 --- a/hydrabot/commands.js +++ b/hydrabot/commands.js @@ -11,7 +11,7 @@ Commands[ "info" ] = { var verbose = hasFlag( params, "verbose" ) || hasFlag( params, "v" ); var user = getUser( message, params ); - console.log("INFO", params); + console.log( "INFO", params ); bot.reply( message, [ "here's some info on " + user.mention() + ":", @@ -20,13 +20,15 @@ Commands[ "info" ] = { ), "User ID is *" + user.id + "*", "Authority/OP Level to me is **" + Authority.getLevel( user ) + "**" - ], function(err){ - console.log(err); + ], function( err ) { + console.log( err ); } ); } } +Commands[ "" ] + Commands[ "echo" ] = { oplevel: 0, fn: function( bot, params, message ) { @@ -103,10 +105,9 @@ Commands[ "clear" ] = { if ( todo === 0 ) { bot.reply( - msg, + message, "Done! " + deletedCount + " message(s) were deleted, with " + failedCount + " error(s).", - false, - true, { + false, { selfDestruct: 5000 } ); @@ -195,6 +196,55 @@ Commands[ "icon" ] = { } } +Commands[ "feedback" ] = { + + oplevel: 0, + fn: function( bot, params, message ) { + + var amount = getKey( params, "amount" ) || getKey( params, "n" ) || 1000; + + bot.getChannelLogs( message.channel, amount, function( err, logs ) { + + if ( err ) { + bot.reply( message, "an error occurred when grabbing the logs.", false, { + selfDestruct: 3000 + } ); + } else { + + var found = []; + for ( msg of logs.contents ) { + + if ( ~msg.content.indexOf( "[request" ) || ~msg.content.indexOf( "[feature" || ~msg.content.indexOf( "[suggestion") ) ) { + if(msg.content.length > 15){ + found.push( msg ); + } + } + + } + + bot.sendMessage( message.author, "Ok, here's a rundown of all feature requests so far:", function( err, ms ) { + + if (!err) + gothroughit(); + + } ); + + bot.reply( message, "I found " + found.length + " result(s) that matched this. I'll send it to you in a PM." ); + + function gothroughit() { + for ( msg of found ) { + + bot.sendMessage( message.author, "**" + msg.author.username + "** said:\n " + msg.content ); + + } + } + } + } ); + + } + +} + Commands[ "remind" ] = { oplevel: 0, fn: function( bot, params, message ) { diff --git a/hydrabot/hydrabot.js b/hydrabot/hydrabot.js index a15b1b503..9ca7bd106 100644 --- a/hydrabot/hydrabot.js +++ b/hydrabot/hydrabot.js @@ -33,7 +33,7 @@ var time = Date.now(); // When the bot is ready to go, output to the console hydrabot.on( "ready", function() { console.log( "Ready in "+ (Date.now() - time) +"ms!" ); - console.log(hydrabot.PMList); + console.log(Commands); } ); // When the bot gets disconnected, exit. diff --git a/index.js b/index.js index 055e7fbba..0588ec9ac 100644 --- a/index.js +++ b/index.js @@ -465,7 +465,7 @@ exports.Client.prototype.sendMessage = function( destination, toSend, callback, channel_id = destination.channel.id; } else if ( destination instanceof User ) { var destId = self.PMList.deepFilter( [ "user", "id" ], destination.id, true ); - console.log(destId); + if ( destId ) { channel_id = destId.id; } else { @@ -530,7 +530,7 @@ exports.Client.prototype.deleteMessage = function( message, callback ) { exports.Client.prototype.getChannelLogs = function( channel, amount, callback ) { var self = this; - Internal.XHR.getChannelLogs( self.token, message.channel.id, ( amount || 50 ), function( err, data ) { + Internal.XHR.getChannelLogs( self.token, channel.id, ( amount || 50 ), function( err, data ) { var logs = new List( "id" ); for ( message of data ) { diff --git a/lib/internal.js b/lib/internal.js index ec11c3da4..09d83acca 100644 --- a/lib/internal.js +++ b/lib/internal.js @@ -82,9 +82,9 @@ Internal.XHR.createInvite = function( token, channelId, options, callback ) { .send( options ) .end( function( err, res ) { if ( err ) { - cb( err ); + callback( err ); } else { - cb( null, res.body ); + callback( null, res.body ); } } ) } @@ -140,9 +140,9 @@ Internal.XHR.getChannelLogs = function( token, channelID, amount, callback ) { .end( function( err, res ) { if ( err ) { - cb( err ); + callback( err ); } else { - cb( null, res.body ); + callback( null, res.body ); } } ); @@ -158,9 +158,9 @@ Internal.XHR.createChannel = function( token, serverID, name, type, callback ) { } ) .end( function( err, res ) { if ( err ) { - cb( err ); + callback( err ); } else { - cb( null, res.body ); + callback( null, res.body ); } } ); } @@ -201,9 +201,9 @@ Internal.XHR.getServer = function( token, serverID, callback ) { .end( function( err, res ) { if ( err ) { - cb( err ); + callback( err ); } else { - cb( null, res.body ); + callback( null, res.body ); } } );