feat(typings): use readonly arrays in parameters (#4692)

Co-authored-by: Noel <icrawltogo@gmail.com>
This commit is contained in:
cherryblossom000
2020-08-14 04:43:51 +10:00
committed by GitHub
parent f991bd46f3
commit f451be0519

56
typings/index.d.ts vendored
View File

@@ -65,7 +65,7 @@ declare module 'discord.js' {
extra?: MessageOptions | WebhookMessageOptions, extra?: MessageOptions | WebhookMessageOptions,
): APIMessage; ): APIMessage;
public static partitionMessageAdditions( public static partitionMessageAdditions(
items: (MessageEmbed | MessageAttachment)[], items: readonly (MessageEmbed | MessageAttachment)[],
): [MessageEmbed[], MessageAttachment[]]; ): [MessageEmbed[], MessageAttachment[]];
public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<object>; public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<object>;
public static transformOptions( public static transformOptions(
@@ -692,7 +692,7 @@ declare module 'discord.js' {
public setAFKChannel(afkChannel: ChannelResolvable | null, reason?: string): Promise<Guild>; public setAFKChannel(afkChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>; public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
public setBanner(banner: Base64Resolvable | null, reason?: string): Promise<Guild>; public setBanner(banner: Base64Resolvable | null, reason?: string): Promise<Guild>;
public setChannelPositions(channelPositions: ChannelPosition[]): Promise<Guild>; public setChannelPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
public setDefaultMessageNotifications( public setDefaultMessageNotifications(
defaultMessageNotifications: DefaultMessageNotifications | number, defaultMessageNotifications: DefaultMessageNotifications | number,
reason?: string, reason?: string,
@@ -706,7 +706,7 @@ declare module 'discord.js' {
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>; public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
public setPublicUpdatesChannel(publicUpdatesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>; public setPublicUpdatesChannel(publicUpdatesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setRegion(region: string, reason?: string): Promise<Guild>; public setRegion(region: string, reason?: string): Promise<Guild>;
public setRolePositions(rolePositions: RolePosition[]): Promise<Guild>; public setRolePositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
public setRulesChannel(rulesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>; public setRulesChannel(rulesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setSplash(splash: Base64Resolvable | null, reason?: string): Promise<Guild>; public setSplash(splash: Base64Resolvable | null, reason?: string): Promise<Guild>;
public setSystemChannel(systemChannel: ChannelResolvable | null, reason?: string): Promise<Guild>; public setSystemChannel(systemChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
@@ -781,7 +781,7 @@ declare module 'discord.js' {
public fetchInvites(): Promise<Collection<string, Invite>>; public fetchInvites(): Promise<Collection<string, Invite>>;
public lockPermissions(): Promise<this>; public lockPermissions(): Promise<this>;
public overwritePermissions( public overwritePermissions(
overwrites: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>, overwrites: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>,
reason?: string, reason?: string,
): Promise<this>; ): Promise<this>;
public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null; public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly<Permissions> | null;
@@ -1897,9 +1897,13 @@ declare module 'discord.js' {
public emoji: GuildEmoji; public emoji: GuildEmoji;
public guild: Guild; public guild: Guild;
public cache: Collection<Snowflake, Role>; public cache: Collection<Snowflake, Role>;
public add(roleOrRoles: RoleResolvable | RoleResolvable[] | Collection<Snowflake, Role>): Promise<GuildEmoji>; public add(
public set(roles: RoleResolvable[] | Collection<Snowflake, Role>): Promise<GuildEmoji>; roleOrRoles: RoleResolvable | readonly RoleResolvable[] | Collection<Snowflake, Role>,
public remove(roleOrRoles: RoleResolvable | RoleResolvable[] | Collection<Snowflake, Role>): Promise<GuildEmoji>; ): Promise<GuildEmoji>;
public set(roles: readonly RoleResolvable[] | Collection<Snowflake, Role>): Promise<GuildEmoji>;
public remove(
roleOrRoles: RoleResolvable | readonly RoleResolvable[] | Collection<Snowflake, Role>,
): Promise<GuildEmoji>;
} }
export class GuildManager extends BaseManager<Snowflake, Guild, GuildResolvable> { export class GuildManager extends BaseManager<Snowflake, Guild, GuildResolvable> {
@@ -1932,12 +1936,12 @@ declare module 'discord.js' {
public guild: Guild; public guild: Guild;
public add( public add(
roleOrRoles: RoleResolvable | RoleResolvable[] | Collection<Snowflake, Role>, roleOrRoles: RoleResolvable | readonly RoleResolvable[] | Collection<Snowflake, Role>,
reason?: string, reason?: string,
): Promise<GuildMember>; ): Promise<GuildMember>;
public set(roles: RoleResolvable[] | Collection<Snowflake, Role>, reason?: string): Promise<GuildMember>; public set(roles: readonly RoleResolvable[] | Collection<Snowflake, Role>, reason?: string): Promise<GuildMember>;
public remove( public remove(
roleOrRoles: RoleResolvable | RoleResolvable[] | Collection<Snowflake, Role>, roleOrRoles: RoleResolvable | readonly RoleResolvable[] | Collection<Snowflake, Role>,
reason?: string, reason?: string,
): Promise<GuildMember>; ): Promise<GuildMember>;
} }
@@ -2043,7 +2047,7 @@ declare module 'discord.js' {
typingCount: number; typingCount: number;
awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>; awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
bulkDelete( bulkDelete(
messages: Collection<Snowflake, Message> | MessageResolvable[] | number, messages: Collection<Snowflake, Message> | readonly MessageResolvable[] | number,
filterOld?: boolean, filterOld?: boolean,
): Promise<Collection<Snowflake, Message>>; ): Promise<Collection<Snowflake, Message>>;
createMessageCollector(filter: CollectorFilter, options?: MessageCollectorOptions): MessageCollector; createMessageCollector(filter: CollectorFilter, options?: MessageCollectorOptions): MessageCollector;
@@ -2087,7 +2091,7 @@ declare module 'discord.js' {
name?: string; name?: string;
url?: string; url?: string;
type?: ActivityType | number; type?: ActivityType | number;
shardID?: number | number[]; shardID?: number | readonly number[];
} }
type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS'; type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS';
@@ -2154,11 +2158,11 @@ declare module 'discord.js' {
} }
interface AwaitMessagesOptions extends MessageCollectorOptions { interface AwaitMessagesOptions extends MessageCollectorOptions {
errors?: string[]; errors?: readonly string[];
} }
interface AwaitReactionsOptions extends ReactionCollectorOptions { interface AwaitReactionsOptions extends ReactionCollectorOptions {
errors?: string[]; errors?: readonly string[];
} }
interface BanOptions { interface BanOptions {
@@ -2194,7 +2198,7 @@ declare module 'discord.js' {
parentID?: Snowflake; parentID?: Snowflake;
rateLimitPerUser?: number; rateLimitPerUser?: number;
lockPermissions?: boolean; lockPermissions?: boolean;
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>; permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
} }
interface ChannelLogsQueryOptions { interface ChannelLogsQueryOptions {
@@ -2432,7 +2436,7 @@ declare module 'discord.js' {
} }
interface FetchMembersOptions { interface FetchMembersOptions {
user?: UserResolvable | UserResolvable[]; user?: UserResolvable | readonly UserResolvable[];
query?: string; query?: string;
limit?: number; limit?: number;
withPresences?: boolean; withPresences?: boolean;
@@ -2515,7 +2519,7 @@ declare module 'discord.js' {
type GuildChannelResolvable = Snowflake | GuildChannel; type GuildChannelResolvable = Snowflake | GuildChannel;
interface GuildCreateChannelOptions { interface GuildCreateChannelOptions {
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>; permissionOverwrites?: readonly OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
topic?: string; topic?: string;
type?: Exclude< type?: Exclude<
keyof typeof ChannelType | ChannelType, keyof typeof ChannelType | ChannelType,
@@ -2560,13 +2564,13 @@ declare module 'discord.js' {
} }
interface GuildEmojiCreateOptions { interface GuildEmojiCreateOptions {
roles?: Collection<Snowflake, Role> | RoleResolvable[]; roles?: Collection<Snowflake, Role> | readonly RoleResolvable[];
reason?: string; reason?: string;
} }
interface GuildEmojiEditData { interface GuildEmojiEditData {
name?: string; name?: string;
roles?: Collection<Snowflake, Role> | RoleResolvable[]; roles?: Collection<Snowflake, Role> | readonly RoleResolvable[];
} }
type GuildFeatures = type GuildFeatures =
@@ -2586,7 +2590,7 @@ declare module 'discord.js' {
interface GuildMemberEditData { interface GuildMemberEditData {
nick?: string; nick?: string;
roles?: Collection<Snowflake, Role> | RoleResolvable[]; roles?: Collection<Snowflake, Role> | readonly RoleResolvable[];
mute?: boolean; mute?: boolean;
deaf?: boolean; deaf?: boolean;
channel?: ChannelResolvable | null; channel?: ChannelResolvable | null;
@@ -2713,8 +2717,8 @@ declare module 'discord.js' {
url?: string; url?: string;
timestamp?: Date | number; timestamp?: Date | number;
color?: ColorResolvable; color?: ColorResolvable;
fields?: EmbedFieldData[]; fields?: readonly EmbedFieldData[];
files?: (MessageAttachment | string | FileOptions)[]; files?: readonly (MessageAttachment | string | FileOptions)[];
author?: Partial<MessageEmbedAuthor> & { icon_url?: string; proxy_icon_url?: string }; author?: Partial<MessageEmbedAuthor> & { icon_url?: string; proxy_icon_url?: string };
thumbnail?: Partial<MessageEmbedThumbnail> & { proxy_url?: string }; thumbnail?: Partial<MessageEmbedThumbnail> & { proxy_url?: string };
image?: Partial<MessageEmbedImage> & { proxy_url?: string }; image?: Partial<MessageEmbedImage> & { proxy_url?: string };
@@ -2764,7 +2768,7 @@ declare module 'discord.js' {
embed?: MessageEmbed | MessageEmbedOptions; embed?: MessageEmbed | MessageEmbedOptions;
disableMentions?: 'none' | 'all' | 'everyone'; disableMentions?: 'none' | 'all' | 'everyone';
allowedMentions?: MessageMentionOptions; allowedMentions?: MessageMentionOptions;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[]; files?: readonly (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
code?: string | boolean; code?: string | boolean;
split?: boolean | SplitOptions; split?: boolean | SplitOptions;
reply?: UserResolvable; reply?: UserResolvable;
@@ -2851,7 +2855,7 @@ declare module 'discord.js' {
| 'MANAGE_WEBHOOKS' | 'MANAGE_WEBHOOKS'
| 'MANAGE_EMOJIS'; | 'MANAGE_EMOJIS';
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {} interface RecursiveArray<T> extends ReadonlyArray<T | RecursiveArray<T>> {}
type RecursiveReadonlyArray<T> = ReadonlyArray<T | RecursiveReadonlyArray<T>>; type RecursiveReadonlyArray<T> = ReadonlyArray<T | RecursiveReadonlyArray<T>>;
@@ -3094,10 +3098,10 @@ declare module 'discord.js' {
avatarURL?: string; avatarURL?: string;
tts?: boolean; tts?: boolean;
nonce?: string; nonce?: string;
embeds?: (MessageEmbed | object)[]; embeds?: readonly (MessageEmbed | object)[];
disableMentions?: 'none' | 'all' | 'everyone'; disableMentions?: 'none' | 'all' | 'everyone';
allowedMentions?: MessageMentionOptions; allowedMentions?: MessageMentionOptions;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[]; files?: readonly (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
code?: string | boolean; code?: string | boolean;
split?: boolean | SplitOptions; split?: boolean | SplitOptions;
} }