mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user