slack-term 1.40.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ts/slack.ts CHANGED
@@ -1126,6 +1126,18 @@ export async function userInfo(token: string, userId: string, cookie?: string):
1126
1126
  return get(token, "users.info", { user: userId }, cookie);
1127
1127
  }
1128
1128
 
1129
+ /** A person's Slack UI locale (`ja-JP`, `en-US`), or undefined when it cannot
1130
+ * be read. Fail-soft: it only picks the language of `ask`'s copy, and a lookup
1131
+ * failure must never stop a question from being asked. */
1132
+ export async function userLocale(token: string, userId: string, cookie?: string): Promise<string | undefined> {
1133
+ try {
1134
+ const r = (await get(token, "users.info", { user: userId, include_locale: "true" }, cookie)) as { user?: { locale?: unknown } };
1135
+ return typeof r.user?.locale === "string" ? r.user.locale : undefined;
1136
+ } catch {
1137
+ return undefined;
1138
+ }
1139
+ }
1140
+
1129
1141
  export async function conversationInfo(token: string, channelId: string, cookie?: string): Promise<Json> {
1130
1142
  return get(token, "conversations.info", { channel: channelId }, cookie);
1131
1143
  }