Skip to content

Commit

Permalink
feat(APIApplicationCommand): add command localization (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Mar 23, 2022
1 parent e822e45 commit f702988
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deno/payloads/common.ts
@@ -1,3 +1,5 @@
import type { LocaleString } from '../v10.ts';

/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*
Expand Down Expand Up @@ -54,3 +56,5 @@ export const PermissionFlagsBits = {
* @internal
*/
Object.freeze(PermissionFlagsBits);

export type LocalizationMap = Partial<Record<LocaleString, string>>;
@@ -1,9 +1,12 @@
import type { LocalizationMap } from '../../../../../v10.ts';
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts';

export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
type: Type;
name: string;
name_localizations?: LocalizationMap;
description: string;
description_localizations?: LocalizationMap;
required?: boolean;
}

Expand Down
@@ -1,3 +1,5 @@
import type { LocalizationMap } from '../../../../../v10.ts';

/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
*/
Expand All @@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
*/
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
name: string;
name_localizations?: LocalizationMap;
value: ValueType;
}
9 changes: 9 additions & 0 deletions deno/payloads/v10/_interactions/applicationCommands.ts
@@ -1,4 +1,5 @@
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { LocalizationMap } from '../../../v10.ts';
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIBaseInteraction } from './base.ts';
Expand Down Expand Up @@ -45,10 +46,18 @@ export interface APIApplicationCommand {
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
*/
name: string;
/**
* Localization dictionary for the name field. Values follow the same restrictions as name
*/
name_localizations?: LocalizationMap;
/**
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
*/
description: string;
/**
* Localization dictionary for the description field. Values follow the same restrictions as description
*/
description_localizations?: LocalizationMap;
/**
* The parameters for the `CHAT_INPUT` command, max 25
*/
Expand Down
@@ -1,9 +1,12 @@
import type { LocalizationMap } from '../../../../../v9.ts';
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts';

export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
type: Type;
name: string;
name_localizations?: LocalizationMap;
description: string;
description_localizations?: LocalizationMap;
required?: boolean;
}

Expand Down
@@ -1,3 +1,5 @@
import type { LocalizationMap } from '../../../../../v9.ts';

/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
*/
Expand All @@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
*/
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
name: string;
name_localizations?: LocalizationMap;
value: ValueType;
}
9 changes: 9 additions & 0 deletions deno/payloads/v9/_interactions/applicationCommands.ts
@@ -1,4 +1,5 @@
import type { Permissions, Snowflake } from '../../../globals.ts';
import type { LocalizationMap } from '../../../v9.ts';
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIBaseInteraction } from './base.ts';
Expand Down Expand Up @@ -45,10 +46,18 @@ export interface APIApplicationCommand {
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
*/
name: string;
/**
* Localization dictionary for the name field. Values follow the same restrictions as name
*/
name_localizations?: LocalizationMap;
/**
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
*/
description: string;
/**
* Localization dictionary for the description field. Values follow the same restrictions as description
*/
description_localizations?: LocalizationMap;
/**
* The parameters for the `CHAT_INPUT` command, max 25
*/
Expand Down
4 changes: 4 additions & 0 deletions payloads/common.ts
@@ -1,3 +1,5 @@
import type { LocaleString } from '../v10';

/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*
Expand Down Expand Up @@ -54,3 +56,5 @@ export const PermissionFlagsBits = {
* @internal
*/
Object.freeze(PermissionFlagsBits);

export type LocalizationMap = Partial<Record<LocaleString, string>>;
@@ -1,9 +1,12 @@
import type { LocalizationMap } from '../../../../../v10';
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared';

export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
type: Type;
name: string;
name_localizations?: LocalizationMap;
description: string;
description_localizations?: LocalizationMap;
required?: boolean;
}

Expand Down
@@ -1,3 +1,5 @@
import type { LocalizationMap } from '../../../../../v10';

/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
*/
Expand All @@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
*/
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
name: string;
name_localizations?: LocalizationMap;
value: ValueType;
}
9 changes: 9 additions & 0 deletions payloads/v10/_interactions/applicationCommands.ts
@@ -1,4 +1,5 @@
import type { Permissions, Snowflake } from '../../../globals';
import type { LocalizationMap } from '../../../v10';
import type { APIPartialChannel, APIThreadMetadata } from '../channel';
import type { APIGuildMember } from '../guild';
import type { APIBaseInteraction } from './base';
Expand Down Expand Up @@ -45,10 +46,18 @@ export interface APIApplicationCommand {
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
*/
name: string;
/**
* Localization dictionary for the name field. Values follow the same restrictions as name
*/
name_localizations?: LocalizationMap;
/**
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
*/
description: string;
/**
* Localization dictionary for the description field. Values follow the same restrictions as description
*/
description_localizations?: LocalizationMap;
/**
* The parameters for the `CHAT_INPUT` command, max 25
*/
Expand Down
@@ -1,9 +1,12 @@
import type { LocalizationMap } from '../../../../../v9';
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared';

export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
type: Type;
name: string;
name_localizations?: LocalizationMap;
description: string;
description_localizations?: LocalizationMap;
required?: boolean;
}

Expand Down
@@ -1,3 +1,5 @@
import type { LocalizationMap } from '../../../../../v9';

/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
*/
Expand All @@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
*/
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
name: string;
name_localizations?: LocalizationMap;
value: ValueType;
}
9 changes: 9 additions & 0 deletions payloads/v9/_interactions/applicationCommands.ts
@@ -1,4 +1,5 @@
import type { Permissions, Snowflake } from '../../../globals';
import type { LocalizationMap } from '../../../v9';
import type { APIPartialChannel, APIThreadMetadata } from '../channel';
import type { APIGuildMember } from '../guild';
import type { APIBaseInteraction } from './base';
Expand Down Expand Up @@ -45,10 +46,18 @@ export interface APIApplicationCommand {
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
*/
name: string;
/**
* Localization dictionary for the name field. Values follow the same restrictions as name
*/
name_localizations?: LocalizationMap;
/**
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
*/
description: string;
/**
* Localization dictionary for the description field. Values follow the same restrictions as description
*/
description_localizations?: LocalizationMap;
/**
* The parameters for the `CHAT_INPUT` command, max 25
*/
Expand Down

0 comments on commit f702988

Please sign in to comment.