Merge pull request #229 from brussell98/indev

Added ability to use updateDetails() with token
This commit is contained in:
abalabahaha
2016-03-19 22:44:05 -07:00
2 changed files with 25 additions and 16 deletions

View File

@@ -1236,16 +1236,20 @@ var InternalClient = (function () {
//def updateDetails //def updateDetails
InternalClient.prototype.updateDetails = function updateDetails(data) { InternalClient.prototype.updateDetails = function updateDetails(data) {
if (!this.email && !data.email) { if (!this.bot && !(this.email || data.email)) throw new Error("Must provide email since a token was used to login");
throw new Error("Can't use updateDetails because only a token has been used for login!");
} var options = {
return this.apiRequest("patch", _Constants.Endpoints.ME, true, {
avatar: this.resolver.resolveToBase64(data.avatar) || this.user.avatar, avatar: this.resolver.resolveToBase64(data.avatar) || this.user.avatar,
email: data.email || this.email,
new_password: data.newPassword || null,
password: data.password || this.password,
username: data.username || this.user.username username: data.username || this.user.username
}); };
if (this.email || data.email) {
options.email = data.email || this.email;
options.new_password = data.newPassword || null;
options.password = data.password || this.password;
}
return this.apiRequest("patch", _Constants.Endpoints.ME, true, options);
}; };
//def setAvatar //def setAvatar

View File

@@ -1008,16 +1008,21 @@ export default class InternalClient {
//def updateDetails //def updateDetails
updateDetails(data) { updateDetails(data) {
if (!this.email && !data.email) { if (!this.bot && !(this.email || data.email))
throw new Error("Can't use updateDetails because only a token has been used for login!"); throw new Error("Must provide email since a token was used to login");
}
return this.apiRequest("patch", Endpoints.ME, true, { var options = {
avatar: this.resolver.resolveToBase64(data.avatar) || this.user.avatar, avatar: this.resolver.resolveToBase64(data.avatar) || this.user.avatar,
email: data.email || this.email,
new_password: data.newPassword || null,
password: data.password || this.password,
username: data.username || this.user.username username: data.username || this.user.username
}); }
if (this.email || data.email) {
options.email = data.email || this.email;
options.new_password = data.newPassword || null;
options.password = data.password || this.password;
}
return this.apiRequest("patch", Endpoints.ME, true, options);
} }
//def setAvatar //def setAvatar