Skip to content

Commit

Permalink
refactor(discord.js): change CacheTypeReducer Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 committed Feb 13, 2022
1 parent 88ee664 commit 833ee0e
Showing 1 changed file with 70 additions and 70 deletions.
140 changes: 70 additions & 70 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,17 +1050,17 @@ export class GuildAuditLogs<T extends GuildAuditLogsResolvable = 'All'> {
export class GuildAuditLogsEntry<
TActionRaw extends GuildAuditLogsResolvable = 'All',
TAction = TActionRaw extends keyof GuildAuditLogsIds
? GuildAuditLogsIds[TActionRaw]
: TActionRaw extends null
? 'All'
: TActionRaw,
? GuildAuditLogsIds[TActionRaw]
: TActionRaw extends null
? 'All'
: TActionRaw,
TActionType extends GuildAuditLogsActionType = TAction extends keyof GuildAuditLogsTypes
? GuildAuditLogsTypes[TAction][1]
: 'All',
? GuildAuditLogsTypes[TAction][1]
: 'All',
TTargetType extends GuildAuditLogsTarget = TAction extends keyof GuildAuditLogsTypes
? GuildAuditLogsTypes[TAction][0]
: 'Unknown',
> {
? GuildAuditLogsTypes[TAction][0]
: 'Unknown',
> {
private constructor(logs: GuildAuditLogs, guild: Guild, data: RawGuildAuditLogEntryData);
public action: TAction;
public actionType: TActionType;
Expand Down Expand Up @@ -1340,7 +1340,7 @@ export type CacheTypeReducer<
RawType = CachedType,
PresentType = CachedType | RawType,
Fallback = PresentType | null,
> = [State] extends ['cached']
> = [State] extends ['cached']
? CachedType
: [State] extends ['raw']
? RawType
Expand Down Expand Up @@ -1478,19 +1478,19 @@ export class LimitedCollection<K, V> extends Collection<K, V> {

export type MessageCollectorOptionsParams<T extends ComponentType, Cached extends boolean = boolean> =
| {
componentType?: T;
} & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
componentType?: T;
} & MessageComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;

export type MessageChannelCollectorOptionsParams<T extends ComponentType, Cached extends boolean = boolean> =
| {
componentType?: T;
} & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;
componentType?: T;
} & MessageChannelComponentCollectorOptions<MappedInteractionTypes<Cached>[T]>;

export type AwaitMessageCollectorOptionsParams<T extends ComponentType, Cached extends boolean = boolean> =
| { componentType?: T } & Pick<
InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
keyof AwaitMessageComponentOptions<any>
>;
InteractionCollectorOptions<MappedInteractionTypes<Cached>[T]>,
keyof AwaitMessageComponentOptions<any>
>;

export interface StringMappedInteractionTypes<Cached extends CacheType = CacheType> {
Button: ButtonInteraction<Cached>;
Expand Down Expand Up @@ -1651,7 +1651,7 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e

export class MessageContextMenuCommandInteraction<
Cached extends CacheType = CacheType,
> extends ContextMenuCommandInteraction<Cached> {
> extends ContextMenuCommandInteraction<Cached> {
public readonly targetMessage: NonNullable<CommandInteractionOption<Cached>['message']>;
public inGuild(): this is MessageContextMenuCommandInteraction<'raw' | 'cached'>;
public inCachedGuild(): this is MessageContextMenuCommandInteraction<'cached'>;
Expand Down Expand Up @@ -2335,7 +2335,7 @@ export class User extends PartialTextBasedChannel(Base) {

export class UserContextMenuCommandInteraction<
Cached extends CacheType = CacheType,
> extends ContextMenuCommandInteraction<Cached> {
> extends ContextMenuCommandInteraction<Cached> {
public readonly targetUser: User;
public readonly targetMember: CacheTypeReducer<Cached, GuildMember, APIInteractionGuildMember>;
public inGuild(): this is UserContextMenuCommandInteraction<'raw' | 'cached'>;
Expand Down Expand Up @@ -2716,7 +2716,7 @@ export class ApplicationCommandManager<
ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>,
PermissionsOptionsExtras = { guild: GuildResolvable },
PermissionsGuildType = null,
> extends CachedManager<Snowflake, ApplicationCommandScope, ApplicationCommandResolvable> {
> extends CachedManager<Snowflake, ApplicationCommandScope, ApplicationCommandResolvable> {
protected constructor(client: Client, iterable?: Iterable<unknown>);
public permissions: ApplicationCommandPermissionsManager<
{ command?: ApplicationCommandResolvable } & PermissionsOptionsExtras,
Expand Down Expand Up @@ -2763,7 +2763,7 @@ export class ApplicationCommandPermissionsManager<
FullPermissionsOptions,
GuildType,
CommandIdType,
> extends BaseManager {
> extends BaseManager {
private constructor(manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand);
private manager: ApplicationCommandManager | GuildApplicationCommandManager | ApplicationCommand;

Expand All @@ -2780,13 +2780,13 @@ export class ApplicationCommandPermissionsManager<
public remove(
options:
| (FetchSingleOptions & {
users: UserResolvable | UserResolvable[];
roles?: RoleResolvable | RoleResolvable[];
})
users: UserResolvable | UserResolvable[];
roles?: RoleResolvable | RoleResolvable[];
})
| (FetchSingleOptions & {
users?: UserResolvable | UserResolvable[];
roles: RoleResolvable | RoleResolvable[];
}),
users?: UserResolvable | UserResolvable[];
roles: RoleResolvable | RoleResolvable[];
}),
): Promise<ApplicationCommandPermissions[]>;
public set(
options: FetchSingleOptions & { permissions: ApplicationCommandPermissionData[] },
Expand Down Expand Up @@ -2950,7 +2950,7 @@ export class GuildScheduledEventManager extends CachedManager<
public fetch(): Promise<Collection<Snowflake, GuildScheduledEvent>>;
public fetch<
T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions | FetchGuildScheduledEventsOptions,
>(options?: T): Promise<GuildScheduledEventManagerFetchResult<T>>;
>(options?: T): Promise<GuildScheduledEventManagerFetchResult<T>>;
public edit<S extends GuildScheduledEventStatus, T extends GuildScheduledEventSetStatusArg<S>>(
guildScheduledEvent: GuildScheduledEventResolvable,
options: GuildScheduledEventEditOptions<S, T>,
Expand Down Expand Up @@ -3286,9 +3286,9 @@ export interface ApplicationCommandAttachmentOption extends BaseApplicationComma

export interface ApplicationCommandAutocompleteOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type:
| ApplicationCommandOptionType.String
| ApplicationCommandOptionType.Number
| ApplicationCommandOptionType.Integer;
| ApplicationCommandOptionType.String
| ApplicationCommandOptionType.Number
| ApplicationCommandOptionType.Integer;
autocomplete: true;
}

Expand Down Expand Up @@ -3475,8 +3475,8 @@ export type CacheFactory = (

export type CacheWithLimitsOptions = {
[K in keyof Caches]?: Caches[K][0]['prototype'] extends DataManager<infer K, infer V, any>
? LimitedCollectionOptions<K, V> | number
: never;
? LimitedCollectionOptions<K, V> | number
: never;
};

export interface CategoryCreateChannelOptions {
Expand Down Expand Up @@ -3720,7 +3720,7 @@ export interface CommandInteractionOption<Cached extends CacheType = CacheType>
member?: CacheTypeReducer<Cached, GuildMember, APIInteractionDataResolvedGuildMember>;
channel?: CacheTypeReducer<Cached, GuildBasedChannel, APIInteractionDataResolvedChannel>;
role?: CacheTypeReducer<Cached, Role, APIRole>;
attachment?: CacheTypeReducer<Cached, MessageAttachment>;
attachment?: Collection<Snowflake, MessageAttachment>;
message?: GuildCacheMessage<Cached>;
}

Expand All @@ -3730,7 +3730,7 @@ export interface CommandInteractionResolvedData<Cached extends CacheType = Cache
roles?: Collection<Snowflake, CacheTypeReducer<Cached, Role, APIRole>>;
channels?: Collection<Snowflake, CacheTypeReducer<Cached, AnyChannel, APIInteractionDataResolvedChannel>>;
messages?: Collection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
attachments?: Collection<Snowflake, CacheTypeReducer<Cached, MessageAttachment>>;
attachments?: Collection<Snowflake, MessageAttachment>;
}

export declare const Colors: {
Expand Down Expand Up @@ -4228,20 +4228,20 @@ export interface GuildAuditLogsEntryExtraField {
MessageUnpin: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake };
MemberDisconnect: { count: number };
ChannelOverwriteCreate:
| Role
| GuildMember
| { id: Snowflake; name: string; type: 'Role' }
| { id: Snowflake; type: 'Member' };
| Role
| GuildMember
| { id: Snowflake; name: string; type: 'Role' }
| { id: Snowflake; type: 'Member' };
ChannelOverwriteUpdate:
| Role
| GuildMember
| { id: Snowflake; name: string; type: 'Role' }
| { id: Snowflake; type: 'Member' };
| Role
| GuildMember
| { id: Snowflake; name: string; type: 'Role' }
| { id: Snowflake; type: 'Member' };
ChannelOverwriteDelete:
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteType.Role }
| { id: Snowflake; type: OverwriteType.Member };
| Role
| GuildMember
| { id: Snowflake; name: string; type: OverwriteType.Role }
| { id: Snowflake; type: OverwriteType.Member };
StageInstanceCreate: StageChannel | { id: Snowflake };
StageInstanceDelete: StageChannel | { id: Snowflake };
StageInstanceUpdate: StageChannel | { id: Snowflake };
Expand All @@ -4254,8 +4254,8 @@ export interface GuildAuditLogsEntryTargetField<TActionType extends GuildAuditLo
Invite: Invite;
Message: TActionType extends 'MESSAGE_BULK_DELETE' ? Guild | { id: Snowflake } : User;
Integration: Integration;
Channel: NonThreadGuildBasedChannel | { id: Snowflake; [x: string]: unknown };
Thread: ThreadChannel | { id: Snowflake; [x: string]: unknown };
Channel: NonThreadGuildBasedChannel | { id: Snowflake;[x: string]: unknown };
Thread: ThreadChannel | { id: Snowflake;[x: string]: unknown };
StageInstance: StageInstance;
Sticker: Sticker;
GuildScheduledEvent: GuildScheduledEvent;
Expand Down Expand Up @@ -4417,7 +4417,7 @@ export interface GuildScheduledEventCreateOptions {
export interface GuildScheduledEventEditOptions<
S extends GuildScheduledEventStatus,
T extends GuildScheduledEventSetStatusArg<S>,
> extends Omit<Partial<GuildScheduledEventCreateOptions>, 'channel'> {
> extends Omit<Partial<GuildScheduledEventCreateOptions>, 'channel'> {
channel?: GuildVoiceChannelResolvable | null;
status?: T | number;
}
Expand All @@ -4432,23 +4432,23 @@ export interface GuildScheduledEventEntityMetadataOptions {

export type GuildScheduledEventManagerFetchResult<
T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions | FetchGuildScheduledEventsOptions,
> = T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions
> = T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions
? GuildScheduledEvent
: Collection<Snowflake, GuildScheduledEvent>;

export type GuildScheduledEventManagerFetchSubscribersResult<T extends FetchGuildScheduledEventSubscribersOptions> =
T extends { withMember: true }
? Collection<Snowflake, GuildScheduledEventUser<true>>
: Collection<Snowflake, GuildScheduledEventUser<false>>;
? Collection<Snowflake, GuildScheduledEventUser<true>>
: Collection<Snowflake, GuildScheduledEventUser<false>>;

export type GuildScheduledEventResolvable = Snowflake | GuildScheduledEvent;

export type GuildScheduledEventSetStatusArg<T extends GuildScheduledEventStatus> =
T extends GuildScheduledEventStatus.Scheduled
? GuildScheduledEventStatus.Active | GuildScheduledEventStatus.Canceled
: T extends GuildScheduledEventStatus.Active
? GuildScheduledEventStatus.Completed
: never;
? GuildScheduledEventStatus.Active | GuildScheduledEventStatus.Canceled
: T extends GuildScheduledEventStatus.Active
? GuildScheduledEventStatus.Completed
: never;

export interface GuildScheduledEventUser<T> {
guildScheduledEventId: Snowflake;
Expand Down Expand Up @@ -4766,24 +4766,24 @@ export type Partialize<
N extends keyof T | null = null,
M extends keyof T | null = null,
E extends keyof T | '' = '',
> = {
readonly client: Client;
id: Snowflake;
partial: true;
} & {
[K in keyof Omit<T, 'client' | 'id' | 'partial' | E>]: K extends N ? null : K extends M ? T[K] | null : T[K];
};
> = {
readonly client: Client;
id: Snowflake;
partial: true;
} & {
[K in keyof Omit<T, 'client' | 'id' | 'partial' | E>]: K extends N ? null : K extends M ? T[K] | null : T[K];
};

export interface PartialDMChannel extends Partialize<DMChannel, null, null, 'lastMessageId'> {
lastMessageId: undefined;
}

export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp' | 'pending'> {}
export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp' | 'pending'> { }

export interface PartialMessage
extends Partialize<Message, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> {}
extends Partialize<Message, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> { }

export interface PartialMessageReaction extends Partialize<MessageReaction, 'count'> {}
export interface PartialMessageReaction extends Partialize<MessageReaction, 'count'> { }

export interface PartialOverwriteData {
id: Snowflake | number;
Expand All @@ -4805,7 +4805,7 @@ export enum Partials {
GuildScheduledEvent,
}

export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> {}
export interface PartialUser extends Partialize<User, 'username' | 'tag' | 'discriminator'> { }

export type PresenceStatusData = ClientPresenceStatus | 'invisible';

Expand Down Expand Up @@ -4954,8 +4954,8 @@ export interface SweeperDefinitions {

export type SweeperOptions = {
[K in keyof SweeperDefinitions]?: SweeperDefinitions[K][2] extends true
? SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]> | LifetimeSweepOptions
: SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]>;
? SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]> | LifetimeSweepOptions
: SweepOptions<SweeperDefinitions[K][0], SweeperDefinitions[K][1]>;
};

export interface LimitedCollectionOptions<K, V> {
Expand Down

0 comments on commit 833ee0e

Please sign in to comment.