Skip to content

Commit

Permalink
feat: add linked roles formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
sdanialraza authored Aug 26, 2024
1 parent 4374374 commit c583790
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/formatters/__tests__/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
hyperlink,
inlineCode,
italic,
linkedRoleMention,
messageLink,
orderedList,
quote,
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions packages/formatters/src/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -754,4 +764,8 @@ export enum GuildNavigationMentions {
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
*/
Guide = '<id:guide>',
/**
* Linked Roles tab.
*/
LinkedRoles = '<id:linked-roles>',
}

0 comments on commit c583790

Please sign in to comment.