fix: Adjust label predicates (#11318)

* fix: labels in 14

* test: add variable for at limit

* docs(jsonOptionValidator): deprecate

* fix: export `selectMenuStringOptionPredicate`

* fix: export everything

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>

---------

Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com>
This commit is contained in:
Jiralite
2025-11-30 18:38:46 +00:00
committed by GitHub
parent e77793898a
commit 61251cfcb8
5 changed files with 18 additions and 10 deletions

View File

@@ -6,6 +6,10 @@ const selectMenu = () => new StringSelectMenuBuilder();
const selectMenuOption = () => new StringSelectMenuOptionBuilder();
const longStr = 'a'.repeat(256);
const selectMenuOptionLabelAtLimit = 'a'.repeat(100);
const selectMenuOptionLabelAboveLimit = 'a'.repeat(101);
const selectMenuOptionValueAboveLimit = 'a'.repeat(101);
const selectMenuOptionDescriptionAboveLimit = 'a'.repeat(101);
const selectMenuOptionData: APISelectMenuOption = {
label: 'test',
@@ -53,12 +57,12 @@ describe('Select Menu Components', () => {
expect(() => selectMenu().setDisabled()).not.toThrowError();
expect(() => selectMenu().setPlaceholder('description')).not.toThrowError();
const option = selectMenuOption()
.setLabel('test')
.setLabel(selectMenuOptionLabelAtLimit)
.setValue('test')
.setDefault(true)
.setEmoji({ name: 'test' })
.setDescription('description');
expect(() => selectMenu().addOptions(option)).not.toThrowError();
expect(() => selectMenu().setCustomId('customId').addOptions(option).toJSON()).not.toThrowError();
expect(() => selectMenu().setOptions(option)).not.toThrowError();
expect(() => selectMenu().setOptions({ label: 'test', value: 'test' })).not.toThrowError();
expect(() => selectMenu().addOptions([option])).not.toThrowError();
@@ -156,13 +160,13 @@ describe('Select Menu Components', () => {
expect(() => {
selectMenuOption()
.setLabel(longStr)
.setValue(longStr)
.setLabel(selectMenuOptionLabelAboveLimit)
.setValue(selectMenuOptionValueAboveLimit)
// @ts-expect-error: Invalid default value
.setDefault(-1)
// @ts-expect-error: Invalid emoji
.setEmoji({ name: 1 })
.setDescription(longStr);
.setDescription(selectMenuOptionDescriptionAboveLimit);
}).toThrowError();
});