mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
localization updates (#2206)
* localization updates Upstream: https://github.com/discord/discord-api-docs/commit/2f854d3fd675a9953d1bb8d6858a03c8a9642337 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:
co-authored by
ITOH
Skillz4Killz
parent
de292cd613
commit
453fd45ef7
@@ -1,6 +1,7 @@
|
|||||||
import type { Bot } from "../../../bot.ts";
|
import type { Bot } from "../../../bot.ts";
|
||||||
import { ApplicationCommandOption, ApplicationCommandTypes, Localization } from "../../../mod.ts";
|
import { ApplicationCommandOption, ApplicationCommandTypes, Localization } from "../../../mod.ts";
|
||||||
import { DiscordApplicationCommand, DiscordApplicationCommandOption } from "../../../types/discord.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:
|
* 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(
|
export function isContextApplicationCommand(
|
||||||
cmd: CreateContextApplicationCommand | CreateApplicationCommand,
|
cmd: AtLeastOne<CreateContextApplicationCommand> | AtLeastOne<CreateApplicationCommand>,
|
||||||
): cmd is CreateContextApplicationCommand {
|
): cmd is AtLeastOne<CreateContextApplicationCommand> {
|
||||||
return cmd.type === ApplicationCommandTypes.Message || cmd.type === ApplicationCommandTypes.User;
|
return cmd.type === ApplicationCommandTypes.Message || cmd.type === ApplicationCommandTypes.User;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import {
|
|||||||
makeOptionsForCommand,
|
makeOptionsForCommand,
|
||||||
} from "./createApplicationCommand.ts";
|
} from "./createApplicationCommand.ts";
|
||||||
import { DiscordApplicationCommand } from "../../../types/discord.ts";
|
import { DiscordApplicationCommand } from "../../../types/discord.ts";
|
||||||
import { ApplicationCommandOption } from "../../../transformers/applicationCommandOption.ts";
|
import { AtLeastOne } from "../../../types/shared.ts";
|
||||||
import { ApplicationCommandTypes } from "../../../types/shared.ts";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit an existing application command. If this command did not exist, it will create it.
|
* 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(
|
export async function upsertApplicationCommand(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
commandId: bigint,
|
commandId: bigint,
|
||||||
options: CreateApplicationCommand | CreateContextApplicationCommand,
|
options: AtLeastOne<CreateApplicationCommand> | AtLeastOne<CreateContextApplicationCommand>,
|
||||||
guildId?: bigint,
|
guildId?: bigint,
|
||||||
) {
|
) {
|
||||||
const result = await bot.rest.runMethod<DiscordApplicationCommand>(
|
const result = await bot.rest.runMethod<DiscordApplicationCommand>(
|
||||||
|
|||||||
+2
-2
@@ -1649,7 +1649,7 @@ export interface DiscordApplicationCommand {
|
|||||||
application_id: string;
|
application_id: string;
|
||||||
/** Guild id of the command, if not global */
|
/** Guild id of the command, if not global */
|
||||||
guild_id?: string;
|
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;
|
name: string;
|
||||||
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
||||||
name_localizations?: Localization | null;
|
name_localizations?: Localization | null;
|
||||||
@@ -1669,7 +1669,7 @@ export interface DiscordApplicationCommand {
|
|||||||
export interface DiscordApplicationCommandOption {
|
export interface DiscordApplicationCommandOption {
|
||||||
/** Value of Application Command Option Type */
|
/** Value of Application Command Option Type */
|
||||||
type: ApplicationCommandOptionTypes;
|
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;
|
name: string;
|
||||||
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
/** Localization object for the `name` field. Values follow the same restrictions as `name` */
|
||||||
name_localizations?: Localization | null;
|
name_localizations?: Localization | null;
|
||||||
|
|||||||
+1
-1
@@ -174,7 +174,7 @@ export const endpoints = {
|
|||||||
NITRO_STICKER_PACKS: () => `${baseEndpoints.BASE_URL}/sticker-packs`,
|
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 CONTEXT_MENU_COMMANDS_NAME_REGEX = /^[\w-\s]{1,32}$/;
|
||||||
export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g;
|
export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g;
|
||||||
export const DISCORD_SNOWFLAKE_REGEX = /^(?<id>\d{17,19})$/;
|
export const DISCORD_SNOWFLAKE_REGEX = /^(?<id>\d{17,19})$/;
|
||||||
|
|||||||
Reference in New Issue
Block a user