mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Added file sending
This commit is contained in:
@@ -124,6 +124,22 @@ Internal.XHR.sendMessage = function( token, channelID, messageParameters, callba
|
||||
|
||||
}
|
||||
|
||||
Internal.XHR.sendFile = function( token, channelID, file, fileName, callback ) {
|
||||
request
|
||||
.post( Endpoints.CHANNELS + "/" + channelID + "/messages" )
|
||||
.set( "authorization", token )
|
||||
.attach("file", file, fileName)
|
||||
.end( function( err, res ) {
|
||||
|
||||
if ( err ) {
|
||||
callback( err );
|
||||
} else {
|
||||
callback( null, res.body );
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
Internal.XHR.deleteMessage = function( token, channelID, messageID, callback ) {
|
||||
request
|
||||
.del( Endpoints.CHANNELS + "/" + channelID + "/messages/" + messageID )
|
||||
@@ -133,19 +149,19 @@ Internal.XHR.deleteMessage = function( token, channelID, messageID, callback ) {
|
||||
} );
|
||||
}
|
||||
|
||||
Internal.XHR.updateMessage = function( token, channelID, messageID, messageParameters, 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 );
|
||||
}
|
||||
});
|
||||
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 ) {
|
||||
@@ -225,36 +241,36 @@ Internal.XHR.getServer = function( token, serverID, callback ) {
|
||||
|
||||
}
|
||||
|
||||
Internal.XHR.acceptInvite = function(token, inviteID, callback){
|
||||
Internal.XHR.acceptInvite = function( token, inviteID, callback ) {
|
||||
|
||||
request
|
||||
.post( Endpoints.API + "/invite/" + inviteID )
|
||||
.set( "authorization", token )
|
||||
.end(function(err, res){
|
||||
if(err){
|
||||
callback(err);
|
||||
}else{
|
||||
callback(null, res.body)
|
||||
.end( function( err, res ) {
|
||||
if ( err ) {
|
||||
callback( err );
|
||||
} else {
|
||||
callback( null, res.body )
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
Internal.XHR.setUsername = function(token, avatar, email, newPassword, password, username, callback){
|
||||
Internal.XHR.setUsername = function( token, avatar, email, newPassword, password, username, callback ) {
|
||||
|
||||
request
|
||||
.patch(Endpoints.API + "/users/@me")
|
||||
.patch( Endpoints.API + "/users/@me" )
|
||||
.set( "authorization", token )
|
||||
.send({
|
||||
avatar : avatar,
|
||||
email : email,
|
||||
new_password : newPassword,
|
||||
password : password,
|
||||
username : username
|
||||
})
|
||||
.end(function(err){
|
||||
callback(err);
|
||||
});
|
||||
.send( {
|
||||
avatar: avatar,
|
||||
email: email,
|
||||
new_password: newPassword,
|
||||
password: password,
|
||||
username: username
|
||||
} )
|
||||
.end( function( err ) {
|
||||
callback( err );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user