mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(minor): add application_id to Webhook (#7317)
Co-authored-by: Casper <53900565+Dev-CasperTheGhost@users.noreply.github.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: Almeida <almeidx@pm.me> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -85,6 +85,16 @@ class Webhook {
|
||||
this.owner ??= null;
|
||||
}
|
||||
|
||||
if ('application_id' in data) {
|
||||
/**
|
||||
* The application that created this webhook
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.applicationId = data.application_id;
|
||||
} else {
|
||||
this.applicationId ??= null;
|
||||
}
|
||||
|
||||
if ('source_guild' in data) {
|
||||
/**
|
||||
* The source guild of the webhook
|
||||
@@ -393,6 +403,22 @@ class Webhook {
|
||||
return this.avatar && this.client.rest.cdn.Avatar(this.id, this.avatar, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this webhook is created by a user.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isUserCreated() {
|
||||
return Boolean(this.type === WebhookType.Incoming && this.owner && !this.owner.bot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this webhook is created by an application.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isApplicationCreated() {
|
||||
return this.type === WebhookType.Application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this webhook is a channel follower webhook.
|
||||
* @returns {boolean}
|
||||
|
||||
20
packages/discord.js/typings/index.d.ts
vendored
20
packages/discord.js/typings/index.d.ts
vendored
@@ -2417,10 +2417,28 @@ export class Webhook extends WebhookMixin() {
|
||||
public sourceChannel: NewsChannel | APIPartialChannel | null;
|
||||
public token: string | null;
|
||||
public type: WebhookType;
|
||||
public isIncoming(): this is this & { token: string };
|
||||
public applicationId: Snowflake | null;
|
||||
public isUserCreated(): this is this & {
|
||||
type: WebhookType.Incoming;
|
||||
applicationId: null;
|
||||
owner: User | APIUser;
|
||||
};
|
||||
public isApplicationCreated(): this is this & {
|
||||
type: WebhookType.Application;
|
||||
applicationId: Snowflake;
|
||||
owner: User | APIUser;
|
||||
};
|
||||
public isIncoming(): this is this & {
|
||||
type: WebhookType.Incoming;
|
||||
token: string;
|
||||
};
|
||||
public isChannelFollower(): this is this & {
|
||||
type: WebhookType.ChannelFollower;
|
||||
sourceGuild: Guild | APIPartialGuild;
|
||||
sourceChannel: NewsChannel | APIPartialChannel;
|
||||
token: null;
|
||||
applicationId: null;
|
||||
owner: User | APIUser;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user