mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
added updating of messages
This commit is contained in:
@@ -133,6 +133,21 @@ Internal.XHR.deleteMessage = function( token, channelID, messageID, callback ) {
|
||||
} );
|
||||
}
|
||||
|
||||
Internal.XHR.updateMessage = function( token, channelID, messageID, messageParameters, callback ){
|
||||
|
||||
request
|
||||
.patch(Endpoints.CHANNELS + "/" + channelID + "/messages/" + messageID)
|
||||
.set( "authorization", token )
|
||||
.send( messageParameters )
|
||||
.end(function(err, res){
|
||||
if ( err ) {
|
||||
callback( err );
|
||||
} else {
|
||||
callback( null, res.body );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Internal.XHR.getChannelLogs = function( token, channelID, amount, callback ) {
|
||||
request
|
||||
.get( Endpoints.CHANNELS + "/" + channelID + "/messages?limit=" + amount )
|
||||
|
||||
30
lib/list.js
30
lib/list.js
@@ -34,6 +34,22 @@ exports.List.prototype.length = function() {
|
||||
return this.contents.length;
|
||||
}
|
||||
|
||||
exports.List.prototype.getIndex = function( object ){
|
||||
|
||||
var index = false;
|
||||
|
||||
for(elementIndex in this.contents){
|
||||
var element = this.contents[elementIndex];
|
||||
if( element[this.discriminator] == object[this.discriminator] ){
|
||||
return elementIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
}
|
||||
|
||||
exports.List.prototype.removeIndex = function( index ) {
|
||||
this.contents.splice( index, 1 );
|
||||
}
|
||||
@@ -50,6 +66,20 @@ exports.List.prototype.removeElement = function( child ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
exports.List.prototype.updateElement = function( child, newChild ){
|
||||
|
||||
for ( _element in this.contents ) {
|
||||
var element = this.contents[_element];
|
||||
if ( child[ this.discriminator ] == element[ this.discriminator ] ) {
|
||||
this.contents[_element] = newChild;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
exports.List.prototype.concatSublists = function( whereList, discriminator ) {
|
||||
//this is meant to look at the contents, and assuming the contents are all lists, concatenate their values.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user