Giter VIP home page Giter VIP logo

discord-api-types's People

Contributors

advaith1 avatar almeidx avatar almostsouji avatar andre4ik3 avatar cherryblossom000 avatar ckohen avatar codershiba avatar cyyynthia avatar dependabot[bot] avatar didinele avatar eejit43 avatar fyko avatar github-actions[bot] avatar ianmitchell avatar ishibi avatar jaw0r3k avatar jiralite avatar kyranet avatar mateo-tem avatar n1ckpro avatar notsugden avatar renegade334 avatar renovate[bot] avatar sdanialraza avatar suneettipirneni avatar superchupudev avatar tttie avatar vaporoxx avatar vladfrangu avatar vvito7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-api-types's Issues

Incorrect autocomplete data typings

Please describe the problem you are having in as much detail as possible:

It seems like the Autocomplete types are incorrect/incomplete, if it is indeed incorrect, I'm willing to make a PR, if nobody else does.

Include a reproducible code sample here, if possible:

import { APIInteraction, InteractionType } from 'discord-api-types/v9';

const interaction: APIInteraction = {} as APIInteraction;
if (interaction.type === InteractionType.ApplicationCommandAutocomplete) {
    // Property 'options' does not exist on type 'APIApplicationCommandInteractionData'.
    //  Property 'options' does not exist on type 'APIUserApplicationCommandInteractionData'.
    interaction.data?.options;
}

I expect i should be able to do this:

interaction.data?.options[0]?.value // string | number | undefined

Further details:

NodeJS Version: v16.9.1
discord-api-types Version: 0.25.0-next.bc1d03e.1635987681

file or folder not found

i tried installing discord api types, but looks like it didnt work

~/.../stuff/hazy $ npm install @discordjs/discord-api-types
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@discordjs%2fdiscord-api-types - Not found
npm ERR! 404
npm ERR! 404  '@discordjs/discord-api-types@*' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

these are all the versions

~/.../stuff/hazy $ npm version
{
  hazy: '1.0.0',
  npm: '8.2.0',
  node: '17.2.0',
  v8: '9.6.180.14-node.12',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '102',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1l',
  cldr: '40.0',
  icu: '70.1',
  tz: '2021a3',
  unicode: '14.0'
}

Move from const enums

Is your feature request related to a problem? Please describe.
I need to access one of the enums (ApplicationCommandOptionType) but do it dynamically, currently it's a const enum so you are unable to do that

Describe the ideal solution
It's made a non const enum

Describe alternatives you've considered
Copying and pasting the enum into my project (I will then have to make sure I constantly update this which works but isn't ideal)

Additional context
Would be worth doing this on discord.js itself if there aren't plans to fully use this package on djs

Union type for data leads to an error

Please describe the problem you are having in as much detail as possible:
Type of APIButtonComponent has no custom_id property because the union type is used. It should be an interface extending the types. Maybe this is not the only type that has the same issue.

Include a reproducible code sample here, if possible:

let button!: APIButtonComponent;
button.custom_id; // Property 'custom_id' does not exist on type 'APIButtonComponentWithURL'.

@discordjs/builders:

new ButtonBuilder().data.custom_id; // Property 'custom_id' does not exist on type 'Partial<APIButtonComponentWithURL>'.
  • Runtime:
    • Node.js version: v16.17.0
  • Priority this issue should have: Medium

Current sync status with Discord API Docs PRs

A lot of PRs are (still) open in Discord's API Docs repository, and some features may arrive that we don't have the types for yet Vlad from the future here: that isn't the case anymore
This issue is here just as a check list to make sure we are at least up to date with Discord

If any of these have been done already, let me know here, on Discord, and if not, feel free to either let us know here or make a PR!

Round 1
Round 2

`APIInteractionDataResolvedChannel` missing thread-specific data

Please describe the problem you are having in as much detail as possible:
The type in question:

export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
permissions: Permissions;
}

I noticed that from discordjs/discord.js/pull/6521, thread channels returned the following (example) payload:

