mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
feat(Message): add 'failIfNotExists' to ClientOptions (#6038)
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
@@ -508,6 +508,9 @@ class Client extends BaseClient {
|
|||||||
if (typeof options.retryLimit !== 'number' || isNaN(options.retryLimit)) {
|
if (typeof options.retryLimit !== 'number' || isNaN(options.retryLimit)) {
|
||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'retryLimit', 'a number');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'retryLimit', 'a number');
|
||||||
}
|
}
|
||||||
|
if (typeof options.failIfNotExists !== 'boolean') {
|
||||||
|
throw new TypeError('CLIENT_INVALID_OPTION', 'failIfNotExists', 'a boolean');
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
typeof options.rejectOnRateLimit !== 'undefined' &&
|
typeof options.rejectOnRateLimit !== 'undefined' &&
|
||||||
!(typeof options.rejectOnRateLimit === 'function' || Array.isArray(options.rejectOnRateLimit))
|
!(typeof options.rejectOnRateLimit === 'function' || Array.isArray(options.rejectOnRateLimit))
|
||||||
|
|||||||
@@ -697,7 +697,7 @@ class Message extends Base {
|
|||||||
data = MessagePayload.create(this, options, {
|
data = MessagePayload.create(this, options, {
|
||||||
reply: {
|
reply: {
|
||||||
messageReference: this,
|
messageReference: this,
|
||||||
failIfNotExists: options?.failIfNotExists ?? true,
|
failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class MessagePayload {
|
|||||||
if (message_id) {
|
if (message_id) {
|
||||||
message_reference = {
|
message_reference = {
|
||||||
message_id,
|
message_id,
|
||||||
fail_if_not_exists: this.options.reply.failIfNotExists ?? true,
|
fail_if_not_exists: this.options.reply.failIfNotExists ?? this.target.client.options.failIfNotExists,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
* route starting with /channels, such as /channels/222197033908436994/messages) or a function returning true, a
|
* route starting with /channels, such as /channels/222197033908436994/messages) or a function returning true, a
|
||||||
* {@link RateLimitError} will be thrown. Otherwise the request will be queued for later
|
* {@link RateLimitError} will be thrown. Otherwise the request will be queued for later
|
||||||
* @property {number} [retryLimit=1] How many times to retry on 5XX errors (Infinity for indefinite amount of retries)
|
* @property {number} [retryLimit=1] How many times to retry on 5XX errors (Infinity for indefinite amount of retries)
|
||||||
|
* @property {boolean} [failIfNotExists=true] Default value for {@link ReplyMessageOptions#failIfNotExists}
|
||||||
* @property {PresenceData} [presence={}] Presence data to use upon login
|
* @property {PresenceData} [presence={}] Presence data to use upon login
|
||||||
* @property {IntentsResolvable} intents Intents to enable for this connection
|
* @property {IntentsResolvable} intents Intents to enable for this connection
|
||||||
* @property {WebsocketOptions} [ws] Options for the WebSocket
|
* @property {WebsocketOptions} [ws] Options for the WebSocket
|
||||||
@@ -108,6 +109,7 @@ class Options extends null {
|
|||||||
retryLimit: 1,
|
retryLimit: 1,
|
||||||
restTimeOffset: 500,
|
restTimeOffset: 500,
|
||||||
restSweepInterval: 60,
|
restSweepInterval: 60,
|
||||||
|
failIfNotExists: true,
|
||||||
presence: {},
|
presence: {},
|
||||||
ws: {
|
ws: {
|
||||||
large_threshold: 50,
|
large_threshold: 50,
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -2983,6 +2983,7 @@ export interface ClientOptions {
|
|||||||
restGlobalRateLimit?: number;
|
restGlobalRateLimit?: number;
|
||||||
restSweepInterval?: number;
|
restSweepInterval?: number;
|
||||||
retryLimit?: number;
|
retryLimit?: number;
|
||||||
|
failIfNotExists?: boolean;
|
||||||
presence?: PresenceData;
|
presence?: PresenceData;
|
||||||
intents: BitFieldResolvable<IntentsString, number>;
|
intents: BitFieldResolvable<IntentsString, number>;
|
||||||
ws?: WebSocketOptions;
|
ws?: WebSocketOptions;
|
||||||
|
|||||||
Reference in New Issue
Block a user