mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
fixed some internal callbacks
This commit is contained in:
@@ -11,7 +11,7 @@ Commands[ "info" ] = {
|
|||||||
var verbose = hasFlag( params, "verbose" ) || hasFlag( params, "v" );
|
var verbose = hasFlag( params, "verbose" ) || hasFlag( params, "v" );
|
||||||
var user = getUser( message, params );
|
var user = getUser( message, params );
|
||||||
|
|
||||||
console.log("INFO", params);
|
console.log( "INFO", params );
|
||||||
|
|
||||||
bot.reply( message, [
|
bot.reply( message, [
|
||||||
"here's some info on " + user.mention() + ":",
|
"here's some info on " + user.mention() + ":",
|
||||||
@@ -20,13 +20,15 @@ Commands[ "info" ] = {
|
|||||||
),
|
),
|
||||||
"User ID is *" + user.id + "*",
|
"User ID is *" + user.id + "*",
|
||||||
"Authority/OP Level to me is **" + Authority.getLevel( user ) + "**"
|
"Authority/OP Level to me is **" + Authority.getLevel( user ) + "**"
|
||||||
], function(err){
|
], function( err ) {
|
||||||
console.log(err);
|
console.log( err );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Commands[ "" ]
|
||||||
|
|
||||||
Commands[ "echo" ] = {
|
Commands[ "echo" ] = {
|
||||||
oplevel: 0,
|
oplevel: 0,
|
||||||
fn: function( bot, params, message ) {
|
fn: function( bot, params, message ) {
|
||||||
@@ -103,10 +105,9 @@ Commands[ "clear" ] = {
|
|||||||
|
|
||||||
if ( todo === 0 ) {
|
if ( todo === 0 ) {
|
||||||
bot.reply(
|
bot.reply(
|
||||||
msg,
|
message,
|
||||||
"Done! " + deletedCount + " message(s) were deleted, with " + failedCount + " error(s).",
|
"Done! " + deletedCount + " message(s) were deleted, with " + failedCount + " error(s).",
|
||||||
false,
|
false, {
|
||||||
true, {
|
|
||||||
selfDestruct: 5000
|
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" ] = {
|
Commands[ "remind" ] = {
|
||||||
oplevel: 0,
|
oplevel: 0,
|
||||||
fn: function( bot, params, message ) {
|
fn: function( bot, params, message ) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ var time = Date.now();
|
|||||||
// When the bot is ready to go, output to the console
|
// When the bot is ready to go, output to the console
|
||||||
hydrabot.on( "ready", function() {
|
hydrabot.on( "ready", function() {
|
||||||
console.log( "Ready in "+ (Date.now() - time) +"ms!" );
|
console.log( "Ready in "+ (Date.now() - time) +"ms!" );
|
||||||
console.log(hydrabot.PMList);
|
console.log(Commands);
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// When the bot gets disconnected, exit.
|
// 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;
|
channel_id = destination.channel.id;
|
||||||
} else if ( destination instanceof User ) {
|
} else if ( destination instanceof User ) {
|
||||||
var destId = self.PMList.deepFilter( [ "user", "id" ], destination.id, true );
|
var destId = self.PMList.deepFilter( [ "user", "id" ], destination.id, true );
|
||||||
console.log(destId);
|
|
||||||
if ( destId ) {
|
if ( destId ) {
|
||||||
channel_id = destId.id;
|
channel_id = destId.id;
|
||||||
} else {
|
} else {
|
||||||
@@ -530,7 +530,7 @@ exports.Client.prototype.deleteMessage = function( message, callback ) {
|
|||||||
exports.Client.prototype.getChannelLogs = function( channel, amount, callback ) {
|
exports.Client.prototype.getChannelLogs = function( channel, amount, callback ) {
|
||||||
var self = this;
|
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" );
|
var logs = new List( "id" );
|
||||||
for ( message of data ) {
|
for ( message of data ) {
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ Internal.XHR.createInvite = function( token, channelId, options, callback ) {
|
|||||||
.send( options )
|
.send( options )
|
||||||
.end( function( err, res ) {
|
.end( function( err, res ) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
cb( err );
|
callback( err );
|
||||||
} else {
|
} 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 ) {
|
.end( function( err, res ) {
|
||||||
|
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
cb( err );
|
callback( err );
|
||||||
} else {
|
} 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 ) {
|
.end( function( err, res ) {
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
cb( err );
|
callback( err );
|
||||||
} else {
|
} else {
|
||||||
cb( null, res.body );
|
callback( null, res.body );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@@ -201,9 +201,9 @@ Internal.XHR.getServer = function( token, serverID, callback ) {
|
|||||||
.end( function( err, res ) {
|
.end( function( err, res ) {
|
||||||
|
|
||||||
if ( err ) {
|
if ( err ) {
|
||||||
cb( err );
|
callback( err );
|
||||||
} else {
|
} else {
|
||||||
cb( null, res.body );
|
callback( null, res.body );
|
||||||
}
|
}
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|||||||
Reference in New Issue
Block a user