Backporting, doc/bug fixes as well deprecation (#1826)

* Backporting, doc/bug fixes as well deprecation

* Adress issue with not resettable icons/images
This commit is contained in:
SpaceEEC
2017-08-25 15:14:05 +02:00
committed by Crawl
parent bce5b677ad
commit 1fe201ae90
19 changed files with 125 additions and 89 deletions

View File

@@ -178,7 +178,7 @@ class ClientDataResolver {
/**
* Resolves a Base64Resolvable, a string, or a BufferResolvable to a Base 64 image.
* @param {BufferResolvable|Base64Resolvable} image The image to be resolved
* @returns {Promise<string>}
* @returns {Promise<?string>}
*/
resolveImage(image) {
if (!image) return Promise.resolve(null);

View File

@@ -285,6 +285,11 @@ class RESTMethods {
.then(() => channel);
}
removeUserFromGroupDM(channel, userId) {
return this.rest.makeRequest('delete', Endpoints.Channel(channel).Recipient(userId), true)
.then(() => channel);
}
updateGroupDMChannel(channel, _data) {
const data = {};
data.name = _data.name;
@@ -298,13 +303,14 @@ class RESTMethods {
);
}
deleteChannel(channel) {
deleteChannel(channel, reason) {
if (channel instanceof User || channel instanceof GuildMember) channel = this.getExistingDM(channel);
if (!channel) return Promise.reject(new Error('No channel to delete.'));
return this.rest.makeRequest('delete', Endpoints.Channel(channel), true).then(data => {
data.id = channel.id;
return this.client.actions.ChannelDelete.handle(data).channel;
});
return this.rest.makeRequest('delete', Endpoints.Channel(channel), true, undefined, undefined, reason)
.then(data => {
data.id = channel.id;
return this.client.actions.ChannelDelete.handle(data).channel;
});
}
updateChannel(channel, _data, reason) {
@@ -369,7 +375,7 @@ class RESTMethods {
const user = this.client.user;
const data = {};
data.username = _data.username || user.username;
data.avatar = this.client.resolver.resolveBase64(_data.avatar) || user.avatar;
data.avatar = typeof _data.avatar === 'undefined' ? user.avatar : this.client.resolver.resolveBase64(_data.avatar);
if (!user.bot) {
data.email = _data.email || user.email;
data.password = password;
@@ -639,6 +645,7 @@ class RESTMethods {
payload.temporary = options.temporary;
payload.max_age = options.maxAge;
payload.max_uses = options.maxUses;
payload.unique = options.unique;
return this.rest.makeRequest('post', Endpoints.Channel(channel).invites, true, payload, undefined, reason)
.then(invite => new Invite(this.client, invite));
}

View File

@@ -14,7 +14,7 @@ class ResumedHandler extends AbstractHandler {
const replayed = ws.sequence - ws.closeSequence;
ws.debug(`RESUMED ${ws._trace.join(' -> ')} | replayed ${replayed} events.`);
client.emit('resume', replayed);
client.emit(Constants.Events.RESUME, replayed);
ws.heartbeat();
}
}