mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: re-emit REST debug logs (#10782)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const { REST } = require('@discordjs/rest');
|
||||
const { REST, RESTEvents } = require('@discordjs/rest');
|
||||
const { AsyncEventEmitter } = require('@vladfrangu/async_event_emitter');
|
||||
const { Routes } = require('discord-api-types/v10');
|
||||
const { DiscordjsTypeError, ErrorCodes } = require('../errors/index.js');
|
||||
const { Events } = require('../util/Events.js');
|
||||
const { Options } = require('../util/Options.js');
|
||||
const { flatten } = require('../util/Util.js');
|
||||
|
||||
@@ -53,6 +54,8 @@ class BaseClient extends AsyncEventEmitter {
|
||||
* @type {REST}
|
||||
*/
|
||||
this.rest = new REST(this.options.rest);
|
||||
|
||||
this.rest.on(RESTEvents.Debug, message => this.emit(Events.Debug, message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,7 +115,7 @@ export class REST extends AsyncEventEmitter<RestEvents> {
|
||||
sweptHashes.set(key, val);
|
||||
|
||||
// Emit debug information
|
||||
this.emit(RESTEvents.Debug, `Hash ${val.value} for ${key} swept due to lifetime being exceeded`);
|
||||
this.emit(RESTEvents.Debug, `[REST] Hash ${val.value} for ${key} swept due to lifetime being exceeded`);
|
||||
}
|
||||
|
||||
return shouldSweep;
|
||||
@@ -140,7 +140,7 @@ export class REST extends AsyncEventEmitter<RestEvents> {
|
||||
// Collect inactive handlers
|
||||
if (inactive) {
|
||||
sweptHandlers.set(key, val);
|
||||
this.emit(RESTEvents.Debug, `Handler ${val.id} for ${key} swept due to being inactive`);
|
||||
this.emit(RESTEvents.Debug, `[REST] Handler ${val.id} for ${key} swept due to being inactive`);
|
||||
}
|
||||
|
||||
return inactive;
|
||||
|
||||
Reference in New Issue
Block a user