mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
feat(Webhook): sourceGuild, sourceChannel, improve owner (#5508)
This commit is contained in:
@@ -65,15 +65,25 @@ class Webhook {
|
|||||||
*/
|
*/
|
||||||
this.channelID = data.channel_id;
|
this.channelID = data.channel_id;
|
||||||
|
|
||||||
if (data.user) {
|
/**
|
||||||
/**
|
* The owner of the webhook
|
||||||
* The owner of the webhook
|
* @type {?User|Object}
|
||||||
* @type {?User|Object}
|
*/
|
||||||
*/
|
this.owner = data.user ? this.client.users?.add(data.user) ?? data.user : null;
|
||||||
this.owner = this.client.users ? this.client.users.cache.get(data.user.id) : data.user;
|
|
||||||
} else {
|
/**
|
||||||
this.owner = null;
|
* The source guild of the webhook
|
||||||
}
|
* @type {?Guild|Object}
|
||||||
|
*/
|
||||||
|
this.sourceGuild = data.source_guild
|
||||||
|
? this.client.guilds?.add(data.source_guild, false) ?? data.source_guild
|
||||||
|
: null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source channel of the webhook
|
||||||
|
* @type {?Channel|Object}
|
||||||
|
*/
|
||||||
|
this.sourceChannel = this.client.channels?.resolve(data.source_channel?.id) ?? data.source_channel ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -1800,6 +1800,8 @@ declare module 'discord.js' {
|
|||||||
public guildID: Snowflake;
|
public guildID: Snowflake;
|
||||||
public name: string;
|
public name: string;
|
||||||
public owner: User | object | null;
|
public owner: User | object | null;
|
||||||
|
public sourceGuild: Guild | object | null;
|
||||||
|
public sourceChannel: Channel | object | null;
|
||||||
public token: string | null;
|
public token: string | null;
|
||||||
public type: WebhookTypes;
|
public type: WebhookTypes;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user