From 17d06f613502034908e84bb926088f61d0b91cb2 Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Tue, 30 Jan 2024 21:10:46 -0600 Subject: [PATCH 1/7] limit locales to discord supported locales --- index.d.ts | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index f61604194..ce7ca2109 100644 --- a/index.d.ts +++ b/index.d.ts @@ -203,10 +203,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 | null : null; dmPermission?: T extends true ? never : boolean | null; name?: string; - nameLocalizations?: { [s: string]: string } | null; + nameLocalizations?: Record | null; nsfw?: boolean; options?: ApplicationCommandOptions[]; } @@ -702,7 +702,7 @@ declare namespace Eris { nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; - preferredLocale?: string; + preferredLocale?: Constants["Locales"][keyof Constants["Locales"]]; premiumProgressBarEnabled: boolean; premiumSubscriptionCount?: number; premiumTier: PremiumTier; @@ -993,7 +993,7 @@ declare namespace Eris { is_primary: boolean; name: { default: string; - localizations?: { [lang: string]: string }; + localizations?: Record; }; } interface DiscoveryMetadata { @@ -1104,7 +1104,7 @@ declare namespace Eris { icon?: string | null; name?: string; ownerID?: string; - preferredLocale?: string | null; + preferredLocale?: Constants["Locales"][keyof Constants["Locales"]] | null; publicUpdatesChannelID?: string | null; rulesChannelID?: string | null; safetyAlertsChannelID?: string | null; @@ -2084,6 +2084,39 @@ declare namespace Eris { STREAM: 1; EMBEDDED_APPLICATION: 2; }; + Locales: { + INDONESIAN: "id"; + DANISH: "da"; + GERMAN: "de"; + ENGLISH_UK: "en-GB"; + ENGLISH_US: "en-US"; + SPANISH: "es-ES"; + FRENCH: "fr"; + CROATIAN: "hr"; + ITALIAN: "it"; + LITHUANIAN: "lt"; + HUNGARIAN: "hu"; + DUTCH: "nl"; + NORWEGIAN: "no"; + POLISH: "pl"; + PORTUGUESE_BRAZILIAN: "pt-BR"; + ROMANIAN_ROMANIA: "ro"; + FINNISH: "fi"; + SWEDISH: "sv-SE"; + VIETNAMESE: "vi"; + TURKISH: "tr"; + CZECH: "cs"; + GREEK: "el"; + BULGARIAN: "bg"; + RUSSIAN: "ru"; + UKRAINIAN: "uk"; + HINDI: "hi"; + THAI: "th"; + CHINESE_CHINA: "zh-CN"; + JAPANESE: "ja"; + CHINESE_TAIWAN: "zh-TW"; + KOREAN: "ko"; + }; MemberFlags: { DID_REJOIN: 1; COMPLETED_ONBOARDING: 2; @@ -2468,7 +2501,7 @@ declare namespace Eris { inline_attachment_media: boolean; inline_embed_media: boolean; guild_positions: string[]; - locale: string; + locale: Constants["Locales"][keyof Constants["Locales"]]; message_display_compact: boolean; render_embeds: boolean; render_reactions: boolean; @@ -2486,11 +2519,11 @@ declare namespace Eris { /** @deprecated */ defaultPermission?: boolean | null; description: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : ""; - descriptionLocalizations?: U extends "CHAT_INPUT" ? Record | null : null; + descriptionLocalizations?: U extends "CHAT_INPUT" ? Record | null : null; dmPermission?: boolean; guild: T extends true ? PossiblyUncachedGuild : never; name: string; - nameLocalizations?: Record | null; + nameLocalizations?: Record | null; nsfw?: boolean; options?: ApplicationCommandOptions[]; type?: U; @@ -3064,7 +3097,7 @@ declare namespace Eris { nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; - preferredLocale: string; + preferredLocale: Constants["Locales"][keyof Constants["Locales"]]; premiumProgressBarEnabled: boolean; premiumSubscriptionCount?: number; premiumTier: PremiumTier; From d3dc917d9d351dff26affbaeafb458bd20848e99 Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Tue, 30 Jan 2024 21:42:32 -0600 Subject: [PATCH 2/7] dont forget to update Constants --- lib/Constants.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/Constants.js b/lib/Constants.js index 5adf1004e..cd2c6dcaf 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -383,6 +383,40 @@ module.exports.InviteTargetTypes = { EMBEDDED_APPLICATION: 2 }; +module.exports.Locales = { + INDONESIAN: "id", + DANISH: "da", + GERMAN: "de", + ENGLISH_UK: "en-GB", + ENGLISH_US: "en-US", + SPANISH: "es-ES", + FRENCH: "fr", + CROATIAN: "hr", + ITALIAN: "it", + LITHUANIAN: "lt", + HUNGARIAN: "hu", + DUTCH: "nl", + NORWEGIAN: "no", + POLISH: "pl", + PORTUGUESE_BRAZILIAN: "pt-BR", + ROMANIAN_ROMANIA: "ro", + FINNISH: "fi", + SWEDISH: "sv-SE", + VIETNAMESE: "vi", + TURKISH: "tr", + CZECH: "cs", + GREEK: "el", + BULGARIAN: "bg", + RUSSIAN: "ru", + UKRAINIAN: "uk", + HINDI: "hi", + THAI: "th", + CHINESE_CHINA: "zh-CN", + JAPANESE: "ja", + CHINESE_TAIWAN: "zh-TW", + KOREAN: "ko" +}; + module.exports.MemberFlags = { DID_REJOIN: 1 << 0, COMPLETED_ONBOARDING: 1 << 1, From 7d5d98d6e666a1715257d15178c077ead8eba199 Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Sat, 10 Feb 2024 16:26:30 -0600 Subject: [PATCH 3/7] add and use localeStrings type alias --- index.d.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index ce7ca2109..94059dfd5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -137,6 +137,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"]]; @@ -203,10 +204,10 @@ declare namespace Eris { /** @deprecated */ defaultPermission?: boolean; description?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : "" | void; - descriptionLocalizations?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? Record | null : null; + descriptionLocalizations?: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? Record | null : null; dmPermission?: T extends true ? never : boolean | null; name?: string; - nameLocalizations?: Record | null; + nameLocalizations?: Record | null; nsfw?: boolean; options?: ApplicationCommandOptions[]; } @@ -702,7 +703,7 @@ declare namespace Eris { nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; - preferredLocale?: Constants["Locales"][keyof Constants["Locales"]]; + preferredLocale?: LocaleStrings; premiumProgressBarEnabled: boolean; premiumSubscriptionCount?: number; premiumTier: PremiumTier; @@ -993,7 +994,7 @@ declare namespace Eris { is_primary: boolean; name: { default: string; - localizations?: Record; + localizations?: Record; }; } interface DiscoveryMetadata { @@ -1104,7 +1105,7 @@ declare namespace Eris { icon?: string | null; name?: string; ownerID?: string; - preferredLocale?: Constants["Locales"][keyof Constants["Locales"]] | null; + preferredLocale?: LocaleStrings | null; publicUpdatesChannelID?: string | null; rulesChannelID?: string | null; safetyAlertsChannelID?: string | null; @@ -2501,7 +2502,7 @@ declare namespace Eris { inline_attachment_media: boolean; inline_embed_media: boolean; guild_positions: string[]; - locale: Constants["Locales"][keyof Constants["Locales"]]; + locale: LocaleStrings; message_display_compact: boolean; render_embeds: boolean; render_reactions: boolean; @@ -2519,11 +2520,11 @@ declare namespace Eris { /** @deprecated */ defaultPermission?: boolean | null; description: U extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : ""; - descriptionLocalizations?: U extends "CHAT_INPUT" ? Record | null : null; + descriptionLocalizations?: U extends "CHAT_INPUT" ? Record | null : null; dmPermission?: boolean; guild: T extends true ? PossiblyUncachedGuild : never; name: string; - nameLocalizations?: Record | null; + nameLocalizations?: Record | null; nsfw?: boolean; options?: ApplicationCommandOptions[]; type?: U; @@ -3097,7 +3098,7 @@ declare namespace Eris { nsfw: boolean; nsfwLevel: NSFWLevel; ownerID: string; - preferredLocale: Constants["Locales"][keyof Constants["Locales"]]; + preferredLocale: LocaleStrings; premiumProgressBarEnabled: boolean; premiumSubscriptionCount?: number; premiumTier: PremiumTier; From 97135c66aa92158617c08459192b9432cc6c207c Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Sat, 10 Feb 2024 16:27:57 -0600 Subject: [PATCH 4/7] add description and name localizations to application command options --- index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.d.ts b/index.d.ts index 94059dfd5..9d3b31ca5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -224,7 +224,9 @@ declare namespace Eris { interface ApplicationCommandOption]> { channel_types: T extends Constants["ApplicationCommandOptionTypes"]["CHANNEL"] ? ChannelTypes | undefined : never; description: string; + descriptionLocalizations?: Record | null; name: string; + nameLocalizations?: Record | null; required?: boolean; type: T; } @@ -240,13 +242,17 @@ declare namespace Eris { } interface ApplicationCommandOptionsSubCommand { description: string; + descriptionLocalizations?: Record | null; name: string; + nameLocalizations?: Record | null; options?: ApplicationCommandOptionsWithValue[]; type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"]; } interface ApplicationCommandOptionsSubCommandGroup { description: string; + descriptionLocalizations?: Record | null; name: string; + nameLocalizations?: Record | null; options?: (ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsWithValue)[]; type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"]; } @@ -254,7 +260,9 @@ declare namespace Eris { autocomplete?: boolean; choices?: ApplicationCommandOptionChoice[]; description: string; + descriptionLocalizations?: Record | null; name: string; + nameLocalizations?: Record | null; required?: boolean; type: T; } @@ -262,9 +270,11 @@ declare namespace Eris { autocomplete?: boolean; choices?: ApplicationCommandOptionChoice[]; description: string; + descriptionLocalizations?: Record | null; max_value?: number; min_value?: number; name: string; + nameLocalizations?: Record | null; required?: boolean; type: T; } From 4e2208c85580c1d9717c8286daf6d2c9973377d9 Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Sun, 11 Feb 2024 15:37:47 -0600 Subject: [PATCH 5/7] order locales by iso 639-1 --- index.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9d3b31ca5..b58c11f83 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2096,37 +2096,37 @@ declare namespace Eris { EMBEDDED_APPLICATION: 2; }; Locales: { - INDONESIAN: "id"; + BULGARIAN: "bg"; + CHINESE_CHINA: "zh-CN"; + CHINESE_TAIWAN: "zh-TW"; + CROATIAN: "hr"; + CZECH: "cs"; DANISH: "da"; - GERMAN: "de"; + DUTCH: "nl"; ENGLISH_UK: "en-GB"; ENGLISH_US: "en-US"; - SPANISH: "es-ES"; + FINNISH: "fi"; FRENCH: "fr"; - CROATIAN: "hr"; + GERMAN: "de"; + GREEK: "el"; + HINDI: "hi"; + HUNGARIAN: "hu"; + INDONESIAN: "id"; ITALIAN: "it"; + JAPANESE: "ja"; + KOREAN: "ko"; LITHUANIAN: "lt"; - HUNGARIAN: "hu"; - DUTCH: "nl"; NORWEGIAN: "no"; POLISH: "pl"; PORTUGUESE_BRAZILIAN: "pt-BR"; ROMANIAN_ROMANIA: "ro"; - FINNISH: "fi"; + RUSSIAN: "ru"; + SPANISH: "es-ES"; SWEDISH: "sv-SE"; - VIETNAMESE: "vi"; + THAI: "th"; TURKISH: "tr"; - CZECH: "cs"; - GREEK: "el"; - BULGARIAN: "bg"; - RUSSIAN: "ru"; UKRAINIAN: "uk"; - HINDI: "hi"; - THAI: "th"; - CHINESE_CHINA: "zh-CN"; - JAPANESE: "ja"; - CHINESE_TAIWAN: "zh-TW"; - KOREAN: "ko"; + VIETNAMESE: "vi"; }; MemberFlags: { DID_REJOIN: 1; From 5456c17e90b2b864d236ad5c79cf668ddd553c3c Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Sun, 11 Feb 2024 15:39:18 -0600 Subject: [PATCH 6/7] dont forget to update Constants, angain --- lib/Constants.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/Constants.js b/lib/Constants.js index cd2c6dcaf..67033950c 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -384,37 +384,37 @@ module.exports.InviteTargetTypes = { }; module.exports.Locales = { - INDONESIAN: "id", + BULGARIAN: "bg", + CHINESE_CHINA: "zh-CN", + CHINESE_TAIWAN: "zh-TW", + CROATIAN: "hr", + CZECH: "cs", DANISH: "da", - GERMAN: "de", + DUTCH: "nl", ENGLISH_UK: "en-GB", ENGLISH_US: "en-US", - SPANISH: "es-ES", + FINNISH: "fi", FRENCH: "fr", - CROATIAN: "hr", + GERMAN: "de", + GREEK: "el", + HINDI: "hi", + HUNGARIAN: "hu", + INDONESIAN: "id", ITALIAN: "it", + JAPANESE: "ja", + KOREAN: "ko", LITHUANIAN: "lt", - HUNGARIAN: "hu", - DUTCH: "nl", NORWEGIAN: "no", POLISH: "pl", PORTUGUESE_BRAZILIAN: "pt-BR", ROMANIAN_ROMANIA: "ro", - FINNISH: "fi", + RUSSIAN: "ru", + SPANISH: "es-ES", SWEDISH: "sv-SE", - VIETNAMESE: "vi", + THAI: "th", TURKISH: "tr", - CZECH: "cs", - GREEK: "el", - BULGARIAN: "bg", - RUSSIAN: "ru", UKRAINIAN: "uk", - HINDI: "hi", - THAI: "th", - CHINESE_CHINA: "zh-CN", - JAPANESE: "ja", - CHINESE_TAIWAN: "zh-TW", - KOREAN: "ko" + VIETNAMESE: "vi" }; module.exports.MemberFlags = { From 384e36e58b712081444086004e01da95db1127d4 Mon Sep 17 00:00:00 2001 From: YetAnotherConnor Date: Sat, 17 Feb 2024 13:21:11 -0600 Subject: [PATCH 7/7] order locale values by iso 639-1 --- index.d.ts | 14 +++++++------- lib/Constants.js | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/index.d.ts b/index.d.ts index b58c11f83..89ca585d4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2097,36 +2097,36 @@ declare namespace Eris { }; Locales: { BULGARIAN: "bg"; - CHINESE_CHINA: "zh-CN"; - CHINESE_TAIWAN: "zh-TW"; - CROATIAN: "hr"; CZECH: "cs"; DANISH: "da"; - DUTCH: "nl"; + GERMAN: "de"; + GREEK: "el"; ENGLISH_UK: "en-GB"; ENGLISH_US: "en-US"; + SPANISH: "es-ES"; FINNISH: "fi"; FRENCH: "fr"; - GERMAN: "de"; - GREEK: "el"; 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"; - SPANISH: "es-ES"; SWEDISH: "sv-SE"; THAI: "th"; TURKISH: "tr"; UKRAINIAN: "uk"; VIETNAMESE: "vi"; + CHINESE_CHINA: "zh-CN"; + CHINESE_TAIWAN: "zh-TW"; }; MemberFlags: { DID_REJOIN: 1; diff --git a/lib/Constants.js b/lib/Constants.js index 67033950c..ddadd0b82 100644 --- a/lib/Constants.js +++ b/lib/Constants.js @@ -385,36 +385,36 @@ module.exports.InviteTargetTypes = { module.exports.Locales = { BULGARIAN: "bg", - CHINESE_CHINA: "zh-CN", - CHINESE_TAIWAN: "zh-TW", - CROATIAN: "hr", CZECH: "cs", DANISH: "da", - DUTCH: "nl", + GERMAN: "de", + GREEK: "el", ENGLISH_UK: "en-GB", ENGLISH_US: "en-US", + SPANISH: "es-ES", FINNISH: "fi", FRENCH: "fr", - GERMAN: "de", - GREEK: "el", 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", - SPANISH: "es-ES", SWEDISH: "sv-SE", THAI: "th", TURKISH: "tr", UKRAINIAN: "uk", - VIETNAMESE: "vi" + VIETNAMESE: "vi", + CHINESE_CHINA: "zh-CN", + CHINESE_TAIWAN: "zh-TW" }; module.exports.MemberFlags = {