mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add linked roles formatters (#10461)
* feat: add linked roles formatters * docs: requested changes Co-authored-by: Almeida <github@almeidx.dev> * docs: remove locale --------- Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
hyperlink,
|
hyperlink,
|
||||||
inlineCode,
|
inlineCode,
|
||||||
italic,
|
italic,
|
||||||
|
linkedRoleMention,
|
||||||
messageLink,
|
messageLink,
|
||||||
orderedList,
|
orderedList,
|
||||||
quote,
|
quote,
|
||||||
@@ -147,6 +148,12 @@ describe('Message formatters', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('linkedRoleMention', () => {
|
||||||
|
test('GIVEN roleId THEN returns "<id:linked-roles:[roleId]>"', () => {
|
||||||
|
expect(linkedRoleMention('815434166602170409')).toEqual('<id:linked-roles:815434166602170409>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('chatInputApplicationCommandMention', () => {
|
describe('chatInputApplicationCommandMention', () => {
|
||||||
test('GIVEN commandName and commandId THEN returns "</[commandName]:[commandId]>"', () => {
|
test('GIVEN commandName and commandId THEN returns "</[commandName]:[commandId]>"', () => {
|
||||||
expect(chatInputApplicationCommandMention('airhorn', '815434166602170409')).toEqual(
|
expect(chatInputApplicationCommandMention('airhorn', '815434166602170409')).toEqual(
|
||||||
|
|||||||
@@ -225,6 +225,16 @@ export function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${Rol
|
|||||||
return `<@&${roleId}>`;
|
return `<@&${roleId}>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a role id into a linked role mention.
|
||||||
|
*
|
||||||
|
* @typeParam RoleId - This is inferred by the supplied role id
|
||||||
|
* @param roleId - The role id to format
|
||||||
|
*/
|
||||||
|
export function linkedRoleMention<RoleId extends Snowflake>(roleId: RoleId): `<id:linked-roles:${RoleId}>` {
|
||||||
|
return `<id:linked-roles:${roleId}>`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
||||||
*
|
*
|
||||||
@@ -808,4 +818,8 @@ export enum GuildNavigationMentions {
|
|||||||
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
||||||
*/
|
*/
|
||||||
Guide = '<id:guide>',
|
Guide = '<id:guide>',
|
||||||
|
/**
|
||||||
|
* {@link https://support.discord.com/hc/articles/10388356626711 | Linked Roles} tab.
|
||||||
|
*/
|
||||||
|
LinkedRoles = '<id:linked-roles>',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user