mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
types: improve audit logs' typings (#6647)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: Noel <buechler.noel@outlook.com> Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>
This commit is contained in:
263
typings/index.d.ts
vendored
263
typings/index.d.ts
vendored
@@ -890,7 +890,9 @@ export class Guild extends AnonymousGuild {
|
|||||||
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
||||||
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
|
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
|
||||||
public equals(guild: Guild): boolean;
|
public equals(guild: Guild): boolean;
|
||||||
public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise<GuildAuditLogs>;
|
public fetchAuditLogs<T extends GuildAuditLogsResolvable = 'ALL'>(
|
||||||
|
options?: GuildAuditLogsFetchOptions<T>,
|
||||||
|
): Promise<GuildAuditLogs<T>>;
|
||||||
public fetchIntegrations(): Promise<Collection<Snowflake | string, Integration>>;
|
public fetchIntegrations(): Promise<Collection<Snowflake | string, Integration>>;
|
||||||
public fetchOwner(options?: BaseFetchOptions): Promise<GuildMember>;
|
public fetchOwner(options?: BaseFetchOptions): Promise<GuildMember>;
|
||||||
public fetchPreview(): Promise<GuildPreview>;
|
public fetchPreview(): Promise<GuildPreview>;
|
||||||
@@ -935,12 +937,12 @@ export class Guild extends AnonymousGuild {
|
|||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildAuditLogs {
|
export class GuildAuditLogs<T extends GuildAuditLogsResolvable = 'ALL'> {
|
||||||
private constructor(guild: Guild, data: RawGuildAuditLogData);
|
private constructor(guild: Guild, data: RawGuildAuditLogData);
|
||||||
private webhooks: Collection<Snowflake, Webhook>;
|
private webhooks: Collection<Snowflake, Webhook>;
|
||||||
private integrations: Collection<Snowflake | string, Integration>;
|
private integrations: Collection<Snowflake | string, Integration>;
|
||||||
|
|
||||||
public entries: Collection<Snowflake, GuildAuditLogsEntry>;
|
public entries: Collection<Snowflake, GuildAuditLogsEntry<T>>;
|
||||||
|
|
||||||
public static Actions: GuildAuditLogsActions;
|
public static Actions: GuildAuditLogsActions;
|
||||||
public static Targets: GuildAuditLogsTargets;
|
public static Targets: GuildAuditLogsTargets;
|
||||||
@@ -951,33 +953,34 @@ export class GuildAuditLogs {
|
|||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildAuditLogsEntry {
|
export class GuildAuditLogsEntry<
|
||||||
|
TActionRaw extends GuildAuditLogsResolvable = 'ALL',
|
||||||
|
TAction = TActionRaw extends keyof GuildAuditLogsIds
|
||||||
|
? GuildAuditLogsIds[TActionRaw]
|
||||||
|
: TActionRaw extends null
|
||||||
|
? 'ALL'
|
||||||
|
: TActionRaw,
|
||||||
|
TActionType extends GuildAuditLogsActionType = TAction extends keyof GuildAuditLogsTypes
|
||||||
|
? GuildAuditLogsTypes[TAction][1]
|
||||||
|
: 'ALL',
|
||||||
|
TTargetType extends GuildAuditLogsTarget = TAction extends keyof GuildAuditLogsTypes
|
||||||
|
? GuildAuditLogsTypes[TAction][0]
|
||||||
|
: 'UNKNOWN',
|
||||||
|
> {
|
||||||
private constructor(logs: GuildAuditLogs, guild: Guild, data: RawGuildAuditLogEntryData);
|
private constructor(logs: GuildAuditLogs, guild: Guild, data: RawGuildAuditLogEntryData);
|
||||||
public action: GuildAuditLogsAction;
|
public action: TAction;
|
||||||
public actionType: GuildAuditLogsActionType;
|
public actionType: TActionType;
|
||||||
public changes: AuditLogChange[] | null;
|
public changes: AuditLogChange[] | null;
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
public executor: User | null;
|
public executor: User | null;
|
||||||
public extra: unknown | Role | GuildMember | null;
|
public extra: TAction extends keyof GuildAuditLogsEntryExtraField ? GuildAuditLogsEntryExtraField[TAction] : null;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public reason: string | null;
|
public reason: string | null;
|
||||||
public target:
|
public target: TTargetType extends keyof GuildAuditLogsEntryTargetField<TActionType>
|
||||||
| Guild
|
? GuildAuditLogsEntryTargetField<TActionType>[TTargetType]
|
||||||
| GuildChannel
|
: Role | GuildEmoji | { id: Snowflake } | null;
|
||||||
| User
|
public targetType: TTargetType;
|
||||||
| Role
|
|
||||||
| GuildEmoji
|
|
||||||
| Invite
|
|
||||||
| Webhook
|
|
||||||
| Message
|
|
||||||
| Integration
|
|
||||||
| StageInstance
|
|
||||||
| Sticker
|
|
||||||
| ThreadChannel
|
|
||||||
| { id: Snowflake }
|
|
||||||
| null;
|
|
||||||
public targetType: GuildAuditLogsTarget;
|
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4178,83 +4181,161 @@ export interface GuildApplicationCommandPermissionData {
|
|||||||
permissions: ApplicationCommandPermissionData[];
|
permissions: ApplicationCommandPermissionData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildAuditLogsAction = keyof GuildAuditLogsActions;
|
interface GuildAuditLogsTypes {
|
||||||
|
GUILD_UPDATE: ['GUILD', 'UPDATE'];
|
||||||
export interface GuildAuditLogsActions {
|
CHANNEL_CREATE: ['CHANNEL', 'CREATE'];
|
||||||
ALL?: null;
|
CHANNEL_UPDATE: ['CHANNEL', 'UPDATE'];
|
||||||
GUILD_UPDATE?: number;
|
CHANNEL_DELETE: ['CHANNEL', 'DELETE'];
|
||||||
CHANNEL_CREATE?: number;
|
CHANNEL_OVERWRITE_CREATE: ['CHANNEL', 'CREATE'];
|
||||||
CHANNEL_UPDATE?: number;
|
CHANNEL_OVERWRITE_UPDATE: ['CHANNEL', 'UPDATE'];
|
||||||
CHANNEL_DELETE?: number;
|
CHANNEL_OVERWRITE_DELETE: ['CHANNEL', 'DELETE'];
|
||||||
CHANNEL_OVERWRITE_CREATE?: number;
|
MEMBER_KICK: ['USER', 'DELETE'];
|
||||||
CHANNEL_OVERWRITE_UPDATE?: number;
|
MEMBER_PRUNE: ['USER', 'DELETE'];
|
||||||
CHANNEL_OVERWRITE_DELETE?: number;
|
MEMBER_BAN_ADD: ['USER', 'DELETE'];
|
||||||
MEMBER_KICK?: number;
|
MEMBER_BAN_REMOVE: ['USER', 'CREATE'];
|
||||||
MEMBER_PRUNE?: number;
|
MEMBER_UPDATE: ['USER', 'UPDATE'];
|
||||||
MEMBER_BAN_ADD?: number;
|
MEMBER_ROLE_UPDATE: ['USER', 'UPDATE'];
|
||||||
MEMBER_BAN_REMOVE?: number;
|
MEMBER_MOVE: ['USER', 'UPDATE'];
|
||||||
MEMBER_UPDATE?: number;
|
MEMBER_DISCONNECT: ['USER', 'DELETE'];
|
||||||
MEMBER_ROLE_UPDATE?: number;
|
BOT_ADD: ['USER', 'CREATE'];
|
||||||
MEMBER_MOVE?: number;
|
ROLE_CREATE: ['ROLE', 'CREATE'];
|
||||||
MEMBER_DISCONNECT?: number;
|
ROLE_UPDATE: ['ROLE', 'UPDATE'];
|
||||||
BOT_ADD?: number;
|
ROLE_DELETE: ['ROLE', 'DELETE'];
|
||||||
ROLE_CREATE?: number;
|
INVITE_CREATE: ['INVITE', 'CREATE'];
|
||||||
ROLE_UPDATE?: number;
|
INVITE_UPDATE: ['INVITE', 'UPDATE'];
|
||||||
ROLE_DELETE?: number;
|
INVITE_DELETE: ['INVITE', 'DELETE'];
|
||||||
INVITE_CREATE?: number;
|
WEBHOOK_CREATE: ['WEBHOOK', 'CREATE'];
|
||||||
INVITE_UPDATE?: number;
|
WEBHOOK_UPDATE: ['WEBHOOK', 'UPDATE'];
|
||||||
INVITE_DELETE?: number;
|
WEBHOOK_DELETE: ['WEBHOOK', 'DELETE'];
|
||||||
WEBHOOK_CREATE?: number;
|
EMOJI_CREATE: ['EMOJI', 'CREATE'];
|
||||||
WEBHOOK_UPDATE?: number;
|
EMOJI_UPDATE: ['EMOJI', 'UPDATE'];
|
||||||
WEBHOOK_DELETE?: number;
|
EMOJI_DELETE: ['EMOJI', 'DELETE'];
|
||||||
EMOJI_CREATE?: number;
|
MESSAGE_DELETE: ['MESSAGE', 'DELETE'];
|
||||||
EMOJI_UPDATE?: number;
|
MESSAGE_BULK_DELETE: ['MESSAGE', 'DELETE'];
|
||||||
EMOJI_DELETE?: number;
|
MESSAGE_PIN: ['MESSAGE', 'CREATE'];
|
||||||
MESSAGE_DELETE?: number;
|
MESSAGE_UNPIN: ['MESSAGE', 'DELETE'];
|
||||||
MESSAGE_BULK_DELETE?: number;
|
INTEGRATION_CREATE: ['INTEGRATION', 'CREATE'];
|
||||||
MESSAGE_PIN?: number;
|
INTEGRATION_UPDATE: ['INTEGRATION', 'UPDATE'];
|
||||||
MESSAGE_UNPIN?: number;
|
INTEGRATION_DELETE: ['INTEGRATION', 'DELETE'];
|
||||||
INTEGRATION_CREATE?: number;
|
STAGE_INSTANCE_CREATE: ['STAGE_INSTANCE', 'CREATE'];
|
||||||
INTEGRATION_UPDATE?: number;
|
STAGE_INSTANCE_UPDATE: ['STAGE_INSTANCE', 'UPDATE'];
|
||||||
INTEGRATION_DELETE?: number;
|
STAGE_INSTANCE_DELETE: ['STAGE_INSTANCE', 'DELETE'];
|
||||||
STAGE_INSTANCE_CREATE?: number;
|
STICKER_CREATE: ['STICKER', 'CREATE'];
|
||||||
STAGE_INSTANCE_UPDATE?: number;
|
STICKER_UPDATE: ['STICKER', 'UPDATE'];
|
||||||
STAGE_INSTANCE_DELETE?: number;
|
STICKER_DELETE: ['STICKER', 'DELETE'];
|
||||||
STICKER_CREATE?: number;
|
THREAD_CREATE: ['THREAD', 'CREATE'];
|
||||||
STICKER_UPDATE?: number;
|
THREAD_UPDATE: ['THREAD', 'UPDATE'];
|
||||||
STICKER_DELETE?: number;
|
THREAD_DELETE: ['THREAD', 'DELETE'];
|
||||||
THREAD_CREATE?: number;
|
|
||||||
THREAD_UPDATE?: number;
|
|
||||||
THREAD_DELETE?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildAuditLogsActionType = 'CREATE' | 'DELETE' | 'UPDATE' | 'ALL';
|
export interface GuildAuditLogsIds {
|
||||||
|
1: 'GUILD_UPDATE';
|
||||||
|
10: 'CHANNEL_CREATE';
|
||||||
|
11: 'CHANNEL_UPDATE';
|
||||||
|
12: 'CHANNEL_DELETE';
|
||||||
|
13: 'CHANNEL_OVERWRITE_CREATE';
|
||||||
|
14: 'CHANNEL_OVERWRITE_UPDATE';
|
||||||
|
15: 'CHANNEL_OVERWRITE_DELETE';
|
||||||
|
20: 'MEMBER_KICK';
|
||||||
|
21: 'MEMBER_PRUNE';
|
||||||
|
22: 'MEMBER_BAN_ADD';
|
||||||
|
23: 'MEMBER_BAN_REMOVE';
|
||||||
|
24: 'MEMBER_UPDATE';
|
||||||
|
25: 'MEMBER_ROLE_UPDATE';
|
||||||
|
26: 'MEMBER_MOVE';
|
||||||
|
27: 'MEMBER_DISCONNECT';
|
||||||
|
28: 'BOT_ADD';
|
||||||
|
30: 'ROLE_CREATE';
|
||||||
|
31: 'ROLE_UPDATE';
|
||||||
|
32: 'ROLE_DELETE';
|
||||||
|
40: 'INVITE_CREATE';
|
||||||
|
41: 'INVITE_UPDATE';
|
||||||
|
42: 'INVITE_DELETE';
|
||||||
|
50: 'WEBHOOK_CREATE';
|
||||||
|
51: 'WEBHOOK_UPDATE';
|
||||||
|
52: 'WEBHOOK_DELETE';
|
||||||
|
60: 'EMOJI_CREATE';
|
||||||
|
61: 'EMOJI_UPDATE';
|
||||||
|
62: 'EMOJI_DELETE';
|
||||||
|
72: 'MESSAGE_DELETE';
|
||||||
|
73: 'MESSAGE_BULK_DELETE';
|
||||||
|
74: 'MESSAGE_PIN';
|
||||||
|
75: 'MESSAGE_UNPIN';
|
||||||
|
80: 'INTEGRATION_CREATE';
|
||||||
|
81: 'INTEGRATION_UPDATE';
|
||||||
|
82: 'INTEGRATION_DELETE';
|
||||||
|
83: 'STAGE_INSTANCE_CREATE';
|
||||||
|
84: 'STAGE_INSTANCE_UPDATE';
|
||||||
|
85: 'STAGE_INSTANCE_DELETE';
|
||||||
|
90: 'STICKER_CREATE';
|
||||||
|
91: 'STICKER_UPDATE';
|
||||||
|
92: 'STICKER_DELETE';
|
||||||
|
110: 'THREAD_CREATE';
|
||||||
|
111: 'THREAD_UPDATE';
|
||||||
|
112: 'THREAD_DELETE';
|
||||||
|
}
|
||||||
|
|
||||||
export interface GuildAuditLogsFetchOptions {
|
export type GuildAuditLogsActions = { [Key in keyof GuildAuditLogsIds as GuildAuditLogsIds[Key]]: Key } & { ALL: null };
|
||||||
|
|
||||||
|
export type GuildAuditLogsAction = keyof GuildAuditLogsActions;
|
||||||
|
|
||||||
|
export type GuildAuditLogsActionType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][1] | 'ALL';
|
||||||
|
|
||||||
|
export interface GuildAuditLogsEntryExtraField {
|
||||||
|
MEMBER_PRUNE: { removed: number; days: number };
|
||||||
|
MEMBER_MOVE: { channel: GuildChannel | { id: Snowflake }; count: number };
|
||||||
|
MESSAGE_DELETE: { channel: GuildChannel | { id: Snowflake }; count: number };
|
||||||
|
MESSAGE_BULK_DELETE: { channel: GuildChannel | { id: Snowflake }; count: number };
|
||||||
|
MESSAGE_PIN: { channel: GuildChannel | { id: Snowflake }; messageId: Snowflake };
|
||||||
|
MESSAGE_UNPIN: { channel: GuildChannel | { id: Snowflake }; messageId: Snowflake };
|
||||||
|
MEMBER_DISCONNECT: { count: number };
|
||||||
|
CHANNEL_OVERWRITE_CREATE:
|
||||||
|
| Role
|
||||||
|
| GuildMember
|
||||||
|
| { id: Snowflake; name: string; type: OverwriteTypes.role }
|
||||||
|
| { id: Snowflake; type: OverwriteTypes.member };
|
||||||
|
CHANNEL_OVERWRITE_UPDATE:
|
||||||
|
| Role
|
||||||
|
| GuildMember
|
||||||
|
| { id: Snowflake; name: string; type: OverwriteTypes.role }
|
||||||
|
| { id: Snowflake; type: OverwriteTypes.member };
|
||||||
|
CHANNEL_OVERWRITE_DELETE:
|
||||||
|
| Role
|
||||||
|
| GuildMember
|
||||||
|
| { id: Snowflake; name: string; type: OverwriteTypes.role }
|
||||||
|
| { id: Snowflake; type: OverwriteTypes.member };
|
||||||
|
STAGE_INSTANCE_CREATE: GuildChannel | { id: Snowflake };
|
||||||
|
STAGE_INSTANCE_DELETE: GuildChannel | { id: Snowflake };
|
||||||
|
STAGE_INSTANCE_UPDATE: GuildChannel | { id: Snowflake };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GuildAuditLogsEntryTargetField<TActionType extends GuildAuditLogsActionType> {
|
||||||
|
USER: User | null;
|
||||||
|
GUILD: Guild;
|
||||||
|
WEBHOOK: Webhook;
|
||||||
|
INVITE: Invite | { [x: string]: unknown };
|
||||||
|
MESSAGE: TActionType extends 'MESSAGE_BULK_DELETE' ? Guild | { id: Snowflake } : User;
|
||||||
|
INTEGRATION: Integration;
|
||||||
|
CHANNEL: GuildChannel | ThreadChannel | { id: Snowflake; [x: string]: unknown };
|
||||||
|
THREAD: GuildChannel | ThreadChannel | { id: Snowflake; [x: string]: unknown };
|
||||||
|
STAGE_INSTANCE: StageInstance;
|
||||||
|
STICKER: Sticker;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GuildAuditLogsFetchOptions<T extends GuildAuditLogsResolvable> {
|
||||||
before?: Snowflake | GuildAuditLogsEntry;
|
before?: Snowflake | GuildAuditLogsEntry;
|
||||||
limit?: number;
|
limit?: number;
|
||||||
user?: UserResolvable;
|
user?: UserResolvable;
|
||||||
type?: GuildAuditLogsAction | number;
|
type?: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GuildAuditLogsTarget = keyof GuildAuditLogsTargets;
|
export type GuildAuditLogsResolvable = keyof GuildAuditLogsIds | GuildAuditLogsAction | null;
|
||||||
|
|
||||||
export interface GuildAuditLogsTargets {
|
export type GuildAuditLogsTarget = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][0] | 'ALL' | 'UNKNOWN';
|
||||||
ALL?: string;
|
|
||||||
GUILD?: string;
|
export type GuildAuditLogsTargets = {
|
||||||
CHANNEL?: string;
|
[key in GuildAuditLogsTarget]?: string;
|
||||||
USER?: string;
|
};
|
||||||
ROLE?: string;
|
|
||||||
INVITE?: string;
|
|
||||||
WEBHOOK?: string;
|
|
||||||
EMOJI?: string;
|
|
||||||
MESSAGE?: string;
|
|
||||||
INTEGRATION?: string;
|
|
||||||
STAGE_INSTANCE?: string;
|
|
||||||
STICKER?: string;
|
|
||||||
THREAD?: string;
|
|
||||||
UNKNOWN?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type GuildBanResolvable = GuildBan | UserResolvable;
|
export type GuildBanResolvable = GuildBan | UserResolvable;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type {
|
|||||||
APIInteractionDataResolvedChannel,
|
APIInteractionDataResolvedChannel,
|
||||||
APIRole,
|
APIRole,
|
||||||
} from 'discord-api-types/v9';
|
} from 'discord-api-types/v9';
|
||||||
|
import { AuditLogEvent } from 'discord-api-types/v9';
|
||||||
import {
|
import {
|
||||||
ApplicationCommand,
|
ApplicationCommand,
|
||||||
ApplicationCommandData,
|
ApplicationCommandData,
|
||||||
@@ -79,6 +80,9 @@ import {
|
|||||||
Shard,
|
Shard,
|
||||||
WebSocketShard,
|
WebSocketShard,
|
||||||
Collector,
|
Collector,
|
||||||
|
GuildAuditLogsEntry,
|
||||||
|
GuildAuditLogs,
|
||||||
|
StageInstance,
|
||||||
} from '.';
|
} from '.';
|
||||||
import type { ApplicationCommandOptionTypes } from './enums';
|
import type { ApplicationCommandOptionTypes } from './enums';
|
||||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||||
@@ -1062,3 +1066,85 @@ collector.on('end', (collection, reason) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expectType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));
|
expectType<Promise<number | null>>(shard.eval(c => c.readyTimestamp));
|
||||||
|
|
||||||
|
// Test audit logs
|
||||||
|
declare const guild: Guild;
|
||||||
|
expectType<Promise<GuildAuditLogs<'MEMBER_KICK'>>>(guild.fetchAuditLogs({ type: 'MEMBER_KICK' }));
|
||||||
|
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.MemberKick>>>(
|
||||||
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogs<AuditLogEvent.MemberKick>>>(guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }));
|
||||||
|
|
||||||
|
expectType<Promise<GuildAuditLogs<'CHANNEL_CREATE'>>>(guild.fetchAuditLogs({ type: 'CHANNEL_CREATE' }));
|
||||||
|
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||||
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.CHANNEL_CREATE }),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogs<AuditLogEvent.ChannelCreate>>>(
|
||||||
|
guild.fetchAuditLogs({ type: AuditLogEvent.ChannelCreate }),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<GuildAuditLogs<'INTEGRATION_UPDATE'>>>(guild.fetchAuditLogs({ type: 'INTEGRATION_UPDATE' }));
|
||||||
|
expectAssignable<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||||
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.INTEGRATION_UPDATE }),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogs<AuditLogEvent.IntegrationUpdate>>>(
|
||||||
|
guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs({ type: 'ALL' }));
|
||||||
|
expectType<Promise<GuildAuditLogs<null>>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }));
|
||||||
|
expectType<Promise<GuildAuditLogs<'ALL'>>>(guild.fetchAuditLogs());
|
||||||
|
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
expectAssignable<Promise<GuildAuditLogsEntry<'MEMBER_KICK', 'MEMBER_KICK', 'DELETE', 'USER'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'ALL' }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: null }).then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildAuditLogsEntry<'ALL', 'ALL', 'ALL', 'UNKNOWN'> | undefined>>(
|
||||||
|
guild.fetchAuditLogs().then(al => al.entries.first()),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<null | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.extra),
|
||||||
|
);
|
||||||
|
expectType<Promise<null | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra),
|
||||||
|
);
|
||||||
|
expectType<Promise<GuildChannel | { id: Snowflake } | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.extra),
|
||||||
|
);
|
||||||
|
expectType<Promise<{ channel: GuildChannel | { id: Snowflake }; count: number } | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.extra),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<User | null | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.target),
|
||||||
|
);
|
||||||
|
expectType<Promise<User | null | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target),
|
||||||
|
);
|
||||||
|
expectType<Promise<StageInstance | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.target),
|
||||||
|
);
|
||||||
|
expectType<Promise<User | undefined>>(
|
||||||
|
guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.target),
|
||||||
|
);
|
||||||
|
|
||||||
|
expectType<Promise<User | undefined>>(
|
||||||
|
// @ts-expect-error Invalid audit log ID
|
||||||
|
guild.fetchAuditLogs({ type: 2000 }).then(al => al.entries.first()?.target),
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user