discord.js 15.0.0-dev.1762951248-e8217e335 → 15.0.0-dev.1763078518-9f18cb212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/src/errors/ErrorCodes.js +0 -2
- package/src/errors/Messages.js +0 -1
- package/src/index.js +0 -1
- package/src/structures/GuildMember.js +1 -1
- package/src/structures/MessagePayload.js +3 -4
- package/src/structures/PermissionOverwrites.js +1 -1
- package/src/structures/Role.js +1 -1
- package/src/structures/ThreadChannel.js +1 -1
- package/src/structures/Webhook.js +6 -11
- package/src/util/Util.js +9 -1
- package/typings/index.d.mts +12 -37
- package/typings/index.d.ts +12 -37
- package/src/client/WebhookClient.js +0 -119
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "discord.js",
|
|
4
|
-
"version": "15.0.0-dev.
|
|
4
|
+
"version": "15.0.0-dev.1763078518-9f18cb212",
|
|
5
5
|
"description": "A powerful library for interacting with the Discord API",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./typings/index.d.ts",
|
|
@@ -61,12 +61,12 @@
|
|
|
61
61
|
"magic-bytes.js": "^1.12.1",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
63
|
"undici": "7.16.0",
|
|
64
|
-
"@discordjs/
|
|
65
|
-
"@discordjs/
|
|
66
|
-
"@discordjs/rest": "3.0.0-dev.
|
|
67
|
-
"@discordjs/
|
|
68
|
-
"@discordjs/
|
|
69
|
-
"@discordjs/
|
|
64
|
+
"@discordjs/collection": "3.0.0-dev.1763078518-9f18cb212",
|
|
65
|
+
"@discordjs/builders": "2.0.0-dev.1763078518-9f18cb212",
|
|
66
|
+
"@discordjs/rest": "3.0.0-dev.1763078518-9f18cb212",
|
|
67
|
+
"@discordjs/formatters": "1.0.0-dev.1763078518-9f18cb212",
|
|
68
|
+
"@discordjs/ws": "3.0.0-dev.1763078518-9f18cb212",
|
|
69
|
+
"@discordjs/util": "2.0.0-dev.1763078518-9f18cb212"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@favware/cliff-jumper": "^4.1.0",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"turbo": "^2.5.8",
|
|
84
84
|
"typescript": "~5.9.3",
|
|
85
85
|
"@discordjs/api-extractor": "7.52.7",
|
|
86
|
-
"@discordjs/
|
|
87
|
-
"@discordjs/
|
|
86
|
+
"@discordjs/scripts": "0.1.0",
|
|
87
|
+
"@discordjs/docgen": "0.12.1"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=22.12.0"
|
package/src/errors/ErrorCodes.js
CHANGED
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
*
|
|
78
78
|
* @property {'WebhookMessage'} WebhookMessage
|
|
79
79
|
* @property {'WebhookTokenUnavailable'} WebhookTokenUnavailable
|
|
80
|
-
* @property {'WebhookURLInvalid'} WebhookURLInvalid
|
|
81
80
|
* @property {'WebhookApplication'} WebhookApplication
|
|
82
81
|
*
|
|
83
82
|
* @property {'MessageReferenceMissing'} MessageReferenceMissing
|
|
@@ -212,7 +211,6 @@ const keys = [
|
|
|
212
211
|
|
|
213
212
|
'WebhookMessage',
|
|
214
213
|
'WebhookTokenUnavailable',
|
|
215
|
-
'WebhookURLInvalid',
|
|
216
214
|
'WebhookApplication',
|
|
217
215
|
|
|
218
216
|
'MessageReferenceMissing',
|
package/src/errors/Messages.js
CHANGED
|
@@ -82,7 +82,6 @@ const Messages = {
|
|
|
82
82
|
|
|
83
83
|
[ErrorCodes.WebhookMessage]: 'The message was not sent by a webhook.',
|
|
84
84
|
[ErrorCodes.WebhookTokenUnavailable]: 'This action requires a webhook token, but none is available.',
|
|
85
|
-
[ErrorCodes.WebhookURLInvalid]: 'The provided webhook URL is not valid.',
|
|
86
85
|
[ErrorCodes.WebhookApplication]: 'This message webhook belongs to an application and cannot be fetched.',
|
|
87
86
|
|
|
88
87
|
[ErrorCodes.MessageReferenceMissing]: 'The message does not reference another message',
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.Client = require('./client/Client.js').Client;
|
|
|
8
8
|
exports.Shard = require('./sharding/Shard.js').Shard;
|
|
9
9
|
exports.ShardClientUtil = require('./sharding/ShardClientUtil.js').ShardClientUtil;
|
|
10
10
|
exports.ShardingManager = require('./sharding/ShardingManager.js').ShardingManager;
|
|
11
|
-
exports.WebhookClient = require('./client/WebhookClient.js').WebhookClient;
|
|
12
11
|
|
|
13
12
|
// Errors
|
|
14
13
|
exports.DiscordjsError = require('./errors/DJSError.js').DiscordjsError;
|
|
@@ -47,15 +47,14 @@ class MessagePayload {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Whether or not the target is a {@link Webhook}
|
|
50
|
+
* Whether or not the target is a {@link Webhook}
|
|
51
51
|
*
|
|
52
52
|
* @type {boolean}
|
|
53
53
|
* @readonly
|
|
54
54
|
*/
|
|
55
55
|
get isWebhook() {
|
|
56
56
|
const { Webhook } = require('./Webhook.js');
|
|
57
|
-
|
|
58
|
-
return this.target instanceof Webhook || this.target instanceof WebhookClient;
|
|
57
|
+
return this.target instanceof Webhook;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
/**
|
|
@@ -302,7 +301,7 @@ exports.MessagePayload = MessagePayload;
|
|
|
302
301
|
/**
|
|
303
302
|
* A target for a message.
|
|
304
303
|
*
|
|
305
|
-
* @typedef {TextBasedChannels|ChannelManager|Webhook|
|
|
304
|
+
* @typedef {TextBasedChannels|ChannelManager|Webhook|BaseInteraction|InteractionWebhook|
|
|
306
305
|
* Message|MessageManager} MessageTarget
|
|
307
306
|
*/
|
|
308
307
|
|
package/src/structures/Role.js
CHANGED
|
@@ -23,7 +23,7 @@ class Webhook {
|
|
|
23
23
|
* @readonly
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(this, 'client', { value: client });
|
|
26
|
-
|
|
26
|
+
this._patch(data);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
_patch(data) {
|
|
@@ -95,9 +95,9 @@ class Webhook {
|
|
|
95
95
|
/**
|
|
96
96
|
* The owner of the webhook
|
|
97
97
|
*
|
|
98
|
-
* @type {?
|
|
98
|
+
* @type {?User}
|
|
99
99
|
*/
|
|
100
|
-
this.owner = this.client.users
|
|
100
|
+
this.owner = this.client.users._add(data.user);
|
|
101
101
|
} else {
|
|
102
102
|
this.owner ??= null;
|
|
103
103
|
}
|
|
@@ -119,7 +119,7 @@ class Webhook {
|
|
|
119
119
|
*
|
|
120
120
|
* @type {?(Guild|APIGuild)}
|
|
121
121
|
*/
|
|
122
|
-
this.sourceGuild = this.client.guilds
|
|
122
|
+
this.sourceGuild = this.client.guilds.cache.get(data.source_guild.id) ?? data.source_guild;
|
|
123
123
|
} else {
|
|
124
124
|
this.sourceGuild ??= null;
|
|
125
125
|
}
|
|
@@ -130,7 +130,7 @@ class Webhook {
|
|
|
130
130
|
*
|
|
131
131
|
* @type {?(AnnouncementChannel|APIChannel)}
|
|
132
132
|
*/
|
|
133
|
-
this.sourceChannel = this.client.channels
|
|
133
|
+
this.sourceChannel = this.client.channels.cache.get(data.source_channel?.id) ?? data.source_channel;
|
|
134
134
|
} else {
|
|
135
135
|
this.sourceChannel ??= null;
|
|
136
136
|
}
|
|
@@ -248,7 +248,6 @@ class Webhook {
|
|
|
248
248
|
auth: false,
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
-
if (!this.client.channels) return data;
|
|
252
251
|
return (
|
|
253
252
|
this.client.channels.cache.get(data.channel_id)?.messages._add(data, false) ??
|
|
254
253
|
new (getMessage())(this.client, data)
|
|
@@ -345,7 +344,6 @@ class Webhook {
|
|
|
345
344
|
auth: false,
|
|
346
345
|
});
|
|
347
346
|
|
|
348
|
-
if (!this.client.channels) return data;
|
|
349
347
|
return (
|
|
350
348
|
this.client.channels.cache.get(data.channel_id)?.messages._add(data, false) ??
|
|
351
349
|
new (getMessage())(this.client, data)
|
|
@@ -384,10 +382,7 @@ class Webhook {
|
|
|
384
382
|
},
|
|
385
383
|
);
|
|
386
384
|
|
|
387
|
-
const
|
|
388
|
-
if (!channelManager) return data;
|
|
389
|
-
|
|
390
|
-
const messageManager = channelManager.cache.get(data.channel_id)?.messages;
|
|
385
|
+
const messageManager = this.client.channels.cache.get(data.channel_id)?.messages;
|
|
391
386
|
if (!messageManager) return new (getMessage())(this.client, data);
|
|
392
387
|
|
|
393
388
|
const existing = messageManager.cache.get(data.id);
|
package/src/util/Util.js
CHANGED
|
@@ -469,11 +469,19 @@ function cleanCodeBlockContent(text) {
|
|
|
469
469
|
return text.replaceAll('```', '`\u200B``');
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Represents the credentials used for a webhook in the form of its id and token.
|
|
474
|
+
*
|
|
475
|
+
* @typedef {Object} WebhookDataIdWithToken
|
|
476
|
+
* @property {Snowflake} id The webhook's id
|
|
477
|
+
* @property {string} token The webhook's token
|
|
478
|
+
*/
|
|
479
|
+
|
|
472
480
|
/**
|
|
473
481
|
* Parses a webhook URL for the id and token.
|
|
474
482
|
*
|
|
475
483
|
* @param {string} url The URL to parse
|
|
476
|
-
* @returns {?
|
|
484
|
+
* @returns {?WebhookDataIdWithToken} `null` if the URL is invalid, otherwise the id and the token
|
|
477
485
|
*/
|
|
478
486
|
function parseWebhookURL(url) {
|
|
479
487
|
const matches =
|
package/typings/index.d.mts
CHANGED
|
@@ -493,11 +493,11 @@ export abstract class Base {
|
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
export class BaseClient<Events extends {}> extends AsyncEventEmitter<Events> implements AsyncDisposable {
|
|
496
|
-
public constructor(options?: ClientOptions
|
|
496
|
+
public constructor(options?: ClientOptions);
|
|
497
497
|
private decrementMaxListeners(): void;
|
|
498
498
|
private incrementMaxListeners(): void;
|
|
499
499
|
|
|
500
|
-
public options: ClientOptions
|
|
500
|
+
public options: ClientOptions;
|
|
501
501
|
public rest: REST;
|
|
502
502
|
public destroy(): void;
|
|
503
503
|
public toJSON(...props: Record<string, boolean | string>[]): unknown;
|
|
@@ -3525,7 +3525,7 @@ export interface ThreadChannel<ThreadOnly extends boolean = boolean>
|
|
|
3525
3525
|
MessageChannelFields,
|
|
3526
3526
|
SendMethod<true> {}
|
|
3527
3527
|
export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseChannel {
|
|
3528
|
-
private constructor(guild: Guild, data
|
|
3528
|
+
private constructor(guild: Guild, data: RawThreadChannelData, client?: Client<true>);
|
|
3529
3529
|
public archived: boolean | null;
|
|
3530
3530
|
public get archivedAt(): Date | null;
|
|
3531
3531
|
public archiveTimestamp: number | null;
|
|
@@ -3742,7 +3742,7 @@ export function fetchRecommendedShardCount(token: string, options?: FetchRecomme
|
|
|
3742
3742
|
export function flatten(obj: unknown, ...props: Record<string, boolean | string>[]): unknown;
|
|
3743
3743
|
|
|
3744
3744
|
export function parseEmoji(text: string): PartialEmoji | null;
|
|
3745
|
-
export function parseWebhookURL(url: string):
|
|
3745
|
+
export function parseWebhookURL(url: string): WebhookDataIdWithToken | null;
|
|
3746
3746
|
export function resolveColor(color: ColorResolvable): number;
|
|
3747
3747
|
export function resolveSKUId(resolvable: SKUResolvable): Snowflake | null;
|
|
3748
3748
|
export function verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string;
|
|
@@ -3821,14 +3821,14 @@ export class VoiceState extends Base {
|
|
|
3821
3821
|
|
|
3822
3822
|
export interface Webhook<Type extends WebhookType = WebhookType> extends WebhookFields {}
|
|
3823
3823
|
export class Webhook<Type extends WebhookType = WebhookType> {
|
|
3824
|
-
private constructor(client: Client<true>, data
|
|
3824
|
+
private constructor(client: Client<true>, data: unknown);
|
|
3825
3825
|
public avatar: string | null;
|
|
3826
3826
|
public avatarURL(options?: ImageURLOptions): string | null;
|
|
3827
3827
|
public channelId: Snowflake;
|
|
3828
3828
|
public readonly client: Client;
|
|
3829
3829
|
public guildId: Snowflake;
|
|
3830
3830
|
public name: string;
|
|
3831
|
-
public owner: Type extends WebhookType.Incoming ?
|
|
3831
|
+
public owner: Type extends WebhookType.Incoming ? User | null : User;
|
|
3832
3832
|
public sourceGuild: Type extends WebhookType.ChannelFollower ? APIPartialGuild | Guild : null;
|
|
3833
3833
|
public sourceChannel: Type extends WebhookType.ChannelFollower ? AnnouncementChannel | APIPartialChannel : null;
|
|
3834
3834
|
public token: Type extends WebhookType.Incoming
|
|
@@ -3847,7 +3847,7 @@ export class Webhook<Type extends WebhookType = WebhookType> {
|
|
|
3847
3847
|
| VoiceChannel
|
|
3848
3848
|
| null;
|
|
3849
3849
|
public isUserCreated(): this is Webhook<WebhookType.Incoming> & {
|
|
3850
|
-
owner:
|
|
3850
|
+
owner: User;
|
|
3851
3851
|
};
|
|
3852
3852
|
public isApplicationCreated(): this is Webhook<WebhookType.Application>;
|
|
3853
3853
|
public isIncoming(): this is Webhook<WebhookType.Incoming>;
|
|
@@ -3861,20 +3861,6 @@ export class Webhook<Type extends WebhookType = WebhookType> {
|
|
|
3861
3861
|
public send(options: MessagePayload | WebhookMessageCreateOptions | string): Promise<Message<true>>;
|
|
3862
3862
|
}
|
|
3863
3863
|
|
|
3864
|
-
export interface WebhookClient extends WebhookFields, BaseClient<{}> {}
|
|
3865
|
-
export class WebhookClient extends BaseClient<{}> {
|
|
3866
|
-
public constructor(data: WebhookClientData, options?: WebhookClientOptions);
|
|
3867
|
-
public readonly client: this;
|
|
3868
|
-
public options: WebhookClientOptions;
|
|
3869
|
-
public token: string;
|
|
3870
|
-
public editMessage(
|
|
3871
|
-
message: MessageResolvable,
|
|
3872
|
-
options: MessagePayload | WebhookMessageEditOptions | string,
|
|
3873
|
-
): Promise<APIMessage>;
|
|
3874
|
-
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<APIMessage>;
|
|
3875
|
-
public send(options: MessagePayload | WebhookMessageCreateOptions | string): Promise<APIMessage>;
|
|
3876
|
-
}
|
|
3877
|
-
|
|
3878
3864
|
export class Widget extends Base {
|
|
3879
3865
|
private constructor(client: Client<true>, data: APIGuildWidget);
|
|
3880
3866
|
private _patch(data: APIGuildWidget): void;
|
|
@@ -4064,7 +4050,6 @@ export enum DiscordjsErrorCodes {
|
|
|
4064
4050
|
|
|
4065
4051
|
WebhookMessage = 'WebhookMessage',
|
|
4066
4052
|
WebhookTokenUnavailable = 'WebhookTokenUnavailable',
|
|
4067
|
-
WebhookURLInvalid = 'WebhookURLInvalid',
|
|
4068
4053
|
WebhookApplication = 'WebhookApplication',
|
|
4069
4054
|
|
|
4070
4055
|
MessageReferenceMissing = 'MessageReferenceMissing',
|
|
@@ -5576,7 +5561,8 @@ export interface ClientFetchInviteOptions {
|
|
|
5576
5561
|
withCounts?: boolean;
|
|
5577
5562
|
}
|
|
5578
5563
|
|
|
5579
|
-
export interface ClientOptions
|
|
5564
|
+
export interface ClientOptions {
|
|
5565
|
+
allowedMentions?: MessageMentionOptions;
|
|
5580
5566
|
closeTimeout?: number;
|
|
5581
5567
|
enforceNonce?: boolean;
|
|
5582
5568
|
failIfNotExists?: boolean;
|
|
@@ -5585,6 +5571,7 @@ export interface ClientOptions extends WebhookClientOptions {
|
|
|
5585
5571
|
makeCache?: CacheFactory;
|
|
5586
5572
|
partials?: readonly Partials[];
|
|
5587
5573
|
presence?: PresenceData;
|
|
5574
|
+
rest?: Partial<RESTOptions>;
|
|
5588
5575
|
sweepers?: SweeperOptions;
|
|
5589
5576
|
waitGuildTimeout?: number;
|
|
5590
5577
|
ws?: Partial<WebSocketManagerOptions>;
|
|
@@ -6873,8 +6860,7 @@ export type MessageTarget =
|
|
|
6873
6860
|
| Message
|
|
6874
6861
|
| MessageManager
|
|
6875
6862
|
| TextBasedChannel
|
|
6876
|
-
| Webhook<WebhookType.Incoming
|
|
6877
|
-
| WebhookClient;
|
|
6863
|
+
| Webhook<WebhookType.Incoming>;
|
|
6878
6864
|
|
|
6879
6865
|
export interface MultipleShardRespawnOptions {
|
|
6880
6866
|
respawnDelay?: number;
|
|
@@ -7248,22 +7234,11 @@ export interface VoiceStateEditOptions {
|
|
|
7248
7234
|
suppressed?: boolean;
|
|
7249
7235
|
}
|
|
7250
7236
|
|
|
7251
|
-
export
|
|
7252
|
-
|
|
7253
|
-
export interface WebhookClientDataIdWithToken {
|
|
7237
|
+
export interface WebhookDataIdWithToken {
|
|
7254
7238
|
id: Snowflake;
|
|
7255
7239
|
token: string;
|
|
7256
7240
|
}
|
|
7257
7241
|
|
|
7258
|
-
export interface WebhookClientDataURL {
|
|
7259
|
-
url: string;
|
|
7260
|
-
}
|
|
7261
|
-
|
|
7262
|
-
export interface WebhookClientOptions {
|
|
7263
|
-
allowedMentions?: MessageMentionOptions;
|
|
7264
|
-
rest?: Partial<RESTOptions>;
|
|
7265
|
-
}
|
|
7266
|
-
|
|
7267
7242
|
export interface WebhookDeleteOptions {
|
|
7268
7243
|
reason?: string;
|
|
7269
7244
|
token?: string;
|
package/typings/index.d.ts
CHANGED
|
@@ -493,11 +493,11 @@ export abstract class Base {
|
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
export class BaseClient<Events extends {}> extends AsyncEventEmitter<Events> implements AsyncDisposable {
|
|
496
|
-
public constructor(options?: ClientOptions
|
|
496
|
+
public constructor(options?: ClientOptions);
|
|
497
497
|
private decrementMaxListeners(): void;
|
|
498
498
|
private incrementMaxListeners(): void;
|
|
499
499
|
|
|
500
|
-
public options: ClientOptions
|
|
500
|
+
public options: ClientOptions;
|
|
501
501
|
public rest: REST;
|
|
502
502
|
public destroy(): void;
|
|
503
503
|
public toJSON(...props: Record<string, boolean | string>[]): unknown;
|
|
@@ -3525,7 +3525,7 @@ export interface ThreadChannel<ThreadOnly extends boolean = boolean>
|
|
|
3525
3525
|
MessageChannelFields,
|
|
3526
3526
|
SendMethod<true> {}
|
|
3527
3527
|
export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseChannel {
|
|
3528
|
-
private constructor(guild: Guild, data
|
|
3528
|
+
private constructor(guild: Guild, data: RawThreadChannelData, client?: Client<true>);
|
|
3529
3529
|
public archived: boolean | null;
|
|
3530
3530
|
public get archivedAt(): Date | null;
|
|
3531
3531
|
public archiveTimestamp: number | null;
|
|
@@ -3742,7 +3742,7 @@ export function fetchRecommendedShardCount(token: string, options?: FetchRecomme
|
|
|
3742
3742
|
export function flatten(obj: unknown, ...props: Record<string, boolean | string>[]): unknown;
|
|
3743
3743
|
|
|
3744
3744
|
export function parseEmoji(text: string): PartialEmoji | null;
|
|
3745
|
-
export function parseWebhookURL(url: string):
|
|
3745
|
+
export function parseWebhookURL(url: string): WebhookDataIdWithToken | null;
|
|
3746
3746
|
export function resolveColor(color: ColorResolvable): number;
|
|
3747
3747
|
export function resolveSKUId(resolvable: SKUResolvable): Snowflake | null;
|
|
3748
3748
|
export function verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string;
|
|
@@ -3821,14 +3821,14 @@ export class VoiceState extends Base {
|
|
|
3821
3821
|
|
|
3822
3822
|
export interface Webhook<Type extends WebhookType = WebhookType> extends WebhookFields {}
|
|
3823
3823
|
export class Webhook<Type extends WebhookType = WebhookType> {
|
|
3824
|
-
private constructor(client: Client<true>, data
|
|
3824
|
+
private constructor(client: Client<true>, data: unknown);
|
|
3825
3825
|
public avatar: string | null;
|
|
3826
3826
|
public avatarURL(options?: ImageURLOptions): string | null;
|
|
3827
3827
|
public channelId: Snowflake;
|
|
3828
3828
|
public readonly client: Client;
|
|
3829
3829
|
public guildId: Snowflake;
|
|
3830
3830
|
public name: string;
|
|
3831
|
-
public owner: Type extends WebhookType.Incoming ?
|
|
3831
|
+
public owner: Type extends WebhookType.Incoming ? User | null : User;
|
|
3832
3832
|
public sourceGuild: Type extends WebhookType.ChannelFollower ? APIPartialGuild | Guild : null;
|
|
3833
3833
|
public sourceChannel: Type extends WebhookType.ChannelFollower ? AnnouncementChannel | APIPartialChannel : null;
|
|
3834
3834
|
public token: Type extends WebhookType.Incoming
|
|
@@ -3847,7 +3847,7 @@ export class Webhook<Type extends WebhookType = WebhookType> {
|
|
|
3847
3847
|
| VoiceChannel
|
|
3848
3848
|
| null;
|
|
3849
3849
|
public isUserCreated(): this is Webhook<WebhookType.Incoming> & {
|
|
3850
|
-
owner:
|
|
3850
|
+
owner: User;
|
|
3851
3851
|
};
|
|
3852
3852
|
public isApplicationCreated(): this is Webhook<WebhookType.Application>;
|
|
3853
3853
|
public isIncoming(): this is Webhook<WebhookType.Incoming>;
|
|
@@ -3861,20 +3861,6 @@ export class Webhook<Type extends WebhookType = WebhookType> {
|
|
|
3861
3861
|
public send(options: MessagePayload | WebhookMessageCreateOptions | string): Promise<Message<true>>;
|
|
3862
3862
|
}
|
|
3863
3863
|
|
|
3864
|
-
export interface WebhookClient extends WebhookFields, BaseClient<{}> {}
|
|
3865
|
-
export class WebhookClient extends BaseClient<{}> {
|
|
3866
|
-
public constructor(data: WebhookClientData, options?: WebhookClientOptions);
|
|
3867
|
-
public readonly client: this;
|
|
3868
|
-
public options: WebhookClientOptions;
|
|
3869
|
-
public token: string;
|
|
3870
|
-
public editMessage(
|
|
3871
|
-
message: MessageResolvable,
|
|
3872
|
-
options: MessagePayload | WebhookMessageEditOptions | string,
|
|
3873
|
-
): Promise<APIMessage>;
|
|
3874
|
-
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<APIMessage>;
|
|
3875
|
-
public send(options: MessagePayload | WebhookMessageCreateOptions | string): Promise<APIMessage>;
|
|
3876
|
-
}
|
|
3877
|
-
|
|
3878
3864
|
export class Widget extends Base {
|
|
3879
3865
|
private constructor(client: Client<true>, data: APIGuildWidget);
|
|
3880
3866
|
private _patch(data: APIGuildWidget): void;
|
|
@@ -4064,7 +4050,6 @@ export enum DiscordjsErrorCodes {
|
|
|
4064
4050
|
|
|
4065
4051
|
WebhookMessage = 'WebhookMessage',
|
|
4066
4052
|
WebhookTokenUnavailable = 'WebhookTokenUnavailable',
|
|
4067
|
-
WebhookURLInvalid = 'WebhookURLInvalid',
|
|
4068
4053
|
WebhookApplication = 'WebhookApplication',
|
|
4069
4054
|
|
|
4070
4055
|
MessageReferenceMissing = 'MessageReferenceMissing',
|
|
@@ -5576,7 +5561,8 @@ export interface ClientFetchInviteOptions {
|
|
|
5576
5561
|
withCounts?: boolean;
|
|
5577
5562
|
}
|
|
5578
5563
|
|
|
5579
|
-
export interface ClientOptions
|
|
5564
|
+
export interface ClientOptions {
|
|
5565
|
+
allowedMentions?: MessageMentionOptions;
|
|
5580
5566
|
closeTimeout?: number;
|
|
5581
5567
|
enforceNonce?: boolean;
|
|
5582
5568
|
failIfNotExists?: boolean;
|
|
@@ -5585,6 +5571,7 @@ export interface ClientOptions extends WebhookClientOptions {
|
|
|
5585
5571
|
makeCache?: CacheFactory;
|
|
5586
5572
|
partials?: readonly Partials[];
|
|
5587
5573
|
presence?: PresenceData;
|
|
5574
|
+
rest?: Partial<RESTOptions>;
|
|
5588
5575
|
sweepers?: SweeperOptions;
|
|
5589
5576
|
waitGuildTimeout?: number;
|
|
5590
5577
|
ws?: Partial<WebSocketManagerOptions>;
|
|
@@ -6873,8 +6860,7 @@ export type MessageTarget =
|
|
|
6873
6860
|
| Message
|
|
6874
6861
|
| MessageManager
|
|
6875
6862
|
| TextBasedChannel
|
|
6876
|
-
| Webhook<WebhookType.Incoming
|
|
6877
|
-
| WebhookClient;
|
|
6863
|
+
| Webhook<WebhookType.Incoming>;
|
|
6878
6864
|
|
|
6879
6865
|
export interface MultipleShardRespawnOptions {
|
|
6880
6866
|
respawnDelay?: number;
|
|
@@ -7248,22 +7234,11 @@ export interface VoiceStateEditOptions {
|
|
|
7248
7234
|
suppressed?: boolean;
|
|
7249
7235
|
}
|
|
7250
7236
|
|
|
7251
|
-
export
|
|
7252
|
-
|
|
7253
|
-
export interface WebhookClientDataIdWithToken {
|
|
7237
|
+
export interface WebhookDataIdWithToken {
|
|
7254
7238
|
id: Snowflake;
|
|
7255
7239
|
token: string;
|
|
7256
7240
|
}
|
|
7257
7241
|
|
|
7258
|
-
export interface WebhookClientDataURL {
|
|
7259
|
-
url: string;
|
|
7260
|
-
}
|
|
7261
|
-
|
|
7262
|
-
export interface WebhookClientOptions {
|
|
7263
|
-
allowedMentions?: MessageMentionOptions;
|
|
7264
|
-
rest?: Partial<RESTOptions>;
|
|
7265
|
-
}
|
|
7266
|
-
|
|
7267
7242
|
export interface WebhookDeleteOptions {
|
|
7268
7243
|
reason?: string;
|
|
7269
7244
|
token?: string;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { DiscordjsError, ErrorCodes } = require('../errors/index.js');
|
|
4
|
-
const { Webhook } = require('../structures/Webhook.js');
|
|
5
|
-
const { parseWebhookURL } = require('../util/Util.js');
|
|
6
|
-
const { BaseClient } = require('./BaseClient.js');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The webhook client.
|
|
10
|
-
*
|
|
11
|
-
* @implements {Webhook}
|
|
12
|
-
* @extends {BaseClient}
|
|
13
|
-
*/
|
|
14
|
-
class WebhookClient extends BaseClient {
|
|
15
|
-
/**
|
|
16
|
-
* Represents the credentials used for a webhook in the form of its id and token.
|
|
17
|
-
*
|
|
18
|
-
* @typedef {Object} WebhookClientDataIdWithToken
|
|
19
|
-
* @property {Snowflake} id The webhook's id
|
|
20
|
-
* @property {string} token The webhook's token
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Represents the credentials used for a webhook in the form of a URL.
|
|
25
|
-
*
|
|
26
|
-
* @typedef {Object} WebhookClientDataURL
|
|
27
|
-
* @property {string} url The full URL for the webhook
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Represents the credentials used for a webhook.
|
|
32
|
-
*
|
|
33
|
-
* @typedef {WebhookClientDataIdWithToken|WebhookClientDataURL} WebhookClientData
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Options for a webhook client.
|
|
38
|
-
*
|
|
39
|
-
* @typedef {Object} WebhookClientOptions
|
|
40
|
-
* @property {MessageMentionOptions} [allowedMentions] Default value for {@link BaseMessageOptions#allowedMentions}
|
|
41
|
-
* @property {RESTOptions} [rest] Options for the REST manager
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {WebhookClientData} data The data of the webhook
|
|
46
|
-
* @param {WebhookClientOptions} [options] Options for the webhook client
|
|
47
|
-
*/
|
|
48
|
-
constructor(data, options) {
|
|
49
|
-
super(options);
|
|
50
|
-
Object.defineProperty(this, 'client', { value: this });
|
|
51
|
-
let { id, token } = data;
|
|
52
|
-
|
|
53
|
-
if ('url' in data) {
|
|
54
|
-
const parsed = parseWebhookURL(data.url);
|
|
55
|
-
if (!parsed) {
|
|
56
|
-
throw new DiscordjsError(ErrorCodes.WebhookURLInvalid);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
({ id, token } = parsed);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.id = id;
|
|
63
|
-
Object.defineProperty(this, 'token', { value: token, writable: true, configurable: true });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The options the webhook client was instantiated with.
|
|
68
|
-
*
|
|
69
|
-
* @type {WebhookClientOptions}
|
|
70
|
-
* @name WebhookClient#options
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
// These are here only for documentation purposes - they are implemented by Webhook
|
|
74
|
-
|
|
75
|
-
/* eslint-disable jsdoc/check-param-names, getter-return */
|
|
76
|
-
/**
|
|
77
|
-
* Sends a message with this webhook.
|
|
78
|
-
*
|
|
79
|
-
* @param {string|MessagePayload|WebhookMessageCreateOptions} options The content for the reply
|
|
80
|
-
* @returns {Promise<APIMessage>}
|
|
81
|
-
*/
|
|
82
|
-
async send() {}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Gets a message that was sent by this webhook.
|
|
86
|
-
*
|
|
87
|
-
* @param {Snowflake} message The id of the message to fetch
|
|
88
|
-
* @param {WebhookFetchMessageOptions} [options] The options to provide to fetch the message.
|
|
89
|
-
* @returns {Promise<APIMessage>} Returns the message sent by this webhook
|
|
90
|
-
*/
|
|
91
|
-
async fetchMessage() {}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Edits a message that was sent by this webhook.
|
|
95
|
-
*
|
|
96
|
-
* @param {MessageResolvable} message The message to edit
|
|
97
|
-
* @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
|
|
98
|
-
* @returns {Promise<APIMessage>} Returns the message edited by this webhook
|
|
99
|
-
*/
|
|
100
|
-
async editMessage() {}
|
|
101
|
-
|
|
102
|
-
sendSlackMessage() {}
|
|
103
|
-
|
|
104
|
-
edit() {}
|
|
105
|
-
|
|
106
|
-
delete() {}
|
|
107
|
-
|
|
108
|
-
deleteMessage() {}
|
|
109
|
-
|
|
110
|
-
get createdTimestamp() {}
|
|
111
|
-
|
|
112
|
-
get createdAt() {}
|
|
113
|
-
|
|
114
|
-
get url() {}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
Webhook.applyToClass(WebhookClient);
|
|
118
|
-
|
|
119
|
-
exports.WebhookClient = WebhookClient;
|