{
  '879342171570978847': {
    type: 11,
    thread_metadata: {
      locked: false,
      auto_archive_duration: 1440,
      archived: false,
      archive_timestamp: '2021-08-24T23:08:09.721000+00:00'
    },
    permissions: '549755813887',
    parent_id: '846428632897290260',
    name: 'hi',
    id: '879342171570978847'
  }
}

As you can see, there is more than id, name, type & permissions here! parent_id and thread_metadata are also included.

Further details:

  • Node.js version: 16.6.1
  • Priority this issue should have – please be realistic and elaborate if possible: Medium

Options in Select Menus are marked as optional when they're not

Please describe the problem you are having in as much detail as possible:
According to the following line, options is marked as an optional property in Select Menu components. However, this is not the case, and the API will return it as a bad request if you attempt to omit the options property when sending a Select Menu component.

options?: APISelectMenuOption[];

Include a reproducible code sample here, if possible:
N/A

Further details:
The PR #209 mistakenly marks the property as optional in Select Menus. The PR refers to a PR made on the Discord API Docs which marks the options property as optional in a general Message Component object, not a Select Menu object.

API v8 support

If anyone wants to help out with this, be our guest! However this issue is more less for a TODO

  • copy all files from v6 into a v8 folder
  • update all payloads accordingly

Prepare discord-api-types for TS 4.5 and the separation of optional properties from potentially undefined

Is your feature request related to a problem? Please describe.
We need to create types for REST that are separate from the return type to allow you passing undefined when sending, since thats removed when JSON.stringify-ing, while the return data from the API will never have undefined properties.

Additional context
https://canary.discord.com/channels/222078108977594368/222079895583457280/903057264498339860

Cannot use RESTError

Cannot import and use RESTError

import { RESTError } from 'discord-api-types/v10';
  • Runtime:
    • Node.js version: v16.14.2

Importing into typescript project not working with bun

Please describe the problem you are having in as much detail as possible:
When trying to import the GatewayIntentBits into a project, when running it with bun, the following error is displayed:

$ bun run src/lib/discord/bot.ts
[0.89ms] ".env"


error: Could not resolve: "discord-api-types/gateway". Maybe you need to "bun install"?

import { GatewayIntentBits } from "discord-api-types/gateway";
                                  ^

I have run bun install discord-api-types

A similar error is displayed with "discord-api-types/v10" and just "discord-api-types"

Include a reproducible code sample here, if possible:

import { GatewayIntentBits } from "discord-api-types/gateway";

Further details:

  • Runtime: bun 0.1.8
    • Node.js version:
    • deno version:
  • Priority this issue should have – please be realistic and elaborate if possible: Medium, since while this is a complete failture, bun is a new runtime

no value for chat input command option

Please describe the problem you are having in as much detail as possible:
hello, so, i have command, that needs to access option value, but ts yells that there is no .value for this.
Include a reproducible code sample here, if possible:

import { SlashCommandContext } from '../context'

export default (ctx: SlashCommandContext): Response => {
  return ctx.reply({
    content: ctx.data.options![0].value,
  })
}

Further details:
context is type which is union of APIChatInputApplicationCommandInteraction and two methods, reply and edit

  • Runtime:
    • Node.js version: not node
    • deno version: not deno
  • Priority this issue should have:

fix: revert Snowflake type

Please describe the problem you are having in as much detail as possible:

The Snowflake = `${bigint}` structure is quite annoying

Also just posting this coz @vladfrangu asked on sapphire discord

Include a reproducible code sample here, if possible:

N.A.

// Place your code here

Further details:

  • Runtime:
    • Node.js version: N.A.
    • deno version: N.A.
  • Priority this issue should have – please be realistic and elaborate if possible: medium

Misalignment in the README image

Please describe the problem you are having in as much detail as possible:
My eyes are bleeding when I see this.

Include a reproducible code sample here, if possible:
N/A

Further details:
The DISCORD word is too left from center of image. API TYPES is OK.

Type of permissions slash commands

  • My issue is to propose to remove the type of permissions related to slash commands which for some are no longer used because of the new Discord API.

Route for "Modify Current Member" is undocumented

Please describe the problem you are having in as much detail as possible:

Include a reproducible code sample here, if possible:

// Place your code here

Further details:

  • Runtime:
    • Node.js version:
    • deno version:
  • Priority this issue should have – please be realistic and elaborate if possible:

Eventual versioning changes for discord-api-types

The versioning system for discord-api-types will change (eventually)!

First off, if you're reading this, hi, didn't expect you to. This is a short PSA that in the (hopefully near) future the versioning system for discord-api-types will change

What's changing and, most importantly, why?

Currently, discord-api-types uses the 0ver versioning system (find out more here: https://0ver.org/). This has worked mostly fine for a long time (and changing it to full semver made no sense since we'd have effectively the same versioning troubles between them).

However, as time has shown several times due to the nature of Discord's API, such a versioning system doesn't fully work. As such we are changing it...ish.

The new versioning system will follow the format: @discord-api-types/v<api version>@1.<major/minor>.<patch>. That means, if you plan on creating an interface that uses the api v10 of Discord's api, you could now install @discord-api-types/v10 (or the discord-api-types metapackage). That said, these packages will respect semver too (to a degree, it will always stay at major version 1), however certain major / breaking changes might not be represented as such (Discord doesn't do it, so why should we... 🤣). We will document this on our website as well as in a markdown file at the root of the repository.

Wait, scoped packages? Yes. The discord-api-types package itself will now be just a meta package re-exporting all versions in it. This also means you will now be able to fine tune which package you install, resulting in smaller installs size (yes, I, too, see the fact discord-api-types takes up like 3MB installed.)

Expose PermissionFlagsBits as a enum rather than a object

Is your feature request related to a problem? Please describe.
I have some code that needs to accept an array of permissions, ideally I would have this be an array of PermissionFlagsBits enum values but currently with it being a object there is no way to do this without recreating the object as a enum which is not possible to do dynamically.

Describe the ideal solution
Replace the PermissionFlagsBits object with a enum, or add a enum representation.

Describe alternatives you've considered
I could just require the user pass the string key for the object and then index PermissionFlagsBits with that, but it's inconsistent with other things that use enums and isnt nearly as nice.

PermissionFlagsBits is in discord-api-types\payloads\common.d.ts

Gateway Documentation changed

Please describe the problem you are having in as much detail as possible:

It seems the official documentation for the gateway has been split up in Gateway and Gateway-Events.
E.g. This Reference no longer works:

* https://discord.com/developers/docs/topics/gateway#client-status-object
*/
export interface GatewayPresenceClientStatus {

By now it should be as follows: https://discord.com/developers/docs/topics/gateway-events#client-status-object

Include a reproducible code sample here, if possible:

Code example is shown above

Further details:

  • none

GuildFeature is not a two-way enum

Please describe the problem you are having in as much detail as possible:

Many of the enums exported from discord-api-types are two-way enums, meaning that you can pass a key into the enum, and than that result back into the enum again to get the original key. This is true of the ChannelType enum for example, which has both the integer and string values as keys.

However, the GuildFeature enum only has the PascalCase values as keys, with the SCREAMING_SNAKE_CASE values missing from the keys. This means that you cannot convert the snake case values back to the pascal case values using the enum.

Include a reproducible code sample here, if possible:

import { ChannelType, GuildFeature } from 'discord-api-types';

console.log(ChannelType[ChannelType[0]]); // 0
console.log(GuildFeature[GuildFeature['Banner']]); // undefined

Further details:

  • Runtime:
    • Node.js version: 16.17.0
  • Priority this issue should have – please be realistic and elaborate if possible: P3, I can manually patch in my own enum for now, but inconsistency in the exports is no fun :(

chore: convert APIChannel into an union of channels, based on their `type`

Title says it all. Currently, the typings enumerate all properties, regardless of the channel's type (it is consistent with the docs). However, certain channel types won't respect props that don't make sense with them (recipients in text channels, rate_limit_per_user for voice channels, etc)

export interface APIChannel extends APIPartialChannel {
guild_id?: string;
position?: number;
permission_overwrites?: APIOverwrite[];
name?: string;
topic?: string | null;
nsfw?: boolean;
last_message_id?: string | null;
bitrate?: number;
user_limit?: number;
rate_limit_per_user?: number;
recipients?: APIUser[];
icon?: string | null;
owner_id?: string;
application_id?: string;
parent_id?: string | null;
last_pin_timestamp?: string | null;
}

Do keep in mind that, according to Discord, all channel types have the same properties you could set (one table after all) but only those that make sense are returned

Up to debate: do we keep as is, or separate raw API data per type? What would YOU want?

Wrong ATTACHMENT Application Command Option Type

Please describe the problem you are having in as much detail as possible:

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
The Document says ATTACHMENT type's data is attachment object but it's Snowflake in discord-api-types .

export type APIApplicationCommandInteractionDataAttachmentOption = APIInteractionDataOptionBase<
ApplicationCommandOptionType.Attachment,
Snowflake
>;

Include a reproducible code sample here, if possible:

// Place your code here

Further details:

  • Runtime:
    • Node.js version:
    • deno version:
  • Priority this issue should have – please be realistic and elaborate if possible:

`APIApplicationCommandOption#choices` has wrong type for `value`

Please describe the problem you are having in as much detail as possible:

The value type on an option choice is incorrect when setting the option to a STRING type for example.

Include a reproducible code sample here, if possible:

const data: APIApplicationCommandOption = {
    name: 'test',
    type: ApplicationCommandOptionType.String,
    choices: [
      {name: 'test', value: 'test'} // Type 'string' is not assignable to type 'number'
    ]
}; 

Further details:

  • Runtime:
    • Node.js version: 16.10;0
  • Priority this issue should have – please be realistic and elaborate if possible:
    Medium

suggestion: Add Deno support

Hi!

After seeing comment in Pull Request in Discord API Docs repo for adding Deno support (discord/discord-api-docs#2401 (comment)), I decided to try this out.

From what I know, only import/export style has changed in Deno which makes this incompatible, which does not have anything like index.js/ts file and always requires extension of file to be in import.

I've made a script which goes through all files and makes imports/exports compatible with Deno, https://github.com/DjDeveloperr/denoify-dapi-types. There's even a working GitHub action which deploys on deno branch on every push.
You can see live version on my fork of this repo, https://github.com/DjDeveloperr/discord-api-types.

I have tested, those auto-generated types do work with Deno 😄

Add support for Discord API v10

Is your feature request related to a problem? Please describe.
It is the new stable API version from discord. New features will only be released at v10+

Describe the ideal solution
Switch from API v9 to API v10

Additional context
API Release: discord/discord-api-docs#4510

Api.py

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Eg. I'm always frustrated when [...]

Describe the ideal solution
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Partial guild with permissions

It would be nice if there was some kind of OAuthGuild type

My proposal is to add a type that describes this partial guild object. As the neither the APIPartialGuild or the APIGuildPreview type does not have the permissions field for example.

I think this would be a great addition as I have not been able to find it anywhere. If it does exist, please tell me where :-)

Error: No "exports" main defined

Please describe the problem you are having in as much detail as possible:
When trying to use discord-api-types with TypeScript, I'm getting the following error.

Error: No "exports" main defined in C:\Users\Paul\Desktop\test\node_modules\discord-api-types\package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:413:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:652:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (C:\Users\Paul\Desktop\test\test.ts:1:1)

I tried it first with other code in a project, then a separate file and then a clean project, with a clean install, but the error doesn't change. I'm sure it's not me.

Include a reproducible code sample here, if possible:

  • Create a new project (folder)
  • Run npm i -s discord-api-types
  • Create a file called test.ts with the following code.
import { Routes } from "discord-api-types";

console.log(Routes.applicationCommands("123"));
  • Run ts-node test and see the error.

Further details:

  • Runtime:
    • Node.js version: v16.7.0

Type `ApplicationCommandType.User` is not assignable to `ContextMenuCommandType` after updating to 0.27.0

Please describe the problem you are having in as much detail as possible:
I don't know if this is more of a builders issue, but it showed up when dependabot tried to update discord-api-types in my repo, and it showed this error:
image
After looking at the builders source code, looks like ContextMenuCommandType should be working correctly, since it's defined as ApplicationCommandType.User | ApplicationCommandType.Message

Include a reproducible code sample here, if possible:

import { ContextMenuCommandBuilder } from '@discordjs/builders';
import { ApplicationCommandType } from 'discord-api-types';

export const data = new ContextMenuCommandBuilder().setName('Hi').setType(ApplicationCommandType.User);

Further details:

  • Runtime:
    • Node.js version: 17.4.0
    • deno version:
  • Priority this issue should have – please be realistic and elaborate if possible:
    Medium

Adding `Search` to the website

Is your feature request related to a problem? Please describe.
Sometimes it can be difficult to find the types on the website

Describe the ideal solution
In my opinion, I think that there should be a search bar so we can search for the Types on the website

Describe alternatives you've considered
no response

Additional context
no response

Route documentation inconsistent for "Modify Current Member"

Please describe the problem you are having in as much detail as possible:
Seeing other functions like guildVoiceState and user
They have a default value of "@me" and the type is Snowflake | @me and the routes are mentioned

       /**
	 * Route for:
	 * - PATCH `/guilds/{guild.id}/voice-states/@me`
	 * - PATCH `/guilds/{guild.id}/voice-states/{user.id}`
	 */
	guildVoiceState(guildId: Snowflake, userId: Snowflake | '@me' = '@me') {
		return `/guilds/${guildId}/voice-states/${userId}` as const;
	},

However for the guildMember function, the type for userId is just Snowflake, it doesn't have a default value and the @me is completely undocumented
shouldn't this be consistent?

autocomplete field present for some reason

Please describe the problem you are having in as much detail as possible:

I just migrated fully to discord-api-types in a package I am working on, and was wondering why RESTPostAPIChatInputApplicationCommandsJSONBody is typed as

export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
    type?: ApplicationCommandType.ChatInput;
    /**
     * Whether this application command option should be autocompleted
     */
    autocomplete?: boolean;
    description: string;
}

it has autocomplete property and I am unsure as to why? Especially as when trying to look at the source in this repository it doesn't seem to have this, the above code block is taken from the installed version (running latest as of posting this)

Further details:

  • Runtime:
    • Node.js version: 16
    • deno version: n/a
  • Priority this issue should have – please be realistic and elaborate if possible:

Since autocomplete is typed as optional it's not a big deal (especially as it's internal code) but would like to get this typed properly asap of course

Just got a lot of errors from the API

C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280
      throw new HTTPError.HTTPError(res.constructor.name, status, method, url, requestData);
            ^

Object
    at SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.queueRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22)
    at async MessageManager.edit (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\discord.js\src\managers\MessageManager.js:166:15)
    at async Object.success (C:\Users\HOST\Documents\GitHub\life-pv\things\info.js:287:13) {
  status: 502,
  method: 'PATCH',
  url: 'https://discord.com/api/v10/channels/905786048871813150/messages/993439280636624926',
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [
        {
          title: ' ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ 🐦Life Romania - Since 2020🐦\n' +
            ' ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ Live Info',
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [
            [Object],
            [Object],
            [Object],
            [Object],
            [Object],
            [Object]
          ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object]
          ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [ [Object], [Object], [Object], [Object] ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object]
          ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [ [Object], [Object], [Object] ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [ [Object], [Object], [Object], [Object] ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [ [Object], [Object], [Object], [Object] ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [ [Object], [Object], [Object], [Object] ]
        },
        {
          color: 12648192,
          image: { url: 'https://i.imgur.com/tAm48CY.png' },
          fields: [
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object], [Object],
            [Object], [Object]
          ]
        }
      ],
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: 0,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    }
  }
}
Object
    at SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.queueRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22) {
  status: 502,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/944592494337876028/guilds/770003066467778590/commands',
  requestBody: {
    files: undefined,
    json: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object]
    ]
  }
}
node:events:505
      throw er; // Unhandled 'error' event
      ^

Object
    at SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.queueRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22)
    at async GuildInviteManager._fetchMany (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\discord.js\src\managers\GuildInviteManager.js:158:18)
    at async Object.execute (C:\Users\HOST\Documents\GitHub\life-pv\events\basics\ready.js:231:26)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:384:10)
    at processTicksAndRejections (node:internal/process/task_queues:85:21) {
  status: 502,
  method: 'GET',
  url: 'https://discord.com/api/v10/guilds/770003066467778590/invites',
  requestBody: { files: undefined, json: undefined }
}
C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280
      throw new HTTPError.HTTPError(res.constructor.name, status, method, url, requestData);
            ^

Object
    at SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.queueRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22)
    at async WebSocketManager.connect (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\discord.js\src\client\websocket\WebSocketManager.js:139:9)
    at async Client.login (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\discord.js\src\client\Client.js:232:7) {
  status: 502,
  method: 'GET',
  url: 'https://discord.com/api/v10/gateway/bot',
  requestBody: { files: undefined, json: undefined }
}
Object
    at SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:280:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.runRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:162:16)
    at async SequentialHandler.queueRequest (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (C:\Users\HOST\Documents\GitHub\life-pv\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22) {
  status: 503,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/944592494337876028/guilds/770003066467778590/commands',
  requestBody: {
    files: undefined,
    json: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object]
    ]
  }
}

FormattingPatterns.SlashCommand no longer matches official documentation example

Issue description

In #597, FormattingPatterns.SlashCommand was updated.

In official documentation, Discord provides </airhorn:816437322781949972> as an example. This used to match before this change but now fails to match.

Code sample

"</airhorn:816437322781949972>".match(/<\/(?<fullName>(?<name>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32})(?: (?<subcommandOrGroup>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?(?: (?<subcommand>[-_\p{Letter}\p{Number}\p{sc=Deva}\p{sc=Thai}]{1,32}))?):(?<id>\d{17,20})>/)
// null
"</airhorn:816437322781949972>".match(FormattingPatterns.SlashCommand)
// null

Package version

0.37.14

Runtime

Node.js

Runtime version

v16.13.2 [email protected]

Priority this issue should have

Medium (should be fixed soon)

GameSDK routes

there are many api routes documented in the GameSDK pages, we should probably add typings for those

Cannot type narrow APIApplicationCommandInteraction

Please describe the problem you are having in as much detail as possible:

When trying to type narrow interaction object, it is impossible to type narrow it to chat input. I looked at interaction types and I can't work out why it is like that, so I'm asking for help. Maybe it is my issue, but I do not think so.

Include a reproducible code sample here, if possible:

I have function that takes interaction as APIChatInputApplicationCommandInteraction.

// Say you have an interaction and want to check if it's chat input (slash command)
if (interaction.type === 2 && interaction.data.type === 1) {
  // here interaction should definitely be chat input
  // but it's not, it still APIApplicationCommandInteraction
  // and can't assign to APIChatInputApplicationCommandInteraction
  await this.execute(interaction); // Type "APIApplicationCommandInteraction" not assignable to "APIChatInputApplicationCommandInteraction"

Further details:

CleanShot 2022-02-18 at 20 43 04@2x

  • Runtime:
    • Node.js version: v17.5.0
  • Priority this issue should have – please be realistic and elaborate if possible:
    Medium because it is a bug but can be bypass, e.g. by interaction as APIChatInputApplicationCommandInteraction

APIInteractionDataResolvedGuildMember is missing any way to identify user

Please describe the problem you are having in as much detail as possible:

The APIInteractionDataResolvedGuildMember type doesn't have a user property and doesn't even have an id for the user. So you can't identify who the member is when you get one of these.

Include a reproducible code sample here, if possible:

// Place your code here
interaction.options.getMentionable('name') // APIInteractionDataResolvedGuildMember is one of the return types

Further details:

export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {

  • Runtime:
    • Node.js version:
    • deno version:
  • Priority this issue should have – please be realistic and elaborate if possible:

Bring back const enums

History: #295

So there was a transpilation bug (microsoft/TypeScript#40499) that some people ran into, but that was fixed in Typescript 4.2. It should be possible to set preserveConstEnums and get the best of both worlds. I wouldn't be so bothered except my bundle size (via parcel) goes from 3k to 27k because it pulls in the whole big chunk for just a few numbers.

Installing with npm results in deprecation warnings

Please describe the problem you are having in as much detail as possible:
When I install the discord-api-types package with the command npm install discord.js @discordjs/rest discord-api-types I get the following warnings:

npm WARN deprecated @sapphire/[email protected]: This version has been automatically deprecated by @favware/npm-deprecate. Please use a newer version.
npm WARN deprecated [email protected]: No longer supported. Install the latest release (0.20.2)

In the package.json the following entries are added:

"dependencies": {
    "@discordjs/rest": "^0.1.0-canary.0",
    "discord-api-types": "^0.24.0",
    "discord.js": "^13.3.1"
}

Further details:

  • Runtime:
    • Node.js version: v17.0.1
  • Priority this issue should have – please be realistic and elaborate if possible: Low

`GuildChannelType` does not include category channels

Please describe the problem you are having in as much detail as possible:
GuildChannelType does not include category channels:

export type TextChannelType =
| ChannelType.DM
| ChannelType.GroupDM
| ChannelType.GuildAnnouncement
| ChannelType.PublicThread
| ChannelType.PrivateThread
| ChannelType.AnnouncementThread
| ChannelType.GuildText
| ChannelType.GuildForum
| ChannelType.GuildVoice;
export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildAnnouncement,
ChannelType.DM | ChannelType.GroupDM
>;

Include a reproducible code sample here, if possible:

import { ChannelType, GuildChannelType } from "discord-api-types/v10";

declare const guildChannelType: GuildChannelType;

if (ChannelType.GuildCategory === guildChannelType) {
  // This condition will always return 'false'
}

Further details:

  • Runtime:
    • Node.js version: 18.8.0
    • deno version: N/A
  • Priority this issue should have – please be realistic and elaborate if possible: Medium

Enable ApplicationCommandOptionType Typings As Human Readable

There are many Application Command input variable types ex 3=string, 10=number
We should add human readable typings similar to the ApplicationCommandTypes

/**
 * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
 */
export declare enum ApplicationCommandType {
    ChatInput = 1,
    User = 2,
    Message = 3
}

commandType = ApplicationCommandType.ChatInput;

A good solution might look like

/**
 * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-options-types
 */
export declare enum ApplicationCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP = 2,
STRING = 3,
INTEGER = 4,
BOOLEAN  = 5,
USER = 6,
CHANNEL = 7,
ROLE = 8,
MENTIONABLE = 9,
NUMBER = 10,
ATTACHMENT = 11
}

I'm not entirely sure what file this should be exported from so I'm creating a request instead of a pull request.

`export const enum` -> `export enum`

When the const keyword is prefixed before the declaration of an enum, the enum itself is obliterated during the compilation, this may produce errors if the enum is used as a value in a program.

For instance, we declare two enums, one with const and the other without const:

export enum Test {}

export const enum Test2 {}

The aforementioned code produces the following code:

export var Test;
(function (Test) {
})(Test || (Test = {}));

// "Test2" enum is entirely erased from the compiled code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.