Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ export const DiscordKeys = Object.freeze({
MAX_MEMBERS: 'max_members',
MAX_PRESENCES: 'max_presences',
MAX_USES: 'max_uses',
MAX_VALUE: 'max_value',
MAX_VALUES: 'max_values',
MAX_VIDEO_CHANNEL_USERS: 'max_video_channel_users',
ME: 'me',
Expand All @@ -1549,6 +1550,7 @@ export const DiscordKeys = Object.freeze({
MFA_ENABLED: 'mfa_enabled',
MFA_LEVEL: 'mfa_level',
MIME_TYPE: 'mime_type',
MIN_VALUE: 'min_value',
MIN_VALUES: 'min_values',
MOBILE: 'mobile',
MUTE: 'mute',
Expand Down Expand Up @@ -1900,6 +1902,7 @@ export const DetritusKeys = Object.freeze({
[DiscordKeys.MAX_PRESENCES]: 'maxPresences',
[DiscordKeys.MAX_USES]: 'maxUses',
[DiscordKeys.MAX_VALUES]: 'maxValues',
[DiscordKeys.MAX_VALUE]: 'maxValue',
[DiscordKeys.MAX_VIDEO_CHANNEL_USERS]: 'maxVideoChannelUsers',
[DiscordKeys.ME]: 'me',
[DiscordKeys.MEMBER]: 'member',
Expand All @@ -1922,6 +1925,7 @@ export const DetritusKeys = Object.freeze({
[DiscordKeys.MFA_LEVEL]: 'mfaLevel',
[DiscordKeys.MIME_TYPE]: 'mimeType',
[DiscordKeys.MIN_VALUES]: 'minValues',
[DiscordKeys.MIN_VALUE]: 'minValue',
[DiscordKeys.MOBILE]: 'mobile',
[DiscordKeys.MUTE]: 'mute',
[DiscordKeys.MUTUAL_GUILDS]: 'mutualGuilds',
Expand Down
13 changes: 13 additions & 0 deletions src/interaction/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export interface InteractionCommandOptionOptions {
ratelimits?: Array<CommandRatelimitOptions>,
triggerLoadingAfter?: number,
triggerLoadingAsEphemeral?: boolean,
minValue?: number,
maxValue?: number,

onAutoComplete?: CommandCallbackAutoComplete,
onAutoCompleteError?: CommandCallbackAutoCompleteError,
Expand Down Expand Up @@ -574,6 +576,8 @@ const keysInteractionCommandOption = new BaseSet<string>([
DiscordKeys.OPTIONS,
DiscordKeys.REQUIRED,
DiscordKeys.TYPE,
DiscordKeys.MAX_VALUE,
DiscordKeys.MIN_VALUE,
]);

export class InteractionCommandOption<ParsedArgsFinished = ParsedArgs> extends Structure {
Expand All @@ -589,6 +593,8 @@ export class InteractionCommandOption<ParsedArgsFinished = ParsedArgs> extends S
name: string = '';
required?: boolean;
type: ApplicationCommandOptionTypes = ApplicationCommandOptionTypes.STRING;
minValue?: number;
maxValue?: number;

default?: ArgumentDefault;
disableDm?: boolean;
Expand Down Expand Up @@ -621,6 +627,13 @@ export class InteractionCommandOption<ParsedArgsFinished = ParsedArgs> extends S

constructor(data: InteractionCommandOptionOptions = {}) {
super();
if (DetritusKeys[DiscordKeys.MIN_VALUE] in data) {
(data as any)[DiscordKeys.MIN_VALUE] = (data as any)[DetritusKeys[DiscordKeys.MIN_VALUE]];
}

if (DetritusKeys[DiscordKeys.MAX_VALUE] in data) {
(data as any)[DiscordKeys.MAX_VALUE] = (data as any)[DetritusKeys[DiscordKeys.MAX_VALUE]];
}

this.disableDm = (data.disableDm !== undefined) ? !!data.disableDm : this.disableDm;
this.label = data.label || this.label;
Expand Down