feat: Slash command localization for builders (#7683)

* feat: add slash command localizations

* chore: make requested changes

* chore: make requested changes

* fix: prevent unnecessary spread

* chore: make requested changes

* chore: don't allow maps
This commit is contained in:
Suneet Tipirneni
2022-04-17 04:58:20 -04:00
committed by GitHub
parent ab4c608b97
commit 40b9a1d67d
6 changed files with 172 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import is from '@sindresorhus/is';
import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v10';
import { type APIApplicationCommandOptionChoice, Locale } from 'discord-api-types/v10';
import { s } from '@sapphire/shapeshift';
import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
@@ -15,12 +15,16 @@ export function validateName(name: unknown): asserts name is string {
}
const descriptionPredicate = s.string.lengthGe(1).lengthLe(100);
const localePredicate = s.nativeEnum(Locale);
export function validateDescription(description: unknown): asserts description is string {
descriptionPredicate.parse(description);
}
const maxArrayLengthPredicate = s.unknown.array.lengthLe(25);
export function validateLocale(locale: unknown) {
return localePredicate.parse(locale);
}
export function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {
maxArrayLengthPredicate.parse(options);