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:
oof2win2
2022-01-25 08:34:46 +01:00
committed by GitHub
parent 9a1623425a
commit 5ccdb0ab26
2 changed files with 45 additions and 1 deletions

View File

@@ -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}

View File

@@ -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;
};
}