Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to discord-api-types@v10 #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ including the invoking `user`, server (`guild_id`) and continuation `token`.
<!-- prettier-ignore-start -->
```tsx
import { CommandHandler, createElement, createHandler, useDescription, useNumber } from "slshx";
import type { APIChatInputApplicationCommandInteraction } from "discord-api-types/v9";
import type { APIChatInputApplicationCommandInteraction } from "discord-api-types/v10";

type Env = { KV_NAMESPACE: KVNamespace; SECRET: string };

Expand Down Expand Up @@ -221,7 +221,7 @@ Some types have additional optional fields that control acceptable values.
<!-- prettier-ignore-start -->
```tsx
import { ChannelType } from "slshx";
import type { APIUser, APIInteractionDataResolvedChannel, APIRole, APIAttachment } from "discord-api-types/v9";
import type { APIUser, APIInteractionDataResolvedChannel, APIRole, APIAttachment } from "discord-api-types/v10";

function cmd(): CommandHandler {
useDescription("Command demonstrating option types");
Expand Down Expand Up @@ -309,7 +309,7 @@ suggestions. Similarly to choices, you can optionally provide a `name` for the
suggestion, which will be displayed instead.

```tsx
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v9/_interactions/autocomplete"; // 🙁
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v10/_interactions/autocomplete"; // 🙁

type Env = { SONG_NAMESPACE: KVNamespace };

Expand Down Expand Up @@ -418,7 +418,7 @@ responses.
<!-- prettier-ignore-start -->
```tsx
import { Message, UserCommandHandler, createElement, createHandler } from "slshx";
import type { APIUser, APIUserApplicationCommandInteraction } from "discord-api-types/v9";
import type { APIUser, APIUserApplicationCommandInteraction } from "discord-api-types/v10";

function greet(): UserCommandHandler {
return (interaction, env, ctx, user) => {
Expand Down Expand Up @@ -451,7 +451,7 @@ the command was invoked on.
<!-- prettier-ignore-start -->
```tsx
import { Message, MessageCommand, createElement, createHandler } from "slshx";
import type { APIMessage, APIMessageApplicationCommandInteraction } from "discord-api-types/v9";
import type { APIMessage, APIMessageApplicationCommandInteraction } from "discord-api-types/v10";

type Env = { BOOKMARKS_NAMESPACE: KVNamespace };

Expand Down Expand Up @@ -808,7 +808,7 @@ to a component interaction:

```tsx
import { CommandHandler, useButton, APIMessageComponentInteraction } from "slshx";
import type { APIMessageButtonInteractionData } from "discord-api-types/v9";
import type { APIMessageButtonInteractionData } from "discord-api-types/v10";

function cmd(): CommandHandler {
const buttonId = useButton((interaction, env, ctx) => {
Expand Down Expand Up @@ -1081,7 +1081,7 @@ the `default` option.
<!-- prettier-ignore-start -->
```tsx
import { ComponentType, createElement, Message, Select, Option, $update, useSelectMenu, CommandHandler, APIMessageComponentInteraction } from "slshx";
import type { APIMessageSelectMenuInteractionData } from "discord-api-types/v9";
import type { APIMessageSelectMenuInteractionData } from "discord-api-types/v10";

function selects(): CommandHandler {
// ...
Expand Down Expand Up @@ -1385,7 +1385,7 @@ If an API does not have Slshx bindings, you can use the
`call(method, path, body?, auth?)` function:

- `method` must be a standard HTTP method
- `path` will be appended to `https://discord.com/api/v9` to form the endpoint
- `path` will be appended to `https://discord.com/api/v10` to form the endpoint
URL
- `body` can be an instance of `FormData` (sent as `multipart/form-data`),
`URLSearchParams` (sent as `application/x-www-form-urlencoded`), or an
Expand Down
22 changes: 10 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"typescript": "^4.5.4"
},
"dependencies": {
"discord-api-types": "^0.27.0"
"discord-api-types": "^0.37.5"
},
"volta": {
"node": "17.9.1"
}
}
2 changes: 1 addition & 1 deletion src/api/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
RESTPutAPIApplicationGuildCommandsJSONBody,
RESTPutAPIApplicationGuildCommandsResult,
Snowflake,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { APIBearerAuth, call } from "./helpers";

/** @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
Expand Down
4 changes: 2 additions & 2 deletions src/api/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
RESTPostOAuth2ClientCredentialsResult,
Snowflake,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { log } from "../helpers";

export interface APIBasicAuth {
Expand Down Expand Up @@ -40,7 +40,7 @@ export async function call<Body, Result>(
body?: Body,
auth?: APIAuth
): Promise<Result> {
const url = `https://discord.com/api/v9${path}`;
const url = `https://discord.com/api/v10${path}`;

const headers: HeadersInit = {};
const init: RequestInit = { method, headers };
Expand Down
2 changes: 1 addition & 1 deletion src/api/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
RESTPostAPIInteractionFollowupJSONBody,
RESTPostAPIInteractionFollowupResult,
Snowflake,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import {
WithFileAttachments,
extractAttachments,
Expand Down
2 changes: 1 addition & 1 deletion src/api/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
RESTPutAPIApplicationCommandPermissionsJSONBody,
RESTPutAPIApplicationCommandPermissionsResult,
Snowflake,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { APIBearerAuth, call } from "./helpers";

/** @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
Expand Down
2 changes: 1 addition & 1 deletion src/commands/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
APIApplicationCommandInteractionDataBasicOption,
APIChatInputApplicationCommandInteractionDataResolved,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { AutocompleteHandler } from "./hooks";
import { STATE } from "./state";
import {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v9/_interactions/autocomplete";
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v10/_interactions/autocomplete";
import type {
APIApplicationCommandOptionChoice,
APIAttachment,
Expand All @@ -8,7 +8,7 @@ import type {
APIRole,
APIUser,
ChannelType,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ApplicationCommandOptionType } from "../api";
import { Awaitable, ValueOf } from "../helpers";
import { STATE } from "./state";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/recorders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
RESTPostAPIApplicationCommandsJSONBody,
RESTPostAPIChatInputApplicationCommandsJSONBody,
RESTPostAPIContextMenuApplicationCommandsJSONBody,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ApplicationCommandOptionType, ApplicationCommandType } from "../api";
import { PREFIX } from "../helpers";
import { Options } from "../options";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
APIApplicationCommandInteractionDataBasicOption,
APIApplicationCommandOption,
APIChatInputApplicationCommandInteractionDataResolved,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { AutocompleteHandler } from "./hooks";
import { ComponentHandler, ModalHandler } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
APIModalSubmitInteraction,
APIUser,
APIUserApplicationCommandInteraction,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { InteractionType } from "../api";
import { Awaitable, AwaitableGenerator, WithFileAttachments } from "../helpers";

Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIInteractionResponseCallbackData } from "discord-api-types/v9";
import type { APIInteractionResponseCallbackData } from "discord-api-types/v10";

export const PREFIX = "slshx";

Expand Down
4 changes: 2 additions & 2 deletions src/interactions/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v9/_interactions/autocomplete";
import type { APIApplicationCommandAutocompleteResponse } from "discord-api-types/v9";
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v10/_interactions/autocomplete";
import type { APIApplicationCommandAutocompleteResponse } from "discord-api-types/v10";
import { InteractionResponseType } from "../api";
import { instantiateAutocompleteHandler, normaliseChoices } from "../commands";
import { jsonResponse } from "../helpers";
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
APIChatInputApplicationCommandInteractionDataResolved,
APIMessage,
APIUser,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ApplicationCommandType } from "../api";
import { instantiateCommandHandler } from "../commands";
import { HandlerOptions } from "../options";
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIMessageComponentInteraction } from "discord-api-types/v9";
import type { APIMessageComponentInteraction } from "discord-api-types/v10";
import { instantiateComponentHandler } from "../commands";
import { HandlerOptions } from "../options";
import { matchCustomId } from "./matchers";
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/matchers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v9/_interactions/autocomplete";
import type { APIApplicationCommandAutocompleteInteraction } from "discord-api-types/payloads/v10/_interactions/autocomplete";
import type {
APIApplicationCommandInteraction,
APIApplicationCommandInteractionDataBasicOption,
APIApplicationCommandInteractionDataOption,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ApplicationCommandType } from "../api";
import {
AnyCommand,
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/modal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIModalSubmitInteraction } from "discord-api-types/v9";
import type { APIModalSubmitInteraction } from "discord-api-types/v10";
import { ComponentType } from "../api";
import { instantiateModalHandler } from "../commands";
import { HandlerOptions } from "../options";
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/ping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIInteractionResponsePong } from "discord-api-types/v9";
import type { APIInteractionResponsePong } from "discord-api-types/v10";
import { InteractionResponseType } from "../api";
import { jsonResponse } from "../helpers";

Expand Down
2 changes: 1 addition & 1 deletion src/interactions/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
APIInteractionResponseUpdateMessage,
APIModalInteractionResponse,
APIModalSubmitInteraction,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import {
InteractionResponseType,
createFollowupMessage,
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/validate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
APIInteraction,
APIModalSubmitInteraction,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { hexDecode } from "../helpers";

const ENCODER = /* @__PURE__ */ new TextEncoder();
Expand Down
8 changes: 4 additions & 4 deletions src/jsx/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type {
APIButtonComponent,
APIEmbed,
APIInteractionResponseCallbackData,
APIMessageComponent,
APIMessageActionRowComponent,
APISelectMenuComponent,
Snowflake,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { AllowedMentionsTypes, ComponentType } from "../api";
import { $update } from "../commands";
import { ValueOf, WithFileAttachments } from "../helpers";
Expand All @@ -30,7 +30,7 @@ export interface MessageProps {
children?: (
| Child
| (APIEmbed & { [$embed]: true })
| (APIActionRowComponent<APIMessageComponent> & { [$actionRow]: true })
| (APIActionRowComponent<APIMessageActionRowComponent> & { [$actionRow]: true })
| (APIButtonComponent & { [$actionRowChild]: true })
| (APISelectMenuComponent & { [$actionRowChild]: true })
)[];
Expand All @@ -44,7 +44,7 @@ export function Message(
// Sort children into correct slots
let content = undefined;
const embeds: APIEmbed[] = [];
const components: APIActionRowComponent<APIMessageComponent>[] = [];
const components: APIActionRowComponent<APIMessageActionRowComponent>[] = [];
for (const child of props.children?.flat(Infinity) ?? []) {
if (isEmptyChild(child)) continue;
if ((child as any)[$embed]) {
Expand Down
8 changes: 4 additions & 4 deletions src/jsx/Modal.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {
APIActionRowComponent,
APIModalComponent,
APIModalActionRowComponent,
APITextInputComponent,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ComponentType } from "../api";
import { $modal, ModalResponse } from "../commands";
import { $actionRow, $actionRowChild } from "./components";
Expand All @@ -12,13 +12,13 @@ export interface ModalProps {
id: string;
title: string;
children?: (
| (APIActionRowComponent<APIModalComponent> & { [$actionRow]: true })
| (APIActionRowComponent<APIModalActionRowComponent> & { [$actionRow]: true })
| (APITextInputComponent & { [$actionRowChild]: true })
)[];
}

export function Modal(props: ModalProps): ModalResponse {
const components: APIActionRowComponent<APIModalComponent>[] = [];
const components: APIActionRowComponent<APIModalActionRowComponent>[] = [];
for (const child of props.children?.flat(Infinity) ?? []) {
if (isEmptyChild(child)) continue;
if ((child as any)[$actionRow]) {
Expand Down
2 changes: 1 addition & 1 deletion src/jsx/components/Button.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
APIButtonComponent,
APIMessageComponentEmoji,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ButtonStyle, ComponentType } from "../../api";
import { Child, childrenContent } from "../helpers";
import { $actionRowChild } from "./Row";
Expand Down
2 changes: 1 addition & 1 deletion src/jsx/components/Input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APITextInputComponent } from "discord-api-types/v9";
import type { APITextInputComponent } from "discord-api-types/v10";
import { ComponentType, TextInputStyle } from "../../api";
import { $actionRowChild } from "./Row";

Expand Down
2 changes: 1 addition & 1 deletion src/jsx/components/Option.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
APIMessageComponentEmoji,
APISelectMenuOption,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { Child, childrenContent } from "../helpers";

export interface OptionProps {
Expand Down
2 changes: 1 addition & 1 deletion src/jsx/components/Row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
APIActionRowComponent,
APIActionRowComponentTypes,
APIMessageComponent,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ComponentType } from "../../api";

export const $actionRow = /* @__PURE__ */ Symbol("$actionRow");
Expand Down
2 changes: 1 addition & 1 deletion src/jsx/components/Select.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
APISelectMenuComponent,
APISelectMenuOption,
} from "discord-api-types/v9";
} from "discord-api-types/v10";
import { ComponentType } from "../../api";
import { $actionRowChild } from "./Row";

Expand Down
Loading