fix(Message): Optional parameter for setting allowed mentions (#11338)

feat: allow empty allowed mentions

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Jiralite
2025-12-08 23:14:34 +00:00
committed by GitHub
parent fa43c40d34
commit d90a86a048
2 changed files with 14 additions and 1 deletions

View File

@@ -24,6 +24,19 @@ describe('Message', () => {
expect(() => message.toJSON()).toThrow();
});
test('GIVEN empty allowed mentions THEN return valid toJSON data', () => {
const allowedMentions = new AllowedMentionsBuilder();
expect(allowedMentions.toJSON()).toStrictEqual({});
const message = new MessageBuilder().setContent('test').setAllowedMentions();
expect(message.toJSON()).toStrictEqual({
...base,
allowed_mentions: {},
content: 'test',
});
});
test('GIVEN parse: [users] and empty users THEN return valid toJSON data', () => {
const allowedMentions = new AllowedMentionsBuilder();
allowedMentions.setUsers();

View File

@@ -239,7 +239,7 @@ export class MessageBuilder
allowedMentions:
| AllowedMentionsBuilder
| APIAllowedMentions
| ((builder: AllowedMentionsBuilder) => AllowedMentionsBuilder),
| ((builder: AllowedMentionsBuilder) => AllowedMentionsBuilder) = new AllowedMentionsBuilder(),
): this {
this.data.allowed_mentions = resolveBuilder(allowedMentions, AllowedMentionsBuilder);
return this;