@@ -1434,7 +1434,7 @@ export class Guild extends AnonymousGuild {
1434
1434
public fetchPreview ( ) : Promise < GuildPreview > ;
1435
1435
public fetchTemplates ( ) : Promise < Collection < GuildTemplate [ 'code' ] , GuildTemplate > > ;
1436
1436
public fetchVanityData ( ) : Promise < Vanity > ;
1437
- public fetchWebhooks ( ) : Promise < Collection < Snowflake , Webhook > > ;
1437
+ public fetchWebhooks ( ) : Promise < Collection < Snowflake , Webhook < WebhookType . ChannelFollower | WebhookType . Incoming > > > ;
1438
1438
public fetchWelcomeScreen ( ) : Promise < WelcomeScreen > ;
1439
1439
public fetchWidget ( ) : Promise < Widget > ;
1440
1440
public fetchWidgetSettings ( ) : Promise < GuildWidgetSettings > ;
@@ -1476,7 +1476,7 @@ export class Guild extends AnonymousGuild {
1476
1476
export class GuildAuditLogs < Event extends GuildAuditLogsResolvable = AuditLogEvent > {
1477
1477
private constructor ( guild : Guild , data : RawGuildAuditLogData ) ;
1478
1478
private applicationCommands : Collection < Snowflake , ApplicationCommand > ;
1479
- private webhooks : Collection < Snowflake , Webhook > ;
1479
+ private webhooks : Collection < Snowflake , Webhook < WebhookType . ChannelFollower | WebhookType . Incoming > > ;
1480
1480
private integrations : Collection < Snowflake | string , Integration > ;
1481
1481
private guildScheduledEvents : Collection < Snowflake , GuildScheduledEvent > ;
1482
1482
private autoModerationRules : Collection < Snowflake , AutoModerationRule > ;
@@ -3529,44 +3529,32 @@ export class VoiceState extends Base {
3529
3529
}
3530
3530
3531
3531
// tslint:disable-next-line no-empty-interface
3532
- export interface Webhook extends WebhookFields { }
3533
- export class Webhook {
3532
+ export interface Webhook < Type extends WebhookType = WebhookType > extends WebhookFields { }
3533
+ export class Webhook < Type extends WebhookType = WebhookType > {
3534
3534
private constructor ( client : Client < true > , data ?: RawWebhookData ) ;
3535
3535
public avatar : string | null ;
3536
3536
public avatarURL ( options ?: ImageURLOptions ) : string | null ;
3537
3537
public channelId : Snowflake ;
3538
3538
public readonly client : Client ;
3539
3539
public guildId : Snowflake ;
3540
3540
public name : string ;
3541
- public owner : User | APIUser | null ;
3542
- public sourceGuild : Guild | APIPartialGuild | null ;
3543
- public sourceChannel : NewsChannel | APIPartialChannel | null ;
3544
- public token : string | null ;
3545
- public type : WebhookType ;
3546
- public applicationId : Snowflake | null ;
3541
+ public owner : Type extends WebhookType . Incoming ? User | APIUser | null : User | APIUser ;
3542
+ public sourceGuild : Type extends WebhookType . ChannelFollower ? Guild | APIPartialGuild : null ;
3543
+ public sourceChannel : Type extends WebhookType . ChannelFollower ? NewsChannel | APIPartialChannel : null ;
3544
+ public token : Type extends WebhookType . Incoming
3545
+ ? string
3546
+ : Type extends WebhookType . ChannelFollower
3547
+ ? null
3548
+ : string | null ;
3549
+ public type : Type ;
3550
+ public applicationId : Type extends WebhookType . Application ? Snowflake : null ;
3547
3551
public get channel ( ) : TextChannel | VoiceChannel | NewsChannel | StageChannel | ForumChannel | MediaChannel | null ;
3548
- public isUserCreated ( ) : this is this & {
3549
- type : WebhookType . Incoming ;
3550
- applicationId : null ;
3551
- owner : User | APIUser ;
3552
- } ;
3553
- public isApplicationCreated ( ) : this is this & {
3554
- type : WebhookType . Application ;
3555
- applicationId : Snowflake ;
3556
- owner : User | APIUser ;
3557
- } ;
3558
- public isIncoming ( ) : this is this & {
3559
- type : WebhookType . Incoming ;
3560
- token : string ;
3561
- } ;
3562
- public isChannelFollower ( ) : this is this & {
3563
- type : WebhookType . ChannelFollower ;
3564
- sourceGuild : Guild | APIPartialGuild ;
3565
- sourceChannel : NewsChannel | APIPartialChannel ;
3566
- token : null ;
3567
- applicationId : null ;
3552
+ public isUserCreated ( ) : this is Webhook < WebhookType . Incoming > & {
3568
3553
owner : User | APIUser ;
3569
3554
} ;
3555
+ public isApplicationCreated ( ) : this is Webhook < WebhookType . Application > ;
3556
+ public isIncoming ( ) : this is Webhook < WebhookType . Incoming > ;
3557
+ public isChannelFollower ( ) : this is Webhook < WebhookType . ChannelFollower > ;
3570
3558
3571
3559
public editMessage (
3572
3560
message : MessageResolvable ,
@@ -4192,14 +4180,16 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
4192
4180
options : GuildChannelCreateOptions & { type : Type } ,
4193
4181
) : Promise < MappedGuildChannelTypes [ Type ] > ;
4194
4182
public create ( options : GuildChannelCreateOptions ) : Promise < TextChannel > ;
4195
- public createWebhook ( options : WebhookCreateOptions ) : Promise < Webhook > ;
4183
+ public createWebhook ( options : WebhookCreateOptions ) : Promise < Webhook < WebhookType . Incoming > > ;
4196
4184
public edit ( channel : GuildChannelResolvable , data : GuildChannelEditOptions ) : Promise < GuildChannel > ;
4197
4185
public fetch ( id : Snowflake , options ?: BaseFetchOptions ) : Promise < GuildBasedChannel | null > ;
4198
4186
public fetch (
4199
4187
id ?: undefined ,
4200
4188
options ?: BaseFetchOptions ,
4201
4189
) : Promise < Collection < Snowflake , NonThreadGuildBasedChannel | null > > ;
4202
- public fetchWebhooks ( channel : GuildChannelResolvable ) : Promise < Collection < Snowflake , Webhook > > ;
4190
+ public fetchWebhooks (
4191
+ channel : GuildChannelResolvable ,
4192
+ ) : Promise < Collection < Snowflake , Webhook < WebhookType . ChannelFollower | WebhookType . Incoming > > > ;
4203
4193
public setPosition (
4204
4194
channel : GuildChannelResolvable ,
4205
4195
position : number ,
@@ -4553,8 +4543,8 @@ export interface TextBasedChannelFields<InGuild extends boolean = boolean>
4553
4543
options ?: MessageChannelCollectorOptionsParams < ComponentType , true > ,
4554
4544
) : InteractionCollector < MappedInteractionTypes [ ComponentType ] > ;
4555
4545
createMessageCollector ( options ?: MessageCollectorOptions ) : MessageCollector ;
4556
- createWebhook ( options : ChannelWebhookCreateOptions ) : Promise < Webhook > ;
4557
- fetchWebhooks ( ) : Promise < Collection < Snowflake , Webhook > > ;
4546
+ createWebhook ( options : ChannelWebhookCreateOptions ) : Promise < Webhook < WebhookType . Incoming > > ;
4547
+ fetchWebhooks ( ) : Promise < Collection < Snowflake , Webhook < WebhookType . ChannelFollower | WebhookType . Incoming > > > ;
4558
4548
sendTyping ( ) : Promise < void > ;
4559
4549
setRateLimitPerUser ( rateLimitPerUser : number , reason ?: string ) : Promise < this> ;
4560
4550
setNSFW ( nsfw ?: boolean , reason ?: string ) : Promise < this> ;
@@ -4580,7 +4570,7 @@ export interface WebhookFields extends PartialWebhookFields {
4580
4570
get createdAt ( ) : Date ;
4581
4571
get createdTimestamp ( ) : number ;
4582
4572
delete ( reason ?: string ) : Promise < void > ;
4583
- edit ( options : WebhookEditOptions ) : Promise < Webhook > ;
4573
+ edit ( options : WebhookEditOptions ) : Promise < this > ;
4584
4574
sendSlackMessage ( body : unknown ) : Promise < boolean > ;
4585
4575
}
4586
4576
@@ -5736,7 +5726,7 @@ export interface GuildAuditLogsEntryExtraField {
5736
5726
export interface GuildAuditLogsEntryTargetField < TActionType extends GuildAuditLogsActionType > {
5737
5727
User : User | null ;
5738
5728
Guild : Guild ;
5739
- Webhook : Webhook ;
5729
+ Webhook : Webhook < WebhookType . ChannelFollower | WebhookType . Incoming > ;
5740
5730
Invite : Invite ;
5741
5731
Message : TActionType extends AuditLogEvent . MessageBulkDelete ? Guild | { id : Snowflake } : User ;
5742
5732
Integration : Integration ;
@@ -6337,7 +6327,7 @@ export type MessageTarget =
6337
6327
| TextBasedChannel
6338
6328
| User
6339
6329
| GuildMember
6340
- | Webhook
6330
+ | Webhook < WebhookType . Incoming >
6341
6331
| WebhookClient
6342
6332
| Message
6343
6333
| MessageManager ;
0 commit comments