Skip to content

Commit

Permalink
feat(Locales): Add discord supported locales (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
YetAnotherConnor committed Feb 19, 2024
1 parent 6084d6a commit f09ba3e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 9 deletions.
62 changes: 53 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ declare namespace Eris {
type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber;
type InteractionResponseTypes = Constants["InteractionResponseTypes"][keyof Constants["InteractionResponseTypes"]];
type InteractionTypes = Constants["InteractionTypes"][keyof Constants["InteractionTypes"]];
type LocaleStrings = Constants["Locales"][keyof Constants["Locales"]];

// Invite
type InviteTargetTypes = Constants["InviteTargetTypes"][keyof Constants["InviteTargetTypes"]];
Expand Down Expand Up @@ -207,10 +208,10 @@ declare namespace Eris {
/** @deprecated */
defaultPermission?: boolean;
description?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : "" | void;
descriptionLocalizations?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? { [s: string]: string } | null : null;
descriptionLocalizations?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? Record<LocaleStrings, string> | null : null;
dmPermission?: T extends true ? never : boolean | null;
name?: string;
nameLocalizations?: { [s: string]: string } | null;
nameLocalizations?: Record<LocaleStrings, string> | null;
nsfw?: boolean;
options?: ApplicationCommandOptions[];
}
Expand All @@ -227,7 +228,9 @@ declare namespace Eris {
interface ApplicationCommandOption<T extends Constants["ApplicationCommandOptionTypes"][Exclude<keyof Constants["ApplicationCommandOptionTypes"], "SUB_COMMAND" | "SUB_COMMAND_GROUP">]> {
channel_types: T extends Constants["ApplicationCommandOptionTypes"]["CHANNEL"] ? ChannelTypes | undefined : never;
description: string;
descriptionLocalizations?: Record<LocaleStrings, string> | null;
name: string;
nameLocalizations?: Record<LocaleStrings, string> | null;
required?: boolean;
type: T;
}
Expand All @@ -243,31 +246,39 @@ declare namespace Eris {
}
interface ApplicationCommandOptionsSubCommand {
description: string;
descriptionLocalizations?: Record<LocaleStrings, string> | null;
name: string;
nameLocalizations?: Record<LocaleStrings, string> | null;
options?: ApplicationCommandOptionsWithValue[];
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"];
}
interface ApplicationCommandOptionsSubCommandGroup {
description: string;
descriptionLocalizations?: Record<LocaleStrings, string> | null;
name: string;
nameLocalizations?: Record<LocaleStrings, string> | null;
options?: (ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsWithValue)[];
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"];
}
interface ApplicationCommandOptionWithChoices<T extends Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">] = Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">]> {
autocomplete?: boolean;
choices?: ApplicationCommandOptionChoice<T>[];
description: string;
descriptionLocalizations?: Record<LocaleStrings, string> | null;
name: string;
nameLocalizations?: Record<LocaleStrings, string> | null;
required?: boolean;
type: T;
}
interface ApplicationCommandOptionWithMinMax<T extends Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "INTEGER" | "NUMBER">] = Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "INTEGER" | "NUMBER">]> {
autocomplete?: boolean;
choices?: ApplicationCommandOptionChoice<T>[];
description: string;
descriptionLocalizations?: Record<LocaleStrings, string> | null;
max_value?: number;
min_value?: number;
name: string;
nameLocalizations?: Record<LocaleStrings, string> | null;
required?: boolean;
type: T;
}
Expand Down Expand Up @@ -728,7 +739,7 @@ declare namespace Eris {
nsfw: boolean;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale?: string;
preferredLocale?: LocaleStrings;
premiumProgressBarEnabled: boolean;
premiumSubscriptionCount?: number;
premiumTier: PremiumTier;
Expand Down Expand Up @@ -1023,7 +1034,7 @@ declare namespace Eris {
is_primary: boolean;
name: {
default: string;
localizations?: { [lang: string]: string };
localizations?: Record<LocaleStrings, string>;
};
}
interface DiscoveryMetadata {
Expand Down Expand Up @@ -1135,7 +1146,7 @@ declare namespace Eris {
icon?: string | null;
name?: string;
ownerID?: string;
preferredLocale?: string | null;
preferredLocale?: LocaleStrings | null;
publicUpdatesChannelID?: string | null;
rulesChannelID?: string | null;
safetyAlertsChannelID?: string | null;
Expand Down Expand Up @@ -2155,6 +2166,39 @@ declare namespace Eris {
STREAM: 1;
EMBEDDED_APPLICATION: 2;
};
Locales: {
BULGARIAN: "bg";
CZECH: "cs";
DANISH: "da";
GERMAN: "de";
GREEK: "el";
ENGLISH_UK: "en-GB";
ENGLISH_US: "en-US";
SPANISH: "es-ES";
FINNISH: "fi";
FRENCH: "fr";
HINDI: "hi";
CROATIAN: "hr";
HUNGARIAN: "hu";
INDONESIAN: "id";
ITALIAN: "it";
JAPANESE: "ja";
KOREAN: "ko";
LITHUANIAN: "lt";
DUTCH: "nl";
NORWEGIAN: "no";
POLISH: "pl";
PORTUGUESE_BRAZILIAN: "pt-BR";
ROMANIAN_ROMANIA: "ro";
RUSSIAN: "ru";
SWEDISH: "sv-SE";
THAI: "th";
TURKISH: "tr";
UKRAINIAN: "uk";
VIETNAMESE: "vi";
CHINESE_CHINA: "zh-CN";
CHINESE_TAIWAN: "zh-TW";
};
MemberFlags: {
DID_REJOIN: 1;
COMPLETED_ONBOARDING: 2;
Expand Down Expand Up @@ -2542,7 +2586,7 @@ declare namespace Eris {
inline_attachment_media: boolean;
inline_embed_media: boolean;
guild_positions: string[];
locale: string;
locale: LocaleStrings;
message_display_compact: boolean;
render_embeds: boolean;
render_reactions: boolean;
Expand All @@ -2560,11 +2604,11 @@ declare namespace Eris {
/** @deprecated */
defaultPermission?: boolean | null;
description: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : "";
descriptionLocalizations?: U extends "CHAT_INPUT" ? Record<string, string> | null : null;
descriptionLocalizations?: U extends "CHAT_INPUT" ? Record<LocaleStrings, string> | null : null;
dmPermission?: boolean;
guild: T extends true ? PossiblyUncachedGuild : never;
name: string;
nameLocalizations?: Record<string, string> | null;
nameLocalizations?: Record<LocaleStrings, string> | null;
nsfw?: boolean;
options?: ApplicationCommandOptions[];
type?: U;
Expand Down Expand Up @@ -3160,7 +3204,7 @@ declare namespace Eris {
nsfw: boolean;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale: string;
preferredLocale: LocaleStrings;
premiumProgressBarEnabled: boolean;
premiumSubscriptionCount?: number;
premiumTier: PremiumTier;
Expand Down
34 changes: 34 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,40 @@ module.exports.InviteTargetTypes = {
EMBEDDED_APPLICATION: 2
};

module.exports.Locales = {
BULGARIAN: "bg",
CZECH: "cs",
DANISH: "da",
GERMAN: "de",
GREEK: "el",
ENGLISH_UK: "en-GB",
ENGLISH_US: "en-US",
SPANISH: "es-ES",
FINNISH: "fi",
FRENCH: "fr",
HINDI: "hi",
CROATIAN: "hr",
HUNGARIAN: "hu",
INDONESIAN: "id",
ITALIAN: "it",
JAPANESE: "ja",
KOREAN: "ko",
LITHUANIAN: "lt",
DUTCH: "nl",
NORWEGIAN: "no",
POLISH: "pl",
PORTUGUESE_BRAZILIAN: "pt-BR",
ROMANIAN_ROMANIA: "ro",
RUSSIAN: "ru",
SWEDISH: "sv-SE",
THAI: "th",
TURKISH: "tr",
UKRAINIAN: "uk",
VIETNAMESE: "vi",
CHINESE_CHINA: "zh-CN",
CHINESE_TAIWAN: "zh-TW"
};

module.exports.MemberFlags = {
DID_REJOIN: 1 << 0,
COMPLETED_ONBOARDING: 1 << 1,
Expand Down

0 comments on commit f09ba3e

Please sign in to comment.