Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add linked roles formatters #10461

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>',
/**
* {@link https://support.discord.com/hc/en-us/articles/10388356626711 | Linked Roles} tab.
*/
LinkedRoles = '<id:linked-roles>',
}
Loading