Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Locales): add locale string enum #297

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions deno/payloads/v8/_interactions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InteractionType } from './responses.ts';
import type { APIMessage } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';
import type { LocaleString } from '../../../v8.ts';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object
Expand Down Expand Up @@ -89,11 +90,11 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* The selected language of the invoking user
*/
locale: string;
locale: LocaleString;
/**
* The guild's preferred locale, if invoked in a guild
*/
guild_locale?: string;
guild_locale?: LocaleString;
}

export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Expand Down
5 changes: 3 additions & 2 deletions deno/payloads/v9/_interactions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InteractionType } from './responses.ts';
import type { APIMessage } from '../channel.ts';
import type { APIGuildMember } from '../guild.ts';
import type { APIUser } from '../user.ts';
import type { LocaleString } from '../../../v9.ts';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object
Expand Down Expand Up @@ -89,11 +90,11 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* The selected language of the invoking user
*/
locale: string;
locale: LocaleString;
/**
* The guild's preferred locale, if invoked in a guild
*/
guild_locale?: string;
guild_locale?: LocaleString;
}

export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Expand Down
35 changes: 35 additions & 0 deletions deno/rest/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,38 @@ export enum RESTJSONErrorCodes {

FailedToCreateStageNeededForStageEvent = 180002,
}

export enum Locale {
EnglishUS = 'en-US',
EnglishGB = 'en-GB',
Bulgarian = 'bg',
ChineseCN = 'zh-CN',
ChineseTW = 'zh-TW',
Croatian = 'hr',
Czech = 'cs',
Danish = 'da',
Dutch = 'nl',
Finnish = 'fi',
French = 'fr',
German = 'de',
Greek = 'el',
Hindi = 'hi',
Hungarian = 'hu',
Italian = 'it',
Japanese = 'ja',
Korean = 'ko',
Lithuanian = 'lt',
Norwegian = 'no',
Polish = 'pl',
PortugueseBR = 'pt-BR',
Romanian = 'ro',
Russian = 'ru',
SpanishES = 'es-ES',
Swedish = 'sv-SE',
Thai = 'th',
Turkish = 'tr',
Ukrainian = 'uk',
Vietnamese = 'vi',
}

export type LocaleString = `${Locale}`;
5 changes: 3 additions & 2 deletions payloads/v8/_interactions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InteractionType } from './responses';
import type { APIMessage } from '../channel';
import type { APIGuildMember } from '../guild';
import type { APIUser } from '../user';
import type { LocaleString } from '../../../v8';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object
Expand Down Expand Up @@ -89,11 +90,11 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* The selected language of the invoking user
*/
locale: string;
locale: LocaleString;
/**
* The guild's preferred locale, if invoked in a guild
*/
guild_locale?: string;
guild_locale?: LocaleString;
}

export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Expand Down
5 changes: 3 additions & 2 deletions payloads/v9/_interactions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InteractionType } from './responses';
import type { APIMessage } from '../channel';
import type { APIGuildMember } from '../guild';
import type { APIUser } from '../user';
import type { LocaleString } from '../../../v9';

/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object
Expand Down Expand Up @@ -89,11 +90,11 @@ export interface APIBaseInteraction<Type extends InteractionType, Data> {
/**
* The selected language of the invoking user
*/
locale: string;
locale: LocaleString;
/**
* The guild's preferred locale, if invoked in a guild
*/
guild_locale?: string;
guild_locale?: LocaleString;
}

export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
Expand Down
35 changes: 35 additions & 0 deletions rest/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,38 @@ export const enum RESTJSONErrorCodes {

FailedToCreateStageNeededForStageEvent = 180002,
}

export const enum Locale {
EnglishUS = 'en-US',
EnglishGB = 'en-GB',
Bulgarian = 'bg',
ChineseCN = 'zh-CN',
ChineseTW = 'zh-TW',
Croatian = 'hr',
Czech = 'cs',
Danish = 'da',
Dutch = 'nl',
Finnish = 'fi',
French = 'fr',
German = 'de',
Greek = 'el',
Hindi = 'hi',
Hungarian = 'hu',
Italian = 'it',
Japanese = 'ja',
Korean = 'ko',
Lithuanian = 'lt',
Norwegian = 'no',
Polish = 'pl',
PortugueseBR = 'pt-BR',
Romanian = 'ro',
Russian = 'ru',
SpanishES = 'es-ES',
Swedish = 'sv-SE',
Thai = 'th',
Turkish = 'tr',
Ukrainian = 'uk',
Vietnamese = 'vi',
}

export type LocaleString = `${Locale}`;