discordjs / discord-api-types Goto Github PK
View Code? Open in Web Editor NEWUp to date Discord API Typings, versioned by the API version
Home Page: https://discord-api-types.dev
License: MIT License
Up to date Discord API Typings, versioned by the API version
Home Page: https://discord-api-types.dev
License: MIT License
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
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'
}
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
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>'.
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!
Re-organize interactions structure because 1 file is NOT enough
Consider re-organizing all REST files based on their methods? so we'd do /rest/interactions/<method>.ts, where we define just that method's interfaces, respecting the current naming convention
Oauth2 types. Are they even accurate? Nobody knows. Need to shoot an eye at those again, esp with all the scopes... Lord spare me
Boopable Noses - Soon™️
Please describe the problem you are having in as much detail as possible:
The type in question:
discord-api-types/payloads/v9/_interactions/applicationCommands.ts
Lines 83 to 85 in b6babf2
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:
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.
discord-api-types/payloads/v9/channel.ts
Line 1159 in 3ff85ee
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.
If anyone wants to help out with this, be our guest! However this issue is more less for a TODO
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 import and use RESTError
import { RESTError } from 'discord-api-types/v10';
I'm looking for the type information for the following rest routes and it seems they are not present:
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:
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
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:
This property:
I can't find it anywhere in the docs, vlad said "its something that needs to be removed". I cant PR it now but ill try to if i get time.
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.
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:
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
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.)
we can make a Snowflake type like discordjs/discord.js#5157
docs already say snowflake for snowflake properties
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
Please describe the problem you are having in as much detail as possible:
Per discordjs/discord.js/pull/6204, I believe some typings need to be updated over here!
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:
discord-api-types/deno/payloads/v10/gateway.ts
Lines 107 to 109 in b216f7a
Include a reproducible code sample here, if possible:
Code example is shown above
Further details:
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:
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)
discord-api-types/v8/payloads/channel.ts
Lines 21 to 38 in 664ad80
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?
discord-api-types/gateway/v10.ts
Line 520 in db99388
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 .
Include a reproducible code sample here, if possible:
// Place your code here
Further details:
After installing got issue "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in"
Further details:
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:
Min and Max Length for Command Options
July 1, 2022
Application command options of type
STRING
now includes optionalmin_length
andmax_length
fields to control the length of text a user can input.The value of
min_length
must be greater or equal to0
, and the value ofmax_length
must be greater or equal to1
.
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 😄
Please describe the problem you are having in as much detail as possible:
https://discord.com/channels/222078108977594368/1005167313877741588
Include a reproducible code sample here, if possible:
declare const channel: import('discord-api-types/v10').APIThreadChannel
channel.total_message_sent
Further details:
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
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.
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 :-)
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:
npm i -s discord-api-types
test.ts
with the following code.import { Routes } from "discord-api-types";
console.log(Routes.applicationCommands("123"));
ts-node test
and see the error.Further details:
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:
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:
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
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?
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:
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
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]
]
}
}
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.
"</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
0.37.14
Node.js
v16.13.2 [email protected]
Medium (should be fixed soon)
there are many api routes documented in the GameSDK pages, we should probably add typings for those
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:
interaction as APIChatInputApplicationCommandInteraction
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:
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.
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:
Please describe the problem you are having in as much detail as possible:
GuildChannelType
does not include category channels:
discord-api-types/payloads/v10/channel.ts
Lines 42 to 56 in 04b3a7f
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:
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.