diff --git a/packages/builders/__tests__/messages/formatters.test.ts b/packages/builders/__tests__/messages/formatters.test.ts index 9276a4a11059..b787f18a30dd 100644 --- a/packages/builders/__tests__/messages/formatters.test.ts +++ b/packages/builders/__tests__/messages/formatters.test.ts @@ -9,7 +9,6 @@ import { hyperlink, inlineCode, italic, - memberNicknameMention, quote, roleMention, spoiler, @@ -122,12 +121,6 @@ describe('Message formatters', () => { }); }); - describe('memberNicknameMention', () => { - test('GIVEN memberId THEN returns "<@![memberId]>"', () => { - expect(memberNicknameMention('139836912335716352')).toBe('<@!139836912335716352>'); - }); - }); - describe('channelMention', () => { test('GIVEN channelId THEN returns "<#[channelId]>"', () => { expect(channelMention('829924760309334087')).toBe('<#829924760309334087>'); diff --git a/packages/builders/src/messages/formatters.ts b/packages/builders/src/messages/formatters.ts index 2f3463e79fe9..9594ffefe04d 100644 --- a/packages/builders/src/messages/formatters.ts +++ b/packages/builders/src/messages/formatters.ts @@ -164,15 +164,6 @@ export function userMention(userId: C): `<@${C}>` { return `<@${userId}>`; } -/** - * Formats a user ID into a member-nickname mention - * - * @param memberId The user ID to format - */ -export function memberNicknameMention(memberId: C): `<@!${C}>` { - return `<@!${memberId}>`; -} - /** * Formats a channel ID into a channel mention * diff --git a/packages/discord.js/src/structures/GuildMember.js b/packages/discord.js/src/structures/GuildMember.js index 3d4f6d280e5f..f49876da48b4 100644 --- a/packages/discord.js/src/structures/GuildMember.js +++ b/packages/discord.js/src/structures/GuildMember.js @@ -428,7 +428,7 @@ class GuildMember extends Base { * console.log(`Hello from ${member}!`); */ toString() { - return `<@${this.nickname ? '!' : ''}${this.user.id}>`; + return this.user.toString(); } toJSON() { diff --git a/packages/discord.js/src/structures/User.js b/packages/discord.js/src/structures/User.js index c80625c26edd..75189c8c6dcb 100644 --- a/packages/discord.js/src/structures/User.js +++ b/packages/discord.js/src/structures/User.js @@ -1,5 +1,6 @@ 'use strict'; +const { userMention } = require('@discordjs/builders'); const { DiscordSnowflake } = require('@sapphire/snowflake'); const Base = require('./Base'); const TextBasedChannel = require('./interfaces/TextBasedChannel'); @@ -286,7 +287,7 @@ class User extends Base { * console.log(`Hello from ${user}!`); */ toString() { - return `<@${this.id}>`; + return userMention(this.id); } toJSON(...props) { diff --git a/packages/discord.js/src/util/Formatters.js b/packages/discord.js/src/util/Formatters.js index b680ce10600e..7e6999593a03 100644 --- a/packages/discord.js/src/util/Formatters.js +++ b/packages/discord.js/src/util/Formatters.js @@ -10,7 +10,6 @@ const { hyperlink, inlineCode, italic, - memberNicknameMention, quote, roleMention, spoiler, @@ -111,15 +110,6 @@ class Formatters extends null { */ static italic = italic; - /** - * Formats a user id into a member-nickname mention. - * @method memberNicknameMention - * @memberof Formatters - * @param {string} memberId The user id to format. - * @returns {string} - */ - static memberNicknameMention = memberNicknameMention; - /** * Formats the content into a quote. This needs to be at the start of the line for Discord to format it. * @method quote diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 115583679f3b..682d440bd94d 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -14,7 +14,6 @@ import { italic, JSONEncodable, MappedComponentTypes, - memberNicknameMention, quote, roleMention, SelectMenuBuilder as BuilderSelectMenuComponent, @@ -1281,7 +1280,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) { public permissionsIn(channel: GuildChannelResolvable): Readonly; public setNickname(nickname: string | null, reason?: string): Promise; public toJSON(): unknown; - public toString(): MemberMention; + public toString(): UserMention; public valueOf(): string; } @@ -2554,7 +2553,6 @@ export class Formatters extends null { public static hyperlink: typeof hyperlink; public static inlineCode: typeof inlineCode; public static italic: typeof italic; - public static memberNicknameMention: typeof memberNicknameMention; public static quote: typeof quote; public static roleMention: typeof roleMention; public static spoiler: typeof spoiler; @@ -4668,8 +4666,6 @@ export interface MakeErrorOptions { stack: string; } -export type MemberMention = UserMention | `<@!${Snowflake}>`; - export type ActionRowComponentOptions = | (Required & ButtonComponentData) | (Required & SelectMenuComponentData);