-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
SelectMenuOption.ts
30 lines (26 loc) · 942 Bytes
/
SelectMenuOption.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v9';
import {
defaultValidator,
emojiValidator,
labelValueValidator,
validateRequiredSelectMenuOptionParameters,
} from '../Assertions';
import { UnsafeSelectMenuOption } from './UnsafeSelectMenuOption';
/**
* Represents a validated option within a select menu component
*/
export class SelectMenuOption extends UnsafeSelectMenuOption {
public override setDescription(description: string) {
return super.setDescription(labelValueValidator.parse(description));
}
public override setDefault(isDefault = true) {
return super.setDefault(defaultValidator.parse(isDefault));
}
public override setEmoji(emoji: APIMessageComponentEmoji) {
return super.setEmoji(emojiValidator.parse(emoji));
}
public override toJSON(): APISelectMenuOption {
validateRequiredSelectMenuOptionParameters(this.label, this.value);
return super.toJSON();
}
}