Skip to content

Commit 7b1e5a7

Browse files
chore(release): 0.33.4 🎉 (#475)
Build ran for 8e5f07e Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8e5f07e commit 7b1e5a7

File tree

11 files changed

+456
-3
lines changed

11 files changed

+456
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [0.33.4](https://github.com/discordjs/discord-api-types/compare/0.33.3...0.33.4) (2022-06-06)
2+
3+
### Features
4+
5+
- **RESTPostAPIWebhookWithTokenJSONBody:** add `thread_name` ([#463](https://github.com/discordjs/discord-api-types/issues/463)) ([8e5f07e](https://github.com/discordjs/discord-api-types/commit/8e5f07e2eebc14e5777dbfb932ef54f252165524))
6+
17
## [0.33.3](https://github.com/discordjs/discord-api-types/compare/0.33.2...0.33.3) (2022-06-04)
28

39
### Bug Fixes

deno/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [0.33.4](https://github.com/discordjs/discord-api-types/compare/0.33.3...0.33.4) (2022-06-06)
2+
3+
### Features
4+
5+
- **RESTPostAPIWebhookWithTokenJSONBody:** add `thread_name` ([#463](https://github.com/discordjs/discord-api-types/issues/463)) ([8e5f07e](https://github.com/discordjs/discord-api-types/commit/8e5f07e2eebc14e5777dbfb932ef54f252165524))
6+
17
## [0.33.3](https://github.com/discordjs/discord-api-types/compare/0.33.2...0.33.3) (2022-06-04)
28

39
### Bug Fixes

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "discord-api-types",
3-
"version": "0.33.3",
3+
"version": "0.33.4",
44
"description": "Discord API typings that are kept up to date for use in bot library creation.",
55
"exports": {
66
"./globals": {
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
---
2+
id: contributing_to_discord-api-types
3+
title: How to Contribute
4+
sidebar_position: 1
5+
---
6+
7+
So, you'd like to contribute to `discord-api-types` but don't know where to start or what to do? Here are some of the
8+
things you need to keep in mind before opening a pull request!
9+
10+
:::tip Before you begin
11+
12+
We recommend you contribute either through locally editing the files on your desktop (which means also installing
13+
[`npm`](https://www.npmjs.com/) dependencies as this will ensure not only a consistent code style, but also that the
14+
`deno` types stay in sync automatically) or through a service like
15+
[`GitHub Codespaces`](https://github.com/features/codespaces).
16+
17+
:::
18+
19+
:::info Still can't figure it out?
20+
21+
No problem! We await you with open hands in our [`Discord Server`](https://discord.gg/djs) in the `#discord-api-types`
22+
channel (under the `Miscellaneous` category)
23+
24+
:::
25+
26+
### Install npm dependencies first
27+
28+
One of the most crucial steps is installing [`npm`](https://www.npmjs.com/) dependencies via `npm ci`. This ensures that
29+
linting can be done, and it also sets up the `git` hooks for building the `deno` types and automatically
30+
formatting/linting the code when you commit it.
31+
32+
If you forget to install [`npm`](https://www.npmjs.com/) dependencies, or are doing the contributions through other
33+
means (like directly from GitHub web), you might see a comment like this one being sent as a review to your pull
34+
request:
35+
36+
![An image showing the style of comment the automatic deno checker reports](./images/deno_types_out_of_sync.png)
37+
38+
The easiest way to solve this is to run the `build:deno` script (`npm run build:deno`) and pushing the results.
39+
40+
### Figure out if the update you want to contribute respects our rules about documentation
41+
42+
:::danger
43+
44+
We will not document client-only / client related types. If you plan on contributing, make sure the types you want to
45+
document can be used by bots and are _intended_ for usage by bots. This is a hard rule that will never change.
46+
47+
:::
48+
49+
Not every single update to the API is valid to be documented here. Our main stance for documentation is that properties
50+
must be known and documented on [`Discord's API Documentation repository`](https://github.com/discord/discord-api-docs),
51+
must be mentioned in an open pull request or must have received the green light to be used.
52+
53+
With that aside, there are times where documentation for certain types is not approved/merged by Discord on the grounds
54+
that `it isn't helpful for bots` (or similar), but it would actually benefit bot developers to have it documented (one
55+
good example is the UserFlags `SPAMMER` flag). As such, if you think your update should still be merged, please propose
56+
it and we will be handled on a case by case basis. If approved, your update will be documented with an `@unstable` tag.
57+
It will also not be subject to the same versioning rules as the rest of the types.
58+
59+
### Figure out what API versions need to receive the update
60+
61+
`discord-api-types` has multiple API versions in the repository, some of which may be considered `deprecated` or
62+
`discontinued` as we keep them till the version is completely dead before removing them. This is a good time to figure
63+
out which API versions need to be updated, and you can use the table below to guide you.
64+
65+
You can also check [`Discord's API versioning table`](https://discord.com/developers/docs/reference#api-versioning) if
66+
you want to be 1000% sure.
67+
68+
| **API Version** | **Should receive updates** |
69+
| :-------------: | :------------------------: |
70+
| 10 | Yes |
71+
| 9 | Yes |
72+
| 8 | No |
73+
| 7 | No |
74+
| 6 | No |
75+
76+
If the version you want to contribute to is not listed above (for instance if a new API version rolls out) or if the
77+
version you want to contribute to is for a different part of the API (for instance `voice`), feel free to submit it and
78+
we will review it accordingly.
79+
80+
### Figure out where exactly are the files you need to modify to make the update
81+
82+
The file structure might seem confusing at first, especially if it's your first time contributing, but we're here to
83+
guide you through it.
84+
85+
When you clone the repository for the first time, you'll see a folder structure like this (we've not mentioned some
86+
tooling specific files like `.eslintrc.json` to keep the structure clean). We've highlighted the important folders and
87+
files you need to keep in mind when contributing.
88+
89+
```bash {2,4-6,9-10,12-16}
90+
├── deno
91+
├── gateway
92+
├── node_modules (once you ran `npm ci`)
93+
├── payloads
94+
├── rest
95+
├── rpc
96+
├── scripts
97+
├── tests
98+
├── utils
99+
├── voice
100+
├── website
101+
├── globals.ts
102+
├── v6.ts
103+
├── v8.ts
104+
├── v9.ts
105+
├── v10.ts
106+
└── package.json
107+
```
108+
109+
#### `deno`
110+
111+
This folder stores the [`deno`](https://deno.land/) compatible typings for Discord's API.
112+
113+
:::danger
114+
115+
This folder should not be manually modified. Any manual changes will be overwritten by the `build:deno` script.
116+
117+
Any changes that need to be done to this folder need to be done through the `scripts/deno.mjs` file.
118+
119+
:::
120+
121+
#### `gateway`
122+
123+
This folder holds types that are strictly received from
124+
[`Discord's gateway`](https://discord.com/developers/docs/topics/gateway). It stores the gateway version the types are
125+
for, the intents and opcodes, and any data that can be received/sent through the gateway.
126+
127+
Each file in the folder represents a gateway version. It references types from the versioned [`payloads`](#payloads)
128+
folder unless the payloads come _only_ through the gateway. There is also a `common.ts` file which represents shared
129+
types across all versions, as well as an `index.ts` file that exports the recommended gateway version's types.
130+
131+
:::info
132+
133+
Types created here must start with the `Gateway` prefix (for instance `GatewayGuildCreateDispatchData` which is an
134+
extension of the `APIGuild` type with extra fields received only through the gateway).
135+
136+
:::
137+
138+
#### `payloads`
139+
140+
This folder holds the bulk of type definitions for Discord's APIs. Each API version receives its own folder. Inside of
141+
each folder there is always an `index.ts` file that exports every type available in that version, as well as the common
142+
types that can be found in `payloads/common.ts`. At the root of the `payloads` folder is also an `index.ts` file which
143+
exports the recommended API version's types.
144+
145+
Inside of each versioned folder, the files are defined from the structure in
146+
[`Discord's API Documentation`](https://discord.dev), under the `Resources` category. Depending on the complexity of the
147+
resource, you may opt for splitting it up into multiple files. If you want to do so, please create a folder named
148+
`_{resource_name}` where the `resource_name` is the same name as the resource you're splitting up (a good example is the
149+
`_interactions` folder which stores all the types for interactions in a neater structure), and create a
150+
`{resource_name}.ts` file which exports everything from that folder). If you feel like you need to split it up even
151+
more, just repeat the same structure of creating an `_{file_name}` folder and exporting everything from it in the
152+
`{file_name}.ts` file (you can see an example
153+
[here](https://github.com/discordjs/discord-api-types/tree/85802f1/payloads/v10/_interactions)).
154+
155+
:::info
156+
157+
Types created here must start with the `API` prefix (for instance `APIUser`), **except** for enums, which should have a
158+
normal name (for instance `UserFlags`).
159+
160+
:::
161+
162+
#### `rest`
163+
164+
This folder holds all the types that are related to Discord's REST API. Just like [`payloads`](#payloads), it is split
165+
into folders that have an `index.ts` file. from the structure in [`Discord's API Documentation`](https://discord.dev),
166+
under the `Resources` category.
167+
168+
:::info
169+
170+
Types created here must start with the `REST` prefix (for instance `RESTGetAPIUserResult`) unless they are objects or
171+
enums (for instance `Routes`).
172+
173+
They must also follow the following structure: `REST{http_method}{type_name}{Query|(JSON|FormData)|Result}`, where:
174+
175+
- `http_method` is the PascalCase HTTP method name (for instance `Get`, `Post`, and so on)
176+
- `type_name` is the actual name of the type it returns (for instance `APIUser`)
177+
- `Query|(JSON|FormData)Body|Result` should be used depending on what the route takes or returns
178+
- If a route doesn't take in any parameters, be it query, JSON or FormData, it shouldn't define any of those types
179+
- A route should always define a `Result` type, and should reference an `API*` type unless the data returned is only
180+
received through a REST call
181+
- If a route returns a `204 No Content` response, it should define a `Result` type with `never` as its value (this
182+
does not account for errors)
183+
184+
This structure should be followed whenever possible, however that might not always be doable. Specifically, types for
185+
OAuth2 may not follow the structure exactly, but should aim to follow it as much as possible.
186+
187+
:::
188+
189+
#### `rpc`
190+
191+
This folder holds types that are strictly related to
192+
[`Discord's RPC API`](https://discord.com/developers/docs/topics/rpc). Just like [`gateway`](#gateway), each RPC API
193+
version receives its own file.
194+
195+
:::info
196+
197+
Types created here must start with the `RPC` prefix (for instance `RPCErrorCodes`).
198+
199+
:::
200+
201+
#### `scripts`
202+
203+
This folder holds the module's scripts that empower our Continuous Integration / Deployment pipelines, as well as other
204+
miscellaneous scripts we might need. There's really not much to say about these really...
205+
206+
#### `tests`
207+
208+
This folder holds tests for certain complex types that the module might have, and is especially useful for validating
209+
unions.
210+
211+
:::info
212+
213+
Files created here **must** end in `.test-d.ts`, as otherwise they will not be picked up by
214+
[`tsd`](https://www.npmjs.com/package/tsd).
215+
216+
:::
217+
218+
#### `utils`
219+
220+
This folder holds certain utility functions which can be used while working with some complicated types (for instance
221+
for more complicated unions). Each API version gets its own file with utility functions, but a folder can be created if
222+
a lot of methods are created.
223+
224+
:::info
225+
226+
The `internals.ts` file stores types that are strictly used inside the module to help build out our strict types. These
227+
types should never be exported from the module.
228+
229+
:::
230+
231+
#### `voice`
232+
233+
This folder holds types that are strictly related to
234+
[`Discord's Voice API`](https://discord.com/developers/docs/topics/voice-connections). It follows the same folder
235+
structure as [`gateway`](#gateway).
236+
237+
:::info
238+
239+
Types in this folder must start with the `Voice` prefix (for instance `VoiceOpcodes`).
240+
241+
:::
242+
243+
#### `website`
244+
245+
This folder holds...well...this very site you are reading this page from! For the most part, you do not need to alter
246+
its contents, except if you're contributing a new API version to the module.
247+
248+
To add the new version to this very website, edit the `docusaurus.config.js` file, and in the `plugins` array, for the
249+
`docusaurus-plugin-typedoc-api` plugin, you need to add an entry similar to the ones already present.
250+
251+
#### `globals.ts`
252+
253+
This file stores types that are present regardless of the API version you use.
254+
255+
#### `v*.ts`
256+
257+
These files export everything from the previously mentioned folders that match the version the file is named after. It
258+
serves as the entry point for importing types from the module (for example by importing `discord-api-types/v10`).
259+
260+
#### `package.json`
261+
262+
This is the entry point of the package for [`npm`](https://www.npmjs.com/). You won't need to edit this file unless
263+
you're adding a new API version, in which case you should follow the same structure as seen in the `exports` field.

0 commit comments

Comments
 (0)