mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 19:04:44 +12:00
fixed some internal callbacks
This commit is contained in:
parent
1b1d027f1e
commit
73e9e9ec4c
4 changed files with 67 additions and 17 deletions
|
@ -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 ) {
|
||||
|
|
|
@ -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.
|
||||
|
|
4
index.js
4
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 ) {
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue