Skip to content

Commit

Permalink
feat: add API v10 support (#7477)
Browse files Browse the repository at this point in the history
* feat: add API v10 support

* refactor: update deps

* chore: rebase fixes
  • Loading branch information
suneettipirneni authored Mar 15, 2022
1 parent 9b0d8cb commit 72577c4
Show file tree
Hide file tree
Showing 144 changed files with 196 additions and 203 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Register a slash command against the Discord API:

```js
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { Routes } = require('discord-api-types/v10');

const commands = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/__tests__/components/actionRow.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIActionRowComponent, APIMessageActionRowComponent, ButtonStyle, ComponentType } from 'discord-api-types/v9';
import { APIActionRowComponent, APIMessageActionRowComponent, ButtonStyle, ComponentType } from 'discord-api-types/v10';
import {
ActionRowBuilder,
ButtonBuilder,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/__tests__/components/button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
APIButtonComponentWithURL,
ButtonStyle,
ComponentType,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import { buttonLabelValidator, buttonStyleValidator } from '../../src/components/Assertions';
import { ButtonBuilder } from '../../src/components/button/Button';

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/__tests__/components/selectMenu.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APISelectMenuComponent, APISelectMenuOption, ComponentType } from 'discord-api-types/v9';
import { APISelectMenuComponent, APISelectMenuOption, ComponentType } from 'discord-api-types/v10';
import { SelectMenuBuilder, SelectMenuOptionBuilder } from '../../src/index';

const selectMenu = () => new SelectMenuBuilder();
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/__tests__/components/textInput.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APITextInputComponent, ComponentType, TextInputStyle } from 'discord-api-types/v9';
import { APITextInputComponent, ComponentType, TextInputStyle } from 'discord-api-types/v10';
import {
labelValidator,
maxLengthValidator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
APIApplicationCommandUserOption,
ApplicationCommandOptionType,
ChannelType,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import {
SlashCommandBooleanOption,
SlashCommandChannelOption,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandOptionChoice, ChannelType } from 'discord-api-types/v9';
import { APIApplicationCommandOptionChoice, ChannelType } from 'discord-api-types/v10';
import {
SlashCommandAssertions,
SlashCommandBooleanOption,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/__tests__/interactions/modal.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIModalInteractionResponseCallbackData, ComponentType, TextInputStyle } from 'discord-api-types/v9';
import { APIModalInteractionResponseCallbackData, ComponentType, TextInputStyle } from 'discord-api-types/v10';
import {
ActionRowBuilder,
ButtonBuilder,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"homepage": "https://discord.js.org",
"dependencies": {
"@sindresorhus/is": "^4.4.0",
"discord-api-types": "^0.27.3",
"discord-api-types": "^0.29.0",
"fast-deep-equal": "^3.1.3",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/ActionRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ComponentType,
APIMessageActionRowComponent,
APIModalActionRowComponent,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import type { ButtonBuilder, SelectMenuBuilder, TextInputBuilder } from '..';
import { ComponentBuilder } from './Component';
import { createComponentBuilder } from './Components';
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Assertions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIMessageComponentEmoji, ButtonStyle } from 'discord-api-types/v9';
import { APIMessageComponentEmoji, ButtonStyle } from 'discord-api-types/v10';
import { z } from 'zod';
import type { SelectMenuOptionBuilder } from './selectMenu/SelectMenuOption';

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
APIModalActionRowComponent,
APIModalComponent,
ComponentType,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';

/**
* Represents a discord component
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/Components.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v9';
import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v10';
import { ActionRowBuilder, ButtonBuilder, ComponentBuilder, SelectMenuBuilder, TextInputBuilder } from '../index';
import type { MessageComponentBuilder, ModalComponentBuilder } from './ActionRow';

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/button/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
APIButtonComponent,
APIButtonComponentWithCustomId,
APIButtonComponentWithURL,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import {
buttonLabelValidator,
buttonStyleValidator,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/button/UnsafeButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type APIButtonComponent,
type APIButtonComponentWithURL,
type APIButtonComponentWithCustomId,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import { ComponentBuilder } from '../Component';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/selectMenu/SelectMenu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APISelectMenuComponent } from 'discord-api-types/v9';
import type { APISelectMenuComponent } from 'discord-api-types/v10';
import {
customIdValidator,
disabledValidator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v9';
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';
import {
defaultValidator,
emojiValidator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APISelectMenuOption, ComponentType, type APISelectMenuComponent } from 'discord-api-types/v9';
import { APISelectMenuOption, ComponentType, type APISelectMenuComponent } from 'discord-api-types/v10';
import { ComponentBuilder } from '../Component';
import { UnsafeSelectMenuOptionBuilder } from './UnsafeSelectMenuOption';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v9';
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';

/**
* Represents a non-validated option within a select menu component
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/textInput/Assertions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextInputStyle } from 'discord-api-types/v9';
import { TextInputStyle } from 'discord-api-types/v10';
import { z } from 'zod';
import { customIdValidator } from '../Assertions';

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/components/textInput/TextInput.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 {
maxLengthValidator,
minLengthValidator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentType, type TextInputStyle, type APITextInputComponent } from 'discord-api-types/v9';
import { ComponentType, type TextInputStyle, type APITextInputComponent } from 'discord-api-types/v10';
import { ComponentBuilder } from '../../index';
import isEqual from 'fast-deep-equal';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { ApplicationCommandType } from 'discord-api-types/v9';
import { ApplicationCommandType } from 'discord-api-types/v10';
import type { ContextMenuCommandType } from './ContextMenuCommandBuilder';

const namePredicate = z
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { validateRequiredParameters, validateName, validateType, validateDefaultPermission } from './Assertions';
import type { ApplicationCommandType, RESTPostAPIApplicationCommandsJSONBody } from 'discord-api-types/v9';
import type { ApplicationCommandType, RESTPostAPIApplicationCommandsJSONBody } from 'discord-api-types/v10';

export class ContextMenuCommandBuilder {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/interactions/modals/Modal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIModalInteractionResponseCallbackData } from 'discord-api-types/v9';
import type { APIModalInteractionResponseCallbackData } from 'discord-api-types/v10';
import { customIdValidator } from '../../components/Assertions';
import { titleValidator, validateRequiredParameters } from './Assertions';
import { UnsafeModalBuilder } from './UnsafeModal';
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/interactions/modals/UnsafeModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
APIActionRowComponent,
APIModalActionRowComponent,
APIModalInteractionResponseCallbackData,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import { ActionRowBuilder, createComponentBuilder, JSONEncodable, ModalActionRowComponentBuilder } from '../../index';

export class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import is from '@sindresorhus/is';
import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';
import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v10';
import { z } from 'zod';
import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIApplicationCommandOption, RESTPostAPIApplicationCommandsJSONBody } from 'discord-api-types/v9';
import type { APIApplicationCommandOption, RESTPostAPIApplicationCommandsJSONBody } from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import {
assertReturnOfBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
APIApplicationCommandSubcommandGroupOption,
APIApplicationCommandSubcommandOption,
ApplicationCommandOptionType,
} from 'discord-api-types/v9';
} from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import { assertReturnOfBuilder, validateMaxOptionsLength, validateRequiredParameters } from './Assertions';
import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIApplicationCommandBasicOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import type { APIApplicationCommandBasicOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { validateRequiredParameters, validateRequired } from '../Assertions';
import { SharedNameAndDescription } from './NameAndDescription';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChannelType } from 'discord-api-types/v9';
import { ChannelType } from 'discord-api-types/v10';
import { z, ZodLiteral } from 'zod';

// Only allow valid channel types to be used. (This can't be dynamic because const enums are erased at runtime)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { z } from 'zod';
import { validateChoicesLength } from '../Assertions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandAttachmentOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandAttachmentOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandBooleanOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandBooleanOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandChannelOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandChannelOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';
import { ApplicationCommandOptionChannelTypesMixin } from '../mixins/ApplicationCommandOptionChannelTypesMixin';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import { z } from 'zod';
import { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandMentionableOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandMentionableOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import { z } from 'zod';
import { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandRoleOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandRoleOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandRoleOption extends ApplicationCommandOptionBase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandStringOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandStringOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { mix } from 'ts-mixer';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';
import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIApplicationCommandUserOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { APIApplicationCommandUserOption, ApplicationCommandOptionType } from 'discord-api-types/v10';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandUserOption extends ApplicationCommandOptionBase {
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/messages/embed/Assertions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIEmbedField } from 'discord-api-types/v9';
import type { APIEmbedField } from 'discord-api-types/v10';
import { z } from 'zod';

export const fieldNamePredicate = z.string().min(1).max(256);
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/messages/embed/Embed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIEmbedField } from 'discord-api-types/v9';
import type { APIEmbedField } from 'discord-api-types/v10';
import {
authorNamePredicate,
colorPredicate,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/messages/embed/UnsafeEmbed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v9';
import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';

export type RGBTuple = [red: number, green: number, blue: number];

Expand Down
2 changes: 1 addition & 1 deletion packages/builders/src/util/componentUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { APIEmbed } from 'discord-api-types/v9';
import type { APIEmbed } from 'discord-api-types/v10';

export function embedLength(data: APIEmbed) {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Register a slash command against the Discord API:

```js
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { Routes } = require('discord-api-types/v10');

const commands = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@discordjs/rest": "workspace:^",
"@sapphire/snowflake": "^3.1.0",
"@types/ws": "^8.2.2",
"discord-api-types": "^0.27.3",
"discord-api-types": "^0.29.0",
"fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1",
"undici": "^4.14.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const process = require('node:process');
const { Collection } = require('@discordjs/collection');
const { OAuth2Scopes, Routes } = require('discord-api-types/v9');
const { OAuth2Scopes, Routes } = require('discord-api-types/v10');
const BaseClient = require('./BaseClient');
const ActionsManager = require('./actions/ActionsManager');
const ClientVoiceManager = require('./voice/ClientVoiceManager');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v9');
const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v10');
const Action = require('./Action');
const AutocompleteInteraction = require('../../structures/AutocompleteInteraction');
const ButtonInteraction = require('../../structures/ButtonInteraction');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const EventEmitter = require('node:events');
const { setImmediate } = require('node:timers');
const { setTimeout: sleep } = require('node:timers/promises');
const { Collection } = require('@discordjs/collection');
const { GatewayCloseCodes, GatewayDispatchEvents, Routes } = require('discord-api-types/v9');
const { GatewayCloseCodes, GatewayDispatchEvents, Routes } = require('discord-api-types/v10');
const WebSocketShard = require('./WebSocketShard');
const PacketHandlers = require('./handlers');
const { Error } = require('../../errors');
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/client/websocket/WebSocketShard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const EventEmitter = require('node:events');
const { setTimeout, setInterval, clearTimeout, clearInterval } = require('node:timers');
const { GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes } = require('discord-api-types/v9');
const { GatewayDispatchEvents, GatewayIntentBits, GatewayOpcodes } = require('discord-api-types/v10');
const WebSocket = require('../../WebSocket');
const Events = require('../../util/Events');
const IntentsBitField = require('../../util/IntentsBitField');
Expand Down
Loading

0 comments on commit 72577c4

Please sign in to comment.