refactor(*): make typedefs for all options params (#5785)

Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
Shubham Parihar
2021-06-14 00:02:54 +05:30
committed by GitHub
parent 01a1fd615b
commit 1ac9a2eb5b
23 changed files with 356 additions and 237 deletions

150
typings/index.d.ts vendored
View File

@@ -422,7 +422,7 @@ declare module 'discord.js' {
public handleCollect(...args: any[]): void;
public handleDispose(...args: any[]): void;
public stop(reason?: string): void;
public resetTimer(options?: { time?: number; idle?: number }): void;
public resetTimer(options?: CollectorResetTimerOptions): void;
public [Symbol.asyncIterator](): AsyncIterableIterator<V>;
public toJSON(): unknown;
@@ -890,7 +890,7 @@ declare module 'discord.js' {
public type: Exclude<keyof typeof ChannelType, 'dm' | 'group' | 'unknown'>;
public readonly viewable: boolean;
public clone(options?: GuildChannelCloneOptions): Promise<this>;
public createInvite(options?: InviteOptions): Promise<Invite>;
public createInvite(options?: CreateInviteOptions): Promise<Invite>;
public createOverwrite(
userOrRole: RoleResolvable | UserResolvable,
options: PermissionOverwriteOptions,
@@ -907,11 +907,8 @@ declare module 'discord.js' {
public permissionsFor(memberOrRole: GuildMember | Role): Readonly<Permissions>;
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
public setName(name: string, reason?: string): Promise<this>;
public setParent(
channel: CategoryChannel | Snowflake | null,
options?: { lockPermissions?: boolean; reason?: string },
): Promise<this>;
public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise<this>;
public setParent(channel: CategoryChannel | Snowflake | null, options?: SetParentOptions): Promise<this>;
public setPosition(position: number, options?: SetChannelPositionOptions): Promise<this>;
public setTopic(topic: string | null, reason?: string): Promise<this>;
public updateOverwrite(
userOrRole: RoleResolvable | UserResolvable,
@@ -1013,7 +1010,7 @@ declare module 'discord.js' {
public unSynced: boolean | null;
public createGuild(name: string, icon?: BufferResolvable | Base64Resolvable): Promise<Guild>;
public delete(): Promise<GuildTemplate>;
public edit(options?: { name?: string; description?: string }): Promise<GuildTemplate>;
public edit(options?: EditGuildTemplateOptions): Promise<GuildTemplate>;
public sync(): Promise<GuildTemplate>;
public static GUILD_TEMPLATES_PATTERN: RegExp;
}
@@ -1398,14 +1395,7 @@ declare module 'discord.js' {
public readonly client: Client;
public everyone: boolean;
public readonly guild: Guild;
public has(
data: UserResolvable | RoleResolvable | ChannelResolvable,
options?: {
ignoreDirect?: boolean;
ignoreRoles?: boolean;
ignoreEveryone?: boolean;
},
): boolean;
public has(data: UserResolvable | RoleResolvable | ChannelResolvable, options?: MessageMentionsHasOptions): boolean;
public readonly members: Collection<Snowflake, GuildMember> | null;
public roles: Collection<Snowflake, Role>;
public users: Collection<Snowflake, User>;
@@ -1583,7 +1573,7 @@ declare module 'discord.js' {
public setMentionable(mentionable: boolean, reason?: string): Promise<Role>;
public setName(name: string, reason?: string): Promise<Role>;
public setPermissions(permissions: PermissionResolvable, reason?: string): Promise<Role>;
public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise<Role>;
public setPosition(position: number, options?: SetRolePositionOptions): Promise<Role>;
public toJSON(): unknown;
public toString(): string;
@@ -1646,7 +1636,7 @@ declare module 'discord.js' {
): Promise<T>;
public fetchClientValues(prop: string): Promise<any[]>;
public fetchClientValues(prop: string, shard: number): Promise<any>;
public respawnAll(options?: { shardDelay?: number; respawnDelay?: number; timeout?: number }): Promise<void>;
public respawnAll(options?: MultipleShardRespawnOptions): Promise<void>;
public send(message: any): Promise<void>;
public static singleton(client: Client, mode: ShardingManagerMode): ShardClientUtil;
@@ -1676,16 +1666,8 @@ declare module 'discord.js' {
public createShard(id: number): Shard;
public fetchClientValues(prop: string): Promise<any[]>;
public fetchClientValues(prop: string, shard: number): Promise<any>;
public respawnAll(options?: {
shardDelay?: number;
respawnDelay?: number;
timeout?: number;
}): Promise<Collection<number, Shard>>;
public spawn(options?: {
amount?: number | 'auto';
delay?: number;
timeout?: number;
}): Promise<Collection<number, Shard>>;
public respawnAll(options?: MultipleShardRespawnOptions): Promise<Collection<number, Shard>>;
public spawn(options?: MultipleShardSpawnOptions): Promise<Collection<number, Shard>>;
public on(event: 'shardCreate', listener: (shard: Shard) => Awaited<void>): this;
@@ -1826,8 +1808,8 @@ declare module 'discord.js' {
public static fetchRecommendedShards(token: string, guildsPerShard?: number): Promise<number>;
public static flatten(obj: unknown, ...props: { [key: string]: boolean | string }[]): unknown;
public static idToBinary(num: Snowflake): string;
public static makeError(obj: { name: string; message: string; stack: string }): Error;
public static makePlainError(err: Error): { name: string; message: string; stack: string };
public static makeError(obj: MakeErrorOptions): Error;
public static makePlainError(err: Error): MakeErrorOptions;
public static mergeDefault(def: unknown, given: unknown): unknown;
public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
public static parseEmoji(text: string): { animated: boolean; name: string; id: Snowflake | null } | null;
@@ -2132,15 +2114,15 @@ declare module 'discord.js' {
export class GuildChannelManager extends BaseManager<Snowflake, GuildChannel, GuildChannelResolvable> {
constructor(guild: Guild, iterable?: Iterable<any>);
public guild: Guild;
public create(name: string, options: GuildCreateChannelOptions & { type: 'voice' }): Promise<VoiceChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'category' }): Promise<CategoryChannel>;
public create(name: string, options?: GuildCreateChannelOptions & { type?: 'text' }): Promise<TextChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'news' }): Promise<NewsChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'store' }): Promise<StoreChannel>;
public create(name: string, options: GuildCreateChannelOptions & { type: 'stage' }): Promise<StageChannel>;
public create(name: string, options: GuildChannelCreateOptions & { type: 'voice' }): Promise<VoiceChannel>;
public create(name: string, options: GuildChannelCreateOptions & { type: 'category' }): Promise<CategoryChannel>;
public create(name: string, options?: GuildChannelCreateOptions & { type?: 'text' }): Promise<TextChannel>;
public create(name: string, options: GuildChannelCreateOptions & { type: 'news' }): Promise<NewsChannel>;
public create(name: string, options: GuildChannelCreateOptions & { type: 'store' }): Promise<StoreChannel>;
public create(name: string, options: GuildChannelCreateOptions & { type: 'stage' }): Promise<StageChannel>;
public create(
name: string,
options: GuildCreateChannelOptions,
options: GuildChannelCreateOptions,
): Promise<TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel>;
public fetch(
id: Snowflake,
@@ -2267,7 +2249,7 @@ declare module 'discord.js' {
export class ReactionUserManager extends BaseManager<Snowflake, User, UserResolvable> {
constructor(client: Client, iterable: Iterable<any> | undefined, reaction: MessageReaction);
public reaction: MessageReaction;
public fetch(options?: { limit?: number; after?: Snowflake }): Promise<Collection<Snowflake, User>>;
public fetch(options?: FetchReactionUsersOptions): Promise<Collection<Snowflake, User>>;
public remove(user?: UserResolvable): Promise<MessageReaction>;
}
@@ -2278,9 +2260,9 @@ declare module 'discord.js' {
public guild: Guild;
public readonly premiumSubscriberRole: Role | null;
public botRoleFor(user: UserResolvable): Role | null;
public create(options?: RoleData & { reason?: string }): Promise<Role>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role | null>;
public fetch(id?: Snowflake, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
public create(options?: CreateRoleOptions): Promise<Role>;
}
export class UserManager extends BaseManager<Snowflake, User, UserResolvable> {
@@ -2717,6 +2699,11 @@ declare module 'discord.js' {
dispose?: boolean;
}
interface CollectorResetTimerOptions {
time?: number;
idle?: number;
}
type ColorResolvable =
| 'DEFAULT'
| 'WHITE'
@@ -2764,6 +2751,10 @@ declare module 'discord.js' {
role?: Role | RawRole;
}
interface CreateRoleOptions extends RoleData {
reason?: string;
}
interface CrosspostedChannel {
channelID: Snowflake;
guildID: Snowflake;
@@ -2782,6 +2773,11 @@ declare module 'discord.js' {
type DefaultMessageNotifications = 'ALL' | 'MENTIONS';
interface EditGuildTemplateOptions {
name?: string;
description?: string;
}
interface EmbedField {
name: string;
value: string;
@@ -2877,6 +2873,11 @@ declare module 'discord.js' {
type FetchOwnerOptions = Omit<FetchMemberOptions, 'user'>;
interface FetchReactionUsersOptions {
limit?: number;
after?: Snowflake;
}
interface FileOptions {
attachment: BufferResolvable | Stream;
name?: string;
@@ -2962,7 +2963,7 @@ declare module 'discord.js' {
type GuildChannelResolvable = Snowflake | GuildChannel;
interface GuildCreateChannelOptions {
interface GuildChannelCreateOptions {
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
topic?: string;
type?: Exclude<
@@ -2978,12 +2979,12 @@ declare module 'discord.js' {
reason?: string;
}
interface GuildChannelCloneOptions extends GuildCreateChannelOptions {
interface GuildChannelCloneOptions extends GuildChannelCreateOptions {
name?: string;
}
interface GuildCreateOptions {
afkChannelID?: number;
afkChannelID?: Snowflake | number;
afkTimeout?: number;
channels?: PartialChannelData[];
defaultMessageNotifications?: DefaultMessageNotifications | number;
@@ -2991,7 +2992,7 @@ declare module 'discord.js' {
icon?: BufferResolvable | Base64Resolvable | null;
roles?: PartialRoleData[];
systemChannelFlags?: SystemChannelFlagsResolvable;
systemChannelID?: number;
systemChannelID?: Snowflake | number;
verificationLevel?: VerificationLevel | number;
}
@@ -3083,6 +3084,8 @@ declare module 'discord.js' {
cache?: boolean;
}
type GuildTemplateResolvable = string;
interface HTTPAttachmentData {
attachment: string | Buffer | Stream;
name: string;
@@ -3161,7 +3164,7 @@ declare module 'discord.js' {
additionalScopes?: InviteScope[];
}
interface InviteOptions {
interface CreateInviteOptions {
temporary?: boolean;
maxAge?: number;
maxUses?: number;
@@ -3187,7 +3190,11 @@ declare module 'discord.js' {
| 'gdm.join'
| 'webhook.incoming';
type GuildTemplateResolvable = string;
interface MakeErrorOptions {
name: string;
message: string;
stack: string;
}
type MembershipStates = 'INVITED' | 'ACCEPTED';
@@ -3324,6 +3331,12 @@ declare module 'discord.js' {
user: User;
}
interface MessageMentionsHasOptions {
ignoreDirect?: boolean;
ignoreRoles?: boolean;
ignoreEveryone?: boolean;
}
interface MessageMentionOptions {
parse?: MessageMentionTypes[];
roles?: Snowflake[];
@@ -3395,6 +3408,18 @@ declare module 'discord.js' {
type MFALevel = keyof typeof MFALevels;
interface MultipleShardRespawnOptions {
shardDelay?: number;
respawnDelay?: number;
timeout?: number;
}
interface MultipleShardSpawnOptions {
amount?: number | 'auto';
delay?: number;
timeout?: number;
}
type NSFWLevel = keyof typeof NSFWLevels;
interface OverwriteData {
@@ -3496,17 +3521,12 @@ declare module 'discord.js' {
}
interface PartialChannelData {
id?: number;
id?: Snowflake | number;
name: string;
topic?: string;
type?: ChannelType;
parentID?: number;
permissionOverwrites?: {
id: number | Snowflake;
type?: OverwriteType;
allow?: PermissionResolvable;
deny?: PermissionResolvable;
}[];
parentID?: Snowflake | number;
permissionOverwrites?: PartialOverwriteData[];
}
interface PartialGuildMember
@@ -3566,8 +3586,15 @@ declare module 'discord.js' {
readonly url: string;
}
interface PartialOverwriteData {
id: Snowflake | number;
type?: OverwriteType;
allow?: PermissionResolvable;
deny?: PermissionResolvable;
}
interface PartialRoleData extends RoleData {
id?: number;
id?: Snowflake | number;
}
type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION';
@@ -3640,6 +3667,21 @@ declare module 'discord.js' {
premiumSubscriberRole?: true;
}
interface SetChannelPositionOptions {
relative?: boolean;
reason?: string;
}
interface SetParentOptions {
lockPermissions?: boolean;
reason?: string;
}
interface SetRolePositionOptions {
relative?: boolean;
reason?: string;
}
type ShardingManagerMode = 'process' | 'worker';
interface ShardingManagerOptions {