mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 09:50:07 +00:00
localization updates (#2206)
* localization updates
Upstream: 2f854d3fd6
Types: DiscordApplicationCommmand and DiscordApplicationCommandOption: Update documentation
Types: DiscordActivityButton: Add documentation link
Helper: upsertApplicationCommand: All fields are optional, but any fields provided will entirely overwrite the existing values of those fields.
* revert unrelated changes
* update SLASH_COMMANDS_NAME_REGEX
* createApplicationCommand options: AtLeastOne instead of Partial
Co-authored-by: ITOH <to@itoh.at>
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import { ApplicationCommandOption, ApplicationCommandTypes, Localization } from "../../../mod.ts";
|
||||
import { DiscordApplicationCommand, DiscordApplicationCommandOption } from "../../../types/discord.ts";
|
||||
import { AtLeastOne } from "../../../types/shared.ts";
|
||||
|
||||
/**
|
||||
* There are two kinds of Application Commands: global commands and guild commands. Global commands are available for every guild that adds your app; guild commands are specific to the guild you specify when making them. Command names are unique per application within each scope (global and guild). That means:
|
||||
@@ -89,7 +90,7 @@ export interface CreateContextApplicationCommand {
|
||||
}
|
||||
|
||||
export function isContextApplicationCommand(
|
||||
cmd: CreateContextApplicationCommand | CreateApplicationCommand,
|
||||
): cmd is CreateContextApplicationCommand {
|
||||
cmd: AtLeastOne<CreateContextApplicationCommand> | AtLeastOne<CreateApplicationCommand>,
|
||||
): cmd is AtLeastOne<CreateContextApplicationCommand> {
|
||||
return cmd.type === ApplicationCommandTypes.Message || cmd.type === ApplicationCommandTypes.User;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
makeOptionsForCommand,
|
||||
} from "./createApplicationCommand.ts";
|
||||
import { DiscordApplicationCommand } from "../../../types/discord.ts";
|
||||
import { ApplicationCommandOption } from "../../../transformers/applicationCommandOption.ts";
|
||||
import { ApplicationCommandTypes } from "../../../types/shared.ts";
|
||||
import { AtLeastOne } from "../../../types/shared.ts";
|
||||
|
||||
/**
|
||||
* Edit an existing application command. If this command did not exist, it will create it.
|
||||
@@ -15,7 +14,7 @@ import { ApplicationCommandTypes } from "../../../types/shared.ts";
|
||||
export async function upsertApplicationCommand(
|
||||
bot: Bot,
|
||||
commandId: bigint,
|
||||
options: CreateApplicationCommand | CreateContextApplicationCommand,
|
||||
options: AtLeastOne<CreateApplicationCommand> | AtLeastOne<CreateContextApplicationCommand>,
|
||||
guildId?: bigint,
|
||||
) {
|
||||
const result = await bot.rest.runMethod<DiscordApplicationCommand>(
|
||||
|
||||
@@ -1649,7 +1649,7 @@ export interface DiscordApplicationCommand {
|
||||
application_id: string;
|
||||
/** Guild id of the command, if not global */
|
||||
guild_id?: string;
|
||||
/** 1-32 character name matching */
|
||||
/** `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set. If there is a lowercase variant of any letters used, you must use those. Characters with no lowercase variants and/or uncased letters are still allowed. `ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces. */
|
||||
name: string;
|
||||
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
||||
name_localizations?: Localization | null;
|
||||
@@ -1669,7 +1669,7 @@ export interface DiscordApplicationCommand {
|
||||
export interface DiscordApplicationCommandOption {
|
||||
/** Value of Application Command Option Type */
|
||||
type: ApplicationCommandOptionTypes;
|
||||
/** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
|
||||
/** Command option name must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set. If there is a lowercase variant of any letters used, you must use those. Characters with no lowercase variants and/or uncased letters are still allowed. */
|
||||
name: string;
|
||||
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
||||
name_localizations?: Localization | null;
|
||||
|
||||
@@ -174,7 +174,7 @@ export const endpoints = {
|
||||
NITRO_STICKER_PACKS: () => `${baseEndpoints.BASE_URL}/sticker-packs`,
|
||||
};
|
||||
|
||||
export const SLASH_COMMANDS_NAME_REGEX = /^[\w-]{1,32}$/;
|
||||
export const SLASH_COMMANDS_NAME_REGEX = /^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u;
|
||||
export const CONTEXT_MENU_COMMANDS_NAME_REGEX = /^[\w-\s]{1,32}$/;
|
||||
export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g;
|
||||
export const DISCORD_SNOWFLAKE_REGEX = /^(?<id>\d{17,19})$/;
|
||||
|
||||
Reference in New Issue
Block a user