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:
Danial Raza
2024-10-06 16:19:50 +02:00
committed by GitHub
parent 12e510671b
commit 04df3c4130
2 changed files with 21 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import {
hyperlink,
inlineCode,
italic,
linkedRoleMention,
messageLink,
orderedList,
quote,
@@ -145,6 +146,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', () => {
test('GIVEN commandName and commandId THEN returns "</[commandName]:[commandId]>"', () => {
expect(chatInputApplicationCommandMention('airhorn', '815434166602170409')).toEqual(

View File

@@ -225,6 +225,16 @@ export function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${Rol
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.
*
@@ -754,4 +764,8 @@ export enum GuildNavigationMentions {
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
*/
Guide = '<id:guide>',
/**
* {@link https://support.discord.com/hc/articles/10388356626711 | Linked Roles} tab.
*/
LinkedRoles = '<id:linked-roles>',
}