From 0dc5dd5808af213ac4ede9f1084b522225a5c661 Mon Sep 17 00:00:00 2001 From: DTrombett <73136330+DTrombett@users.noreply.github.com> Date: Sat, 3 Jul 2021 09:58:18 +0200 Subject: [PATCH] types(*): create mention types (#6003) --- typings/index.d.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 613f9fb0d..9aea995c4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -439,7 +439,7 @@ declare module 'discord.js' { public fetch(force?: boolean): Promise; public isText(): this is TextChannel | DMChannel | NewsChannel | ThreadChannel; public isThread(): this is ThreadChannel; - public toString(): string; + public toString(): ChannelMention; } export class Client extends BaseClient { @@ -1103,7 +1103,7 @@ declare module 'discord.js' { public permissionsIn(channel: GuildChannelResolvable): Readonly; public setNickname(nickname: string | null, reason?: string): Promise; public toJSON(): unknown; - public toString(): string; + public toString(): MemberMention; public valueOf(): string; } @@ -1757,7 +1757,7 @@ declare module 'discord.js' { public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; public setPosition(position: number, options?: SetRolePositionOptions): Promise; public toJSON(): unknown; - public toString(): string; + public toString(): RoleMention; public static comparePositions(role1: Role, role2: Role): number; } @@ -2052,7 +2052,7 @@ declare module 'discord.js' { public equals(user: User): boolean; public fetch(force?: boolean): Promise; public fetchFlags(force?: boolean): Promise; - public toString(): string; + public toString(): UserMention; public typingDurationIn(channel: ChannelResolvable): number; public typingIn(channel: ChannelResolvable): boolean; public typingSinceIn(channel: ChannelResolvable): Date; @@ -3034,6 +3034,8 @@ declare module 'discord.js' { around?: Snowflake; } + type ChannelMention = `<#${Snowflake}>`; + interface ChannelPosition { channel: ChannelResolvable; lockPermissions?: boolean; @@ -3715,6 +3717,8 @@ declare module 'discord.js' { stack: string; } + type MemberMention = UserMention | `<@!${Snowflake}>`; + type MembershipState = keyof typeof MembershipStates; type MessageActionRowComponent = MessageButton | MessageSelectMenu; @@ -4214,6 +4218,8 @@ declare module 'discord.js' { mentionable?: boolean; } + type RoleMention = '@everyone' | `<@&${Snowflake}>`; + interface RolePosition { role: RoleResolvable; position: number; @@ -4343,6 +4349,8 @@ declare module 'discord.js' { | 'EARLY_VERIFIED_BOT_DEVELOPER' | 'DISCORD_CERTIFIED_MODERATOR'; + type UserMention = `<@${Snowflake}>`; + type UserResolvable = User | Snowflake | Message | GuildMember | ThreadMember; interface Vanity {