mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Backports (#1813)
* Backported OAuth2Application201ecd25a2* Backported retry on 50057b6980313* Backportedb8034525e3andfa5c4efa2b
This commit is contained in:
@@ -878,7 +878,8 @@ class RESTMethods {
|
||||
}
|
||||
|
||||
resetApplication(id) {
|
||||
return this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).reset, true)
|
||||
return this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).resetToken, true)
|
||||
.then(() => this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).resetSecret, true))
|
||||
.then(app => new OAuth2Application(this.client, app));
|
||||
}
|
||||
|
||||
@@ -908,6 +909,10 @@ class RESTMethods {
|
||||
patchUserSettings(data) {
|
||||
return this.rest.makeRequest('patch', Constants.Endpoints.User('@me').settings, true, data);
|
||||
}
|
||||
|
||||
patchClientUserGuildSettings(guildID, data) {
|
||||
return this.rest.makeRequest('patch', Constants.Endpoints.User('@me').Guild(guildID).settings, true, data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
||||
@@ -40,6 +40,12 @@ class BurstRequestHandler extends RequestHandler {
|
||||
this.handle();
|
||||
this.resetTimeout = null;
|
||||
}, Number(res.headers['retry-after']) + this.client.options.restTimeOffset);
|
||||
} else if (err.status >= 500 && err.status < 600) {
|
||||
this.queue.unshift(item);
|
||||
this.resetTimeout = this.client.setTimeout(() => {
|
||||
this.handle();
|
||||
this.resetTimeout = null;
|
||||
}, 1e3 + this.client.options.restTimeOffset);
|
||||
} else {
|
||||
item.reject(err.status === 400 ? new DiscordAPIError(res.body) : err);
|
||||
this.handle();
|
||||
|
||||
@@ -64,6 +64,9 @@ class SequentialRequestHandler extends RequestHandler {
|
||||
resolve();
|
||||
}, Number(res.headers['retry-after']) + this.restManager.client.options.restTimeOffset);
|
||||
if (res.headers['x-ratelimit-global']) this.globalLimit = true;
|
||||
} else if (err.status >= 500 && err.status < 600) {
|
||||
this.queue.unshift(item);
|
||||
this.restManager.client.setTimeout(resolve, 1e3 + this.client.options.restTimeOffset);
|
||||
} else {
|
||||
item.reject(err.status >= 400 && err.status < 500 ? new DiscordAPIError(res.body) : err);
|
||||
resolve(err);
|
||||
|
||||
@@ -39,6 +39,7 @@ class WebSocketPacketManager {
|
||||
this.register(Constants.WSEvents.USER_UPDATE, require('./handlers/UserUpdate'));
|
||||
this.register(Constants.WSEvents.USER_NOTE_UPDATE, require('./handlers/UserNoteUpdate'));
|
||||
this.register(Constants.WSEvents.USER_SETTINGS_UPDATE, require('./handlers/UserSettingsUpdate'));
|
||||
this.register(Constants.WSEvents.USER_GUILD_SETTINGS_UPDATE, require('./handlers/UserGuildSettingsUpdate'));
|
||||
this.register(Constants.WSEvents.VOICE_STATE_UPDATE, require('./handlers/VoiceStateUpdate'));
|
||||
this.register(Constants.WSEvents.TYPING_START, require('./handlers/TypingStart'));
|
||||
this.register(Constants.WSEvents.MESSAGE_CREATE, require('./handlers/MessageCreate'));
|
||||
|
||||
@@ -10,6 +10,7 @@ class ReadyHandler extends AbstractHandler {
|
||||
client.ws.heartbeat();
|
||||
|
||||
data.user.user_settings = data.user_settings;
|
||||
data.user.user_guild_settings = data.user_guild_settings;
|
||||
|
||||
const clientUser = new ClientUser(client, data.user);
|
||||
client.user = clientUser;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const AbstractHandler = require('./AbstractHandler');
|
||||
const Constants = require('../../../../util/Constants');
|
||||
|
||||
class UserGuildSettingsUpdateHandler extends AbstractHandler {
|
||||
handle(packet) {
|
||||
const client = this.packetManager.client;
|
||||
client.user.guildSettings.get(packet.d.guild_id).patch(packet.d);
|
||||
client.emit(Constants.Events.USER_GUILD_SETTINGS_UPDATE, client.user.guildSettings.get(packet.d.guild_id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted whenever the client user's settings update.
|
||||
* @event Client#clientUserGuildSettingsUpdate
|
||||
* @param {ClientUserGuildSettings} clientUserGuildSettings The new client user guild settings
|
||||
*/
|
||||
|
||||
module.exports = UserGuildSettingsUpdateHandler;
|
||||
Reference in New Issue
Block a user