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,4 +1,8 @@
import type { APIApplicationCommandOption, RESTPostAPIApplicationCommandsJSONBody } from 'discord-api-types/v10';
import type {
APIApplicationCommandOption,
LocalizationMap,
RESTPostAPIApplicationCommandsJSONBody,
} from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import {
assertReturnOfBuilder,
@@ -17,11 +21,21 @@ export class SlashCommandBuilder {
*/
public readonly name: string = undefined!;
/**
* The localized names for this command
*/
public readonly name_localizations?: LocalizationMap;
/**
* The description of this slash command
*/
public readonly description: string = undefined!;
/**
* The localized descriptions for this command
*/
public readonly description_localizations?: LocalizationMap;
/**
* The options of this slash command
*/
@@ -44,7 +58,9 @@ export class SlashCommandBuilder {
return {
name: this.name,
name_localizations: this.name_localizations,
description: this.description,
description_localizations: this.description_localizations,
options: this.options.map((option) => option.toJSON()),
default_permission: this.defaultPermission,
};