Skip to content

Commit 9ec76f0

Browse files
Merge branch 'main' into fix/brokers-script
2 parents 99715c7 + 53d8e87 commit 9ec76f0

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

packages/discord.js/src/client/Client.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,7 @@ class Client extends BaseClient {
214214
if (!token || typeof token !== 'string') throw new DiscordjsError(ErrorCodes.TokenInvalid);
215215
this.token = token = token.replace(/^(Bot|Bearer)\s*/i, '');
216216
this.rest.setToken(token);
217-
this.emit(
218-
Events.Debug,
219-
`Provided token: ${token
220-
.split('.')
221-
.map((val, i) => (i > 1 ? val.replace(/./g, '*') : val))
222-
.join('.')}`,
223-
);
217+
this.emit(Events.Debug, `Provided token: ${this._censoredToken}`);
224218

225219
if (this.options.presence) {
226220
this.options.ws.presence = this.presence._parse(this.options.presence);
@@ -459,6 +453,21 @@ class Client extends BaseClient {
459453
});
460454
}
461455

456+
/**
457+
* Partially censored client token for debug logging purposes.
458+
* @type {?string}
459+
* @readonly
460+
* @private
461+
*/
462+
get _censoredToken() {
463+
if (!this.token) return null;
464+
465+
return this.token
466+
.split('.')
467+
.map((val, i) => (i > 1 ? val.replace(/./g, '*') : val))
468+
.join('.');
469+
}
470+
462471
/**
463472
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval} on a script
464473
* with the client as `this`.

packages/discord.js/src/client/websocket/WebSocketShard.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,12 @@ class WebSocketShard extends EventEmitter {
740740
*/
741741
_send(data) {
742742
if (this.connection?.readyState !== WebSocket.OPEN) {
743-
this.debug(`Tried to send packet '${JSON.stringify(data)}' but no WebSocket is available!`);
743+
this.debug(
744+
`Tried to send packet '${JSON.stringify(data).replaceAll(
745+
this.manager.client.token,
746+
this.manager.client._censoredToken,
747+
)}' but no WebSocket is available!`,
748+
);
744749
this.destroy({ closeCode: 4_000 });
745750
return;
746751
}

packages/discord.js/src/errors/ErrorCodes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
* @property {'InteractionAlreadyReplied'} InteractionAlreadyReplied
129129
* @property {'InteractionNotReplied'} InteractionNotReplied
130130
* @property {'InteractionEphemeralReplied'} InteractionEphemeralReplied
131+
* <warn>This property is deprecated.</warn>
131132
132133
* @property {'CommandInteractionOptionNotFound'} CommandInteractionOptionNotFound
133134
* @property {'CommandInteractionOptionType'} CommandInteractionOptionType

packages/discord.js/src/structures/interfaces/InteractionResponses.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ class InteractionResponses {
164164
* .catch(console.error);
165165
*/
166166
async deleteReply() {
167-
if (this.ephemeral) throw new DiscordjsError(ErrorCodes.InteractionEphemeralReplied);
168167
await this.webhook.deleteMessage('@original');
169168
}
170169

packages/discord.js/typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
766766
private presence: ClientPresence;
767767
private _eval(script: string): unknown;
768768
private _validateOptions(options: ClientOptions): void;
769+
private get _censoredToken(): string | null;
769770

770771
public application: If<Ready, ClientApplication>;
771772
public channels: ChannelManager;
@@ -3246,6 +3247,7 @@ export enum DiscordjsErrorCodes {
32463247

32473248
InteractionAlreadyReplied = 'InteractionAlreadyReplied',
32483249
InteractionNotReplied = 'InteractionNotReplied',
3250+
/** @deprecated */
32493251
InteractionEphemeralReplied = 'InteractionEphemeralReplied',
32503252

32513253
CommandInteractionOptionNotFound = 'CommandInteractionOptionNotFound',

packages/rest/src/lib/handlers/SequentialHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class SequentialHandler implements IHandler {
137137
* @param time - The amount of time to delay all requests for
138138
*/
139139
private async globalDelayFor(time: number): Promise<void> {
140-
await sleep(time, undefined, { ref: false });
140+
await sleep(time);
141141
this.manager.globalDelay = null;
142142
}
143143

@@ -460,7 +460,7 @@ export class SequentialHandler implements IHandler {
460460

461461
this.#sublimitPromise?.resolve();
462462
this.#sublimitPromise = null;
463-
await sleep(sublimitTimeout, undefined, { ref: false });
463+
await sleep(sublimitTimeout);
464464
let resolve: () => void;
465465
// eslint-disable-next-line promise/param-names, no-promise-executor-return
466466
const promise = new Promise<void>((res) => (resolve = res));

0 commit comments

Comments
 (0)