Compare commits

...

55 Commits

Author SHA1 Message Date
Vlad Frangu
653b9ff17f chore(release): 0.18.0 🎉 (#125) 2021-04-18 11:03:16 +03:00
Advaith
bc9ab4556c refactor(Invite): rename InviteTargetUserType to InviteTargetType (#124)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

BREAKING CHANGE: `InviteTargetUserType` is renamed to `InviteTargetType`, to match the documentation.
  - Reference: https://github.com/discord/discord-api-docs/pull/2690
2021-04-18 10:34:51 +03:00
Advaith
abe05136fd fix(APIInvite): channel is not optional (#123)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-18 10:33:32 +03:00
Vlad Frangu
d6fb271df8 chore(release): 0.17.0 🎉 (#121) 2021-04-17 18:48:20 +03:00
Jan
3294fb15ae feat(WebhookMessage): add GET route types (#120)
- Reference: https://github.com/discord/discord-api-docs/pull/2812
2021-04-16 00:48:22 +03:00
Jan
9817623291 refactor(APISticker): remove preview_asset (#119)
BREAKING CHANGE: This removes the `preview_asset` property from sticket objects
  - Reference: https://github.com/discord/discord-api-docs/commit/b9b8db2
2021-04-15 17:59:30 +03:00
Jan
617f507427 fix(APIChannel): rtc_region is optional (#118)
BREAKING CHANGE: This corrects the fact that `rtc_region` isn't present on non-voice-like channels
2021-04-15 17:47:07 +03:00
Vlad Frangu
df09356edd chore(release): 0.16.0 🎉 (#117) 2021-04-14 20:44:47 +03:00
Vlad Frangu
21b572b7f2 feat(Guild): add nsfw property (#116) 2021-04-14 19:39:34 +03:00
Vlad Frangu
6451679c9a docs(Routes): add GET route to webhookMessage (#114) 2021-04-14 19:39:23 +03:00
Vlad Frangu
ced37d0a5e feat(RESTJSONErrorCode): add UnknownInteraction error code (#115) 2021-04-14 19:39:12 +03:00
Vlad Frangu
a95f40e5b8 fix(TypeScript): imports not working in TypeScript (#113) 2021-04-12 12:01:37 +03:00
Vlad Frangu
75f902b0f5 chore(release): 0.15.0 🎉 (#112)
* chore(release): 0.15.0 🎉

* fix(Scripts): `await` in `versions` script, log any errors from deno one

* chore(Changelog): update changelog
2021-04-11 23:29:03 +03:00
Jan
9420c3e0af fix(APIApplicationCommand): default_permission (#111)
BREAKING CHANGE: This renames the `default_permissions` property to `default_permission`, the correct spelling.
2021-04-11 23:08:13 +03:00
Vlad Frangu
24d8037c47 feat(*): Polish Week - Discord API Types Edition (#110)
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-11 21:45:23 +03:00
Advaith
07ba907242 feat(APIChannel): add rtc_region (#108)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-09 13:18:32 +03:00
Advaith
b90714f677 feat: invite reminder system message type and flag (#105)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-08 14:15:12 +03:00
Vlad Frangu
6cd75426c6 feat: stage channels! (#107) 2021-04-08 14:14:31 +03:00
Advaith
d8d7bccea6 feat(APIChannel): add video_quality_mode (#106)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-08 14:09:47 +03:00
Advaith
4462255168 feat(MessageFlags): EPHEMERAL desc and added LOADING (#109)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-04-08 14:09:01 +03:00
Vlad Frangu
679a5cfd77 chore: fix globs (#104) 2021-03-28 15:19:43 +03:00
Vlad Frangu
fc4b7e2708 chore: release 0.13.2 (#103) 2021-03-28 12:56:01 +03:00
Tiemen
15c171c558 fix(ApplicationCommandInteractionDataOptionSubCommandGroup): typo (#102)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-28 12:48:01 +03:00
Vlad Frangu
ebd5754242 chore: release 0.13.1 (#101) 2021-03-28 00:43:10 +02:00
Advaith
ffcd95d597 fix(APIInteractionResponse): data should not always be present (#100)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-28 00:40:52 +02:00
Vlad Frangu
2636bd0949 chore: release 0.13.0 (#99) 2021-03-27 18:15:41 +02:00
Advaith
ceb787ba36 feat(PermissionFlagsBits): add USE_APPLICATION_COMMANDS (#85)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 18:09:47 +02:00
Ben Richeson
ca61396577 chore(APIApplicationCommandInteractionDataOption): add types and their values (#72)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 18:06:35 +02:00
Advaith
0582f883c5 feat(APIBaseInteraction): add application_id (#98)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 17:40:14 +02:00
didinele
9d8d090c9c fix(RESTPostAPIChannelMessageJSONBody): mark tts as a full boolean (#96) 2021-03-17 10:02:14 +02:00
Vlad Frangu
eb3f8e1dea chore: add missing GitHub mds (#95) 2021-03-17 01:04:10 +02:00
Advaith
24155aeb71 feat(APIApplicationCommandInteractionData): add resolved (#86)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-16 01:05:44 +02:00
Advaith
76651acd49 chore(APIInteractionResponse, APIInteractionResponseType): remove old response types (#94)
Because they're out :3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-16 01:03:32 +02:00
Advaith
92f76f1a3c feat(APIApplication): add ApplicationFlags (#92)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-16 01:01:30 +02:00
Advaith
0f29b32e05 feat(APIMessage): add interaction (#93)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-16 01:00:04 +02:00
Apacheopteryx
7343fabe82 fix(deno): replace const enum exports in deno with normal enums (#89)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-16 00:56:02 +02:00
Advaith
d0b3106758 feat(APIInteraction): DM slash commands and property descriptions (#84)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-16 00:50:46 +02:00
Advaith
eafe7ba96f feat(APIInteractionResponse, APIInteractionResponseType): update for UI changes (#90) 2021-03-08 00:06:12 +02:00
Vlad Frangu
ff761755a6 chore: miscellaneous tasks (#77)
Co-authored-by: Noel <buechler.noel@outlook.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-02-18 19:20:46 +01:00
cherryblossom000
ae1900dc2f fix(RESTPostAPIGuildsJSONBody): make some fields nullable (#91) 2021-02-17 12:46:46 +02:00
didinele
466fa95b0e feat(rest): api base routes (#87)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-02-13 01:05:13 +02:00
aetheryx
70bfe9f4aa chore(Gateway): clarify Heartbeat OP as bidirectional (#83) 2021-02-06 19:01:58 +02:00
Vlad Frangu
63096d807d chore: add missing audit log keys (#81)
ref: https://github.com/discord/discord-api-docs/pull/2570
2021-02-05 22:29:00 +02:00
Advaith
855f36d930 feat(APIMessageReferenceSend): add fail_if_not_exists (#82) 2021-02-04 21:44:11 +02:00
Vlad Frangu
3bf9738a72 chore: shorten regular expression group properties (#80)
They are now strictly `id`, `name`, or `animated`.
2021-02-03 00:47:20 +02:00
Carter
4e4a084003 feat: implement FormatPatterns (#79)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-02-03 00:25:59 +02:00
TTtie
75ed123018 chore(APIGuildMember): make premium_since not optional (#78) 2021-01-29 23:28:35 +02:00
Vlad Frangu
5826da22e3 feat: add GET single Application Command (#76) 2021-01-26 23:47:37 +02:00
Vlad Frangu
da2c2e9ada feat: add Application Command events (#75) 2021-01-26 23:47:24 +02:00
Advaith
4c77a5d90a feat(Webhook): add Edit Webhook Message result and error 50027 (#71) 2021-01-26 21:59:23 +02:00
Advaith
84759d19bc feat(OAuth2): add /oauth2/@me route (#73) 2021-01-21 22:02:59 +02:00
Vlad Frangu
999b3594d8 chore: release 0.12.1 (#70)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-01-05 10:41:23 +02:00
Advaith
549a6f0236 feat: add Snowflake and Permissions types (#69)
Nice.
2021-01-05 02:54:11 +02:00
Vlad Frangu
35bd1f7dcd chore: move deno path from .deno to deno; update readme (#67) 2021-01-04 15:54:37 +02:00
Vlad Frangu
0ef46202f6 fix: run deno workflow only on branch push (#66) 2021-01-02 00:09:14 +02:00
173 changed files with 15272 additions and 5373 deletions

3
.babelrc Normal file
View File

@@ -0,0 +1,3 @@
{
"plugins": ["@babel/plugin-syntax-top-level-await"]
}

View File

@@ -1,4 +0,0 @@
// This file exports all the types available in the default API version
// Thereby, things MAY break in the future
export * from './v8/mod.ts';

View File

@@ -1,4 +0,0 @@
export * from '../common/mod.ts';
export * from './gateway/mod.ts';
export * from './payloads/mod.ts';
export * from './rest/mod.ts';

View File

@@ -1,4 +0,0 @@
export * from '../common/mod.ts';
export * from './gateway/mod.ts';
export * from './payloads/mod.ts';
export * from './rest/mod.ts';

View File

@@ -1,180 +0,0 @@
import type { APIGuildMember, APIUser, MessageFlags } from './mod.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/mod.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
*/
export interface APIApplicationCommand {
id: string;
application_id: string;
name: string;
description: string;
options?: APIApplicationCommandOption[];
}
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.BOOLEAN
| ApplicationCommandOptionType.USER
| ApplicationCommandOptionType.CHANNEL
| ApplicationCommandOptionType.ROLE;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.SUB_COMMAND | ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to @see APIApplicationCommandSubCommandOptions, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.STRING | ApplicationCommandOptionType.INTEGER;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
*/
export const enum ApplicationCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIInteraction {
id: string;
type: InteractionType;
data?: APIApplicationCommandInteractionData;
guild_id: string;
channel_id: string;
member: APIGuildMember & { permissions: string; user: APIUser };
token: string;
version: 1;
}
/**
* Like See APIInteraction, only with the `data` property always present
*/
export type APIApplicationCommandInteraction = Required<APIInteraction>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
*/
export const enum InteractionType {
Ping = 1,
ApplicationCommand,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: string;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
*/
export interface APIApplicationCommandInteractionDataOption {
name: string;
/**
* The value returned here depends on the `ApplicationCommandOptionType` type of the option with the name
* that matches this interface's `name`.
*
* You will need to manually cast this to the appropriate type based on the returned data
*/
value?: unknown;
options?: APIApplicationCommandInteractionDataOption[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interaction-response
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseAcknowledge
| APIInteractionResponseAcknowledgeWithSource
| APIInteractionResponseChannelMessage
| APIInteractionResponseChannelMessageWithSource;
export type APIInteractionResponsePong = InteractionResponsePayload<APIInteractionResponseType.Pong>;
export type APIInteractionResponseAcknowledge = InteractionResponsePayload<APIInteractionResponseType.Acknowledge>;
export type APIInteractionResponseAcknowledgeWithSource = InteractionResponsePayload<APIInteractionResponseType.AcknowledgeWithSource>;
export type APIInteractionResponseChannelMessage = InteractionResponsePayload<
APIInteractionResponseType.ChannelMessage,
true
>;
export type APIInteractionResponseChannelMessageWithSource = InteractionResponsePayload<
APIInteractionResponseType.ChannelMessageWithSource,
true
>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionresponsetype
*/
export const enum APIInteractionResponseType {
Pong = 1,
Acknowledge,
ChannelMessage,
ChannelMessageWithSource,
AcknowledgeWithSource,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionapplicationcommandcallbackdata
*/
export type APIInteractionApplicationCommandCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };
/**
* @internal
*/
interface InteractionResponsePayload<T extends APIInteractionResponseType, D = false> {
type: T;
data?: D extends true ? APIInteractionApplicationCommandCallbackData : never;
}

View File

@@ -1,77 +0,0 @@
import type { APIApplicationCommand, APIInteractionResponse } from '../payloads/mod.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
*/
export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsJSONBody = Omit<APIApplicationCommand, 'id' | 'application_id'>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionCallbackJSONBody & {
/**
* The file contents
*/
file: unknown;
});

76
.github/CODE_OF_CONDUCT.md vendored Normal file
View File

@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at https://discord.gg/bRCvFy9. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

91
.github/COMMIT_CONVENTION.md vendored Normal file
View File

@@ -0,0 +1,91 @@
## Git Commit Message Convention
> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).
#### TL;DR:
Messages must be matched by the following regex:
```js
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/;
```
#### Examples
Appears under "Features" header, `GuildMember` subheader:
```
feat(GuildMember): add 'tag' method
```
Appears under "Bug Fixes" header, `Guild` subheader, with a link to issue #28:
```
fix(Guild): handle events correctly
close #28
```
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
```
perf(core): improve patching by removing 'bar' option
BREAKING CHANGE: The 'bar' option has been removed.
```
The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.
```
revert: feat(Managers): add Managers
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
```
### Full Message Format
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
The **header** is mandatory and the **scope** of the header is optional.
### Revert
If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
### Type
If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.
Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
### Scope
The scope could be anything specifying the place of the commit change. For example `GuildMember`, `Guild`, `Message`, `MessageEmbed` etc...
### Subject
The subject contains a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end
### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.
### Footer
The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.

53
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,53 @@
# discord-api-types Contributing Guide
**The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the [Discord server](https://discord.gg/bRCvFy9) instead of opening an issue, or on [GitHub Discussions](https://github.com/discordjs/discord-api-types/discussions) you will get redirected there anyway.**
- [Code of Conduct](https://github.com/discordjs/discord-api-types/blob/main/.github/CODE_OF_CONDUCT.md)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Development Setup](#development-setup)
- [Project Structure](#project-structure)
- [Contributing Tests](#contributing-tests)
## Pull Request Guidelines
- Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch.
- If adding a new feature:
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.
- If fixing a bug:
- If you are resolving a special issue, add `fix/close #xxxx[,#xxxx]` (#xxxx is the issue id) in your PR body for a better release log, e.g.
```
fix(Guild): handle events correctly
close #28
```
- Provide a detailed description of the bug in the PR. Live demo preferred.
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.
- Make sure tests pass!
- Commit messages must follow the [commit message convention](./COMMIT_CONVENTION.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)).
- No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)).
## Development Setup
You will need [Node.js](http://nodejs.org) **version 12+**, and [npm](https://www.npmjs.com/).
After cloning the repo, run:
```bash
$ npm i # install the dependencies of the project
```
A high level overview of tools used:
- [TypeScript](https://www.typescriptlang.org/) as the development language
- [ESLint](https://eslint.org/) for code-style
- [Prettier](https://prettier.io/) for code formatting

25
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,25 @@
---
name: Bug report
about: Report incorrect or unexpected behavior of discord-api-types
title: ''
labels: 'bug'
assignees: ''
---
<!-- Use Discord for questions: https://discord.gg/bRCvFy9 -->
**Please describe the problem you are having in as much detail as possible:**
**Include a reproducible code sample here, if possible:**
```ts
// Place your code here
```
**Further details:**
- Runtime:
<!-- Complete whichever is applicable -->
- Node.js version:
- deno version:
- Priority this issue should have please be realistic and elaborate if possible:

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord server
url: https://discord.gg/bRCvFy9
about: Please visit our Discord server for questions and support requests.

View File

@@ -0,0 +1,21 @@
---
name: Feature request
about: Request a feature for the discord-api-types library
title: ''
labels: 'discussion'
assignees: ''
---
<!-- Use Discord for questions: https://discord.gg/bRCvFy9 -->
**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.

3
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,3 @@
**Please describe the changes this PR makes and why it should be merged:**
**Reference Discord API Docs PRs or commits:**

8
.github/SUPPORT.md vendored Normal file
View File

@@ -0,0 +1,8 @@
# Seeking support?
We only use this issue tracker for bug reports and feature request. We are not able to provide general support or answer questions in the form of GitHub issues.
For general questions about discord-api-types installation and use please ask in [GitHub Discussions](https://github.com/discordjs/discord-api-types/discussions),
or in the dedicated support channels in our Discord server: https://discord.gg/bRCvFy9
Any issues that don't directly involve a bug or a feature request will likely be closed and redirected.

63
.github/workflows/cicd.yml vendored Normal file
View File

@@ -0,0 +1,63 @@
name: Continuous Integration / Deployment
on:
push:
branches:
- '**'
pull_request:
jobs:
testing:
name: ESLint and TypeScript compilation
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Dependencies
run: npm ci
- name: Run ESLint
run: npm run test:lint
- name: Run TSC
run: npm run build:ci
deno:
name: Generate Deno compatible code
runs-on: ubuntu-latest
needs: testing
# Run workflow only if testing passes
if: needs.testing.result == 'success'
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install Dependencies
run: npm ci
- name: Build Files
run: npm run build:deno
- name: Set Git User and Email
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit and Push New Code
run: |
git add --all .
git commit -m "build: deno build for ${GITHUB_SHA}" || true
git push || true

View File

@@ -1,42 +0,0 @@
name: Code Quality
on:
push:
branches:
- master
- main
- stable
pull_request:
jobs:
ESLint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v1
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
run: npm ci
- name: Run ESLint
uses: icrawl/action-eslint@v1
with:
custom-glob: '{v*,default,common}/**'
TypeScript:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v1
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
run: npm ci
- name: Run TSC
uses: icrawl/action-tsc@v1

View File

@@ -1,40 +0,0 @@
name: Deno Deploy
on:
push:
jobs:
BuildDeno:
name: Publish Deno Types
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'release')"
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Dependencies
run: npm ci
- name: Get GitHub Branch Name
run: echo "GITHUB_BRANCH_NAME=$(echo ${{ github.ref }} | cut -c12-)" >> $GITHUB_ENV
- name: Push new code
run: |
# Build files
npm run build:deno
echo -e "\n# Commit and push"
git add --all .
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "build: deno build for ${GITHUB_SHA}" || true
git push origin $TARGET_BRANCH
env:
TARGET_BRANCH: '${{ env.GITHUB_BRANCH_NAME }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

59
.gitignore vendored
View File

@@ -1,24 +1,47 @@
node_modules/
out/
coverage/
.nyc_output/
debug.log
# Don't commit build outputs
globals.js
globals.*map
globals.d.ts
globals.mjs
v*/**/*.js
v*/**/*.map
v*/**/*.d.ts
v*/**/*.mjs
v*.js
v*.*map
v*.d.ts
v*.mjs
default/*.js
default/*.map
default/*.d.ts
default/*.mjs
gateway/**/*.js
gateway/**/*.map
gateway/**/*.d.ts
gateway/**/*.mjs
common/*.js
common/*.map
common/*.d.ts
common/*.mjs
payloads/**/*.js
payloads/**/*.map
payloads/**/*.d.ts
payloads/**/*.mjs
rest/**/*.js
rest/**/*.map
rest/**/*.d.ts
rest/**/*.mjs
rpc/**/*.js
rpc/**/*.map
rpc/**/*.d.ts
rpc/**/*.mjs
shortcuts/**/*.js
shortcuts/**/*.map
shortcuts/**/*.d.ts
shortcuts/**/*.mjs
utils/**/*.js
utils/**/*.map
utils/**/*.d.ts
utils/**/*.mjs
voice/**/*.js
voice/**/*.map
voice/**/*.d.ts
voice/**/*.mjs

5
.npmrc Normal file
View File

@@ -0,0 +1,5 @@
audit=false
fund=false
legacy-peer-deps=true
tag-version-prefix=""
message="chore(release): %s 🎉"

8
.prettierrc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"endOfLine": "lf"
}

4
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib"
}

357
CHANGELOG.md Normal file
View File

@@ -0,0 +1,357 @@
# [0.18.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.18.0) (2021-04-18)
### Bug Fixes
- **APIInvite:** `channel` is not optional ([#123](https://github.com/discordjs/discord-api-types/issues/123)) ([abe0513](https://github.com/discordjs/discord-api-types/commit/abe05136fd169f483fe09a213259b4cbd526497b))
### Code Refactoring
- **Invite:** rename `InviteTargetUserType` to `InviteTargetType` ([#124](https://github.com/discordjs/discord-api-types/issues/124)) ([bc9ab45](https://github.com/discordjs/discord-api-types/commit/bc9ab4556ca8a7c8e4c7942c87fa322c91b733dc))
### BREAKING CHANGES
- **Invite:** `InviteTargetUserType` is renamed to `InviteTargetType`, to match the documentation.
- Reference: https://github.com/discord/discord-api-docs/pull/2690
# [0.17.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.17.0) (2021-04-17)
### Bug Fixes
- **APIChannel:** `rtc_region` is optional ([#118](https://github.com/discordjs/discord-api-types/issues/118)) ([617f507](https://github.com/discordjs/discord-api-types/commit/617f507427fae6456de228a23809ab04c1df13f6))
### Code Refactoring
- **APISticker:** remove `preview_asset` ([#119](https://github.com/discordjs/discord-api-types/issues/119)) ([9817623](https://github.com/discordjs/discord-api-types/commit/9817623291ec852a831c3de225e90a65d83dac7f))
### Features
- **WebhookMessage:** add `GET` route types ([#120](https://github.com/discordjs/discord-api-types/issues/120)) ([3294fb1](https://github.com/discordjs/discord-api-types/commit/3294fb15ae6c259c1b53b7f2eca4ea8dca2f2372))
### BREAKING CHANGES
- **APISticker:** This removes the `preview_asset` property from sticket objects
- Reference: https://github.com/discord/discord-api-docs/commit/b9b8db2
- **APIChannel:** This corrects the fact that `rtc_region` isn't present on non-voice-like channels
# [0.16.0](https://github.com/discordjs/discord-api-types/compare/0.15.1...0.16.0) (2021-04-14)
### Features
- **Guild:** add `nsfw` property ([#116](https://github.com/discordjs/discord-api-types/issues/116)) ([21b572b](https://github.com/discordjs/discord-api-types/commit/21b572b7f25a320e40f8ca2e63d6bd8b111403aa))
- **RESTJSONErrorCode:** add `UnknownInteraction` error code ([#115](https://github.com/discordjs/discord-api-types/issues/115)) ([ced37d0](https://github.com/discordjs/discord-api-types/commit/ced37d0a5ebdc80887662529922c57e2531e1e5b))
### docs
- **Routes:** add `GET` routes to `webhookMessages` ([#114](https://github.com/discordjs/discord-api-types/issues/114)) ([6451679](https://github.com/discordjs/discord-api-types/commit/6451679c9acb9d7fde593914452577669473841d))
### BREAKING CHANGES
- **Routes:** possibly a breaking change due to the fact that the messageID is now strictly typed as a Snowflake or `@me`
- Reference: discord/discord-api-docs#2410
## [0.15.1](https://github.com/discordjs/discord-api-types/compare/0.15.0...0.15.1) (2021-04-12)
### Bug Fixes
- **TypeScript:** imports not working in TypeScript ([4738c33](https://github.com/discordjs/discord-api-types/commit/4738c33b062d359a1c2fbb35cdd2daf128ab6e5b))
# [0.15.0](https://github.com/discordjs/discord-api-types/compare/0.14.0...0.15.0) (2021-04-11)
### Bug Fixes
- **APIApplicationCommand:** default_permission ([#111](https://github.com/discordjs/discord-api-types/issues/111)) ([9420c3e](https://github.com/discordjs/discord-api-types/commit/9420c3e0af7b2486f0e49bb680ed98e0d9f5c625))
- **Scripts:** `await` in `versions` script, log any errors from deno one ([9113eb1](https://github.com/discordjs/discord-api-types/commit/9113eb133c4627445e2bcd4583c243dde74a20ee))
### BREAKING CHANGES
- **APIApplicationCommand:** This renames the `default_permissions` property to `default_permission`, the correct spelling.
# [0.14.0](https://github.com/discordjs/discord-api-types/compare/0.13.3...0.14.0) (2021-04-11)
### Bug Fixes
- **APIMessage:** correct type for `application` ([ed2cbe8](https://github.com/discordjs/discord-api-types/commit/ed2cbe82c56f872ee01a9eb6991ef70dc22d8c1f))
- **GatewayGuildMemberUpdateDispatchData:** correct types ([14f14e2](https://github.com/discordjs/discord-api-types/commit/14f14e227955af41ed2823f11c6e8d03d12549ba))
- **GatewayPresenceUpdateData:** `activities` may not be `null` ([bb3cb04](https://github.com/discordjs/discord-api-types/commit/bb3cb04e016840f66eecbe39c2e07aea8ea12bc8))
- **GatewayVoiceServerUpdateDispatchData:** `endpoint` is nullable ([e8203a1](https://github.com/discordjs/discord-api-types/commit/e8203a1112a834ce9aaae4ab95f711d3aaffc20f))
- **GuildWelcomeScreenChannel:** document missing `description` property ([238695b](https://github.com/discordjs/discord-api-types/commit/238695b44d8547d51782e3d9d9729e2db85bc444))
- **OAuth2:** `scope` can be optional / not required ([bbe56a9](https://github.com/discordjs/discord-api-types/commit/bbe56a97564ce8c317f291080327484f0d987e1c))
- **OAuth2:** remove invalid parameters from refresh token request ([1c02450](https://github.com/discordjs/discord-api-types/commit/1c024507f3f55b922565845c2bedac615ffa24d5))
- **RPC:** version `RPC` same as` rest`, export again in `shortcuts` ([67e0ba1](https://github.com/discordjs/discord-api-types/commit/67e0ba1834e6d9de9ad00bd452f5e8da59ff1cc6))
- **Utils:** correct import for deno users ([42dd75f](https://github.com/discordjs/discord-api-types/commit/42dd75f2581b2a8862e4f0446b42ff838f923de0))
### chore
- **Gateway:** remove `guild_subscriptions` ([ab8b289](https://github.com/discordjs/discord-api-types/commit/ab8b289ac8f99fe1a998ef06320ad9046aafa1d2))
- **GatewayReady:** un-document `private_channels` ([457edf4](https://github.com/discordjs/discord-api-types/commit/457edf4ed43327fb871d3b1638745b905518ef91))
- **Integrations:** remove routes that bots can no longer interact with ([577c5bd](https://github.com/discordjs/discord-api-types/commit/577c5bd040dd1dc258ca6c414cf6ac69ae84916c))
- **MessageGetReactions:** remove `before` pagination ([0ec26b7](https://github.com/discordjs/discord-api-types/commit/0ec26b731cda570f34e59e05a8c21f272b1fd64e))
- **Oauth2Scopes:** remove `rpc.api` ([7ee8511](https://github.com/discordjs/discord-api-types/commit/7ee85113ea8107106460889a2eaa42b251ee05d0))
- **Permissions:** rename `USE_APPLICATION_COMMANDS` to `USE_SLASH_COMMANDS` ([2aa7f7a](https://github.com/discordjs/discord-api-types/commit/2aa7f7a7b8da3d4d46a7743830562d996d32120b))
- **UserFlags:** un-document `SYSTEM` flag ([1774d4c](https://github.com/discordjs/discord-api-types/commit/1774d4c4749d303f24bfb3c754cf79a4ca7ef699))
### Code Refactoring
- restructure module ([81cdfc2](https://github.com/discordjs/discord-api-types/commit/81cdfc2d9c523d98edd0a69f976879e848e1167b))
### Features
- **APIApplication:** document `terms_of_service` and `privacy_policy` ([598cbfb](https://github.com/discordjs/discord-api-types/commit/598cbfb958a67d5ba61696ba877ea0bae4c4be55))
- **APIAttachment:** add `content_type` ([2d432d1](https://github.com/discordjs/discord-api-types/commit/2d432d145eb8a009b092b27b6231252d7b2f2823))
- **APIChannel:** add `rtc_region` ([#108](https://github.com/discordjs/discord-api-types/issues/108)) ([07ba907](https://github.com/discordjs/discord-api-types/commit/07ba9072429dec85a13479dc211ec1f9d8788acf))
- **APIChannel:** add `video_quality_mode` ([#106](https://github.com/discordjs/discord-api-types/issues/106)) ([d8d7bcc](https://github.com/discordjs/discord-api-types/commit/d8d7bccea617ad0d1150b9d2aed3b26ec1e4f99a))
- **APIInteraction:** add type-check utilities ([3307201](https://github.com/discordjs/discord-api-types/commit/33072011c2ea9ace8350dedc0cd1068660dc2ece))
- **Exports:** add `globals` to the exported sub-modules ([5d35f61](https://github.com/discordjs/discord-api-types/commit/5d35f61334480af983c4767373ef05e395da2e18))
- **Gateway:** add `INTEGRATION_*` events ([9c3fab0](https://github.com/discordjs/discord-api-types/commit/9c3fab052619609eb543ff400c2b813b69c6b99f))
- **GuildWelcomeScreen:** document `welcome-screen` endpoint ([169ecde](https://github.com/discordjs/discord-api-types/commit/169ecde47a6a911309630e952ab26b805ac87cf0))
- **Interactions:** add batch command create / update ([edfe70a](https://github.com/discordjs/discord-api-types/commit/edfe70a1eeec9be1104ec68a20d95e83512b3268))
- **Interactions:** add Slash Command Permissions ([f517f35](https://github.com/discordjs/discord-api-types/commit/f517f3596f458a2c2e4c4a26d5c13bbed4c4a71f))
- **Invites:** document `target_application` & correct property names ([97c8ab3](https://github.com/discordjs/discord-api-types/commit/97c8ab3f5165c6f161e9338e944cff8b296756d5))
- **MessageFlags:** `EPHEMERAL` desc and added `LOADING` ([#109](https://github.com/discordjs/discord-api-types/issues/109)) ([4462255](https://github.com/discordjs/discord-api-types/commit/4462255168af2ad66c9c7405500e80d3fa41de33))
- **PatchAPIWebhookMessage:** add `file` property ([fc2f3c5](https://github.com/discordjs/discord-api-types/commit/fc2f3c58cf5ea2a8c0a1a14a62a16f432b1776e2))
- **Webhook:** add & document `url` property ([77e5bb6](https://github.com/discordjs/discord-api-types/commit/77e5bb624d86e4bc8696c8dac4f513c27eb8aff1))
- invite reminder system message type and flag ([#105](https://github.com/discordjs/discord-api-types/issues/105)) ([b90714f](https://github.com/discordjs/discord-api-types/commit/b90714f677c67c009ddb6d00734ab8998c194350))
- stage channels! ([#107](https://github.com/discordjs/discord-api-types/issues/107)) ([6cd7542](https://github.com/discordjs/discord-api-types/commit/6cd75426c6d7da145b40a656e4c1a1d3d26bfb1f))
### BREAKING CHANGES
- **APIInteraction:** This commit removes the `guild_id` property from `APIDMInteraction`
which allows type-checks to work with the `in` operator.
Because of that, we also provide utility functions that help with those type checks.
Use them in your code by importing the `Utils` object, or by directly importing them.
Check the README for examples
- **OAuth2:** This commit removes parameters that are not expected
in the refresh token request body
Reference: https://github.com/discord/discord-api-docs/commit/eaa12cbc8f96cf7cfe8c530f88e60582c24ca5dd
- **GatewayReady:** This property has been deprecated for a while, and was
returning an empty array for bot users. This commit removes it entirely
Reference: https://github.com/discord/discord-api-docs/commit/f36156dbb641f5c4d4f4593f345bfd6e27fdee08
- **Permissions:** This commit brings consistency with the documentation,
where the permission is documented as `USE_SLASH_COMMANDS`, whereas the
client has it as `USE_APPLICATION_COMMANDS` internally
Reference: https://github.com/discord/discord-api-docs/commit/c7d25885c5cd80a49b31609a40b70603b35f9dec
- **MessageGetReactions:** This query parameter is not usable and was not respected
by the API.
Reference: https://github.com/discord/discord-api-docs/commit/f72b084773d4d3989fb19be4fb4d9cf276a1e6b3
- **OAuth2:** This removes the `scope` property from the authorization
code flow, as it is not expected there.
Reference: https://github.com/discord/discord-api-docs/commit/57965033ab4216a0bb853e85d6912531cd5a9981
- **Gateway:** This removes `guild_subscriptions`, as it has been
deprecated in favor of `intents`.
Reference: https://github.com/discord/discord-api-docs/commit/8de017436d37e56fab14cb8f68f0448a45ebc731
- **Oauth2Scopes:** This removes the `rpc.api` scope, as it has been removed
from the documentation.
Reference: https://github.com/discord/discord-api-docs/commit/2641d9808f676e7316483d152cdb37ed1168f968
- **APIMessage:** This removes the `APIMessageApplication` interface, as it has
been removed from the documentation, being replaced with the OAuth2 application.
Reference: https://github.com/discord/discord-api-docs/commit/ff0c831e424f1bc17dd3cde62da48d5c3d933e88
- **APIApplication:** This renames the `GatewayPresenceLimit` flag to
`GatewayPresenceLimited`, for consistency with `GatewayGuildMembersLimited`
and the documented name.
Reference: https://github.com/discord/discord-api-docs/commit/39b254bed1cc396c475e508a3f2bf328815605c9
- **GatewayVoiceServerUpdateDispatchData:** Any code that expects `endpoint` to never be null needs
to be updated, and the conditions specified in the documentation need
to be respected regarding that.
Reference: https://github.com/discord/discord-api-docs/commit/e887382fafd4c4417f7ba62963984f25bcb643f6
- **Invites:** This renames `target_user_type` to `target_type`,
the actual value the API expects.
Reference: https://github.com/discord/discord-api-docs/commit/1b4e363e324eb1f49a47e32cb0108fbe276c8e0e
- **GatewayPresenceUpdateData:** Clearing `activities` is done by setting them to an empty
array, not by setting them to `null`.
Reference: https://github.com/discord/discord-api-docs/commit/5bf598b864fb89262fce07137f68ce6e7e583432
- **UserFlags:** This removes a flag that bots should not use, as Discord
said this is an internal flag.
Reference: https://github.com/discord/discord-api-docs/commit/9293f0d490ac6acf9d627e429e5a8131b303b528
- **Integrations:** This removes the 3 routes that bots can no longer access.
Reference: https://github.com/discord/discord-api-docs/commit/efe4e5808b6826d40302e265a5ae9b5b65d92fe7
- **Exports:** Certain objects from this file have been moved to their
appropriate spot (such as JSON Error Codes)
- Files have been moved around in order to keep them
organized. Exports might also be missing, so please report if that is the
case.
## [0.13.3](https://github.com/discordjs/discord-api-types/compare/0.13.2...0.13.3) (2021-03-28)
## [0.13.2](https://github.com/discordjs/discord-api-types/compare/0.13.1...0.13.2) (2021-03-28)
### Bug Fixes
- **ApplicationCommandInteractionDataOptionSubCommandGroup:** typo ([#102](https://github.com/discordjs/discord-api-types/issues/102)) ([15c171c](https://github.com/discordjs/discord-api-types/commit/15c171c558a10cd6d1c4880e725af0e63dd82255))
## [0.13.1](https://github.com/discordjs/discord-api-types/compare/0.13.0...0.13.1) (2021-03-27)
### Bug Fixes
- **APIInteractionResponse:** `data` should not always be present ([#100](https://github.com/discordjs/discord-api-types/issues/100)) ([ffcd95d](https://github.com/discordjs/discord-api-types/commit/ffcd95d597a5d1c5b3ea072cd1dfb44f079de4b7))
# [0.13.0](https://github.com/discordjs/discord-api-types/compare/0.12.1...0.13.0) (2021-03-27)
### Bug Fixes
- **deno:** replace `const enum` exports in deno with normal `enum`s ([#89](https://github.com/discordjs/discord-api-types/issues/89)) ([7343fab](https://github.com/discordjs/discord-api-types/commit/7343fabe82e4321808bac784aed600afa8cf4249))
- **RESTPostAPIChannelMessageJSONBody:** mark `tts` as a full boolean ([#96](https://github.com/discordjs/discord-api-types/issues/96)) ([9d8d090](https://github.com/discordjs/discord-api-types/commit/9d8d090c9c6cd5be1f7b578b2f6a6387544f3359))
- **RESTPostAPIGuildsJSONBody:** make some fields nullable ([#91](https://github.com/discordjs/discord-api-types/issues/91)) ([ae1900d](https://github.com/discordjs/discord-api-types/commit/ae1900dc2f65065153b1bf2437348e63b63db49e))
### Features
- **APIApplication:** add ApplicationFlags ([#92](https://github.com/discordjs/discord-api-types/issues/92)) ([92f76f1](https://github.com/discordjs/discord-api-types/commit/92f76f1a3c8acf80689b994e9bfaec70d198aaa1))
- **APIApplicationCommandInteractionData:** add `resolved` ([#86](https://github.com/discordjs/discord-api-types/issues/86)) ([24155ae](https://github.com/discordjs/discord-api-types/commit/24155aeb71d46de48353ce01bfb48e197a84e59b))
- **APIBaseInteraction:** add application_id ([#98](https://github.com/discordjs/discord-api-types/issues/98)) ([0582f88](https://github.com/discordjs/discord-api-types/commit/0582f883c517e5fdc2373ac0a85717a7bfeec018))
- **APIInteraction:** DM slash commands and property descriptions ([#84](https://github.com/discordjs/discord-api-types/issues/84)) ([d0b3106](https://github.com/discordjs/discord-api-types/commit/d0b310675848f4724e47c490b06d828f7ede204c))
- **APIInteractionResponse, APIInteractionResponseType:** update for UI changes ([#90](https://github.com/discordjs/discord-api-types/issues/90)) ([eafe7ba](https://github.com/discordjs/discord-api-types/commit/eafe7ba96fc6e771579850a8a7de36adade8efdc))
- **APIMessage:** add `interaction` ([#93](https://github.com/discordjs/discord-api-types/issues/93)) ([0f29b32](https://github.com/discordjs/discord-api-types/commit/0f29b32e05abe89f70f72989024b9c63493782fa))
- **APIMessageReferenceSend:** add `fail_if_not_exists` ([#82](https://github.com/discordjs/discord-api-types/issues/82)) ([855f36d](https://github.com/discordjs/discord-api-types/commit/855f36d9309ae69f57da723648d3791e3134089e))
- **PermissionFlagsBits:** add `USE_APPLICATION_COMMANDS` ([#85](https://github.com/discordjs/discord-api-types/issues/85)) ([ceb787b](https://github.com/discordjs/discord-api-types/commit/ceb787ba36ed05f25f9acab86496d3054cb15013))
- **rest:** api base routes ([#87](https://github.com/discordjs/discord-api-types/issues/87)) ([466fa95](https://github.com/discordjs/discord-api-types/commit/466fa95b0e239b7984275959886b995a5020640a))
- add Application Command events ([#75](https://github.com/discordjs/discord-api-types/issues/75)) ([da2c2e9](https://github.com/discordjs/discord-api-types/commit/da2c2e9ada39482fce095c47339b40d6c24e683a))
- add GET single Application Command ([#76](https://github.com/discordjs/discord-api-types/issues/76)) ([5826da2](https://github.com/discordjs/discord-api-types/commit/5826da22e30839b1f9fcd73479f8bc0f213001bd))
- implement FormatPatterns ([#79](https://github.com/discordjs/discord-api-types/issues/79)) ([4e4a084](https://github.com/discordjs/discord-api-types/commit/4e4a0840036eddb89a1d49d69f59905dba206afb))
- **OAuth2:** add `/oauth2/[@me](https://github.com/me)` route ([#73](https://github.com/discordjs/discord-api-types/issues/73)) ([84759d1](https://github.com/discordjs/discord-api-types/commit/84759d19bc4cd0f33f0a94608c1af2b4d6a820c6))
- **Webhook:** add Edit Webhook Message result and error 50027 ([#71](https://github.com/discordjs/discord-api-types/issues/71)) ([4c77a5d](https://github.com/discordjs/discord-api-types/commit/4c77a5d90acf627574eff571a92a6703c6ea2d13))
## [0.12.1](https://github.com/discordjs/discord-api-types/compare/0.12.0...0.12.1) (2021-01-05)
### Bug Fixes
- run deno workflow only on branch push ([#66](https://github.com/discordjs/discord-api-types/issues/66)) ([0ef4620](https://github.com/discordjs/discord-api-types/commit/0ef46202f6c8c257e6300e634b675e7e1b6ffa90))
### Features
- add Snowflake and Permissions types ([#69](https://github.com/discordjs/discord-api-types/issues/69)) ([549a6f0](https://github.com/discordjs/discord-api-types/commit/549a6f023698f05829f1dfdf1190c027a994d6cd))
# [0.12.0](https://github.com/discordjs/discord-api-types/compare/0.11.2...0.12.0) (2021-01-01)
### Bug Fixes
- **APIApplication:** flags should be omitted in REST, not optional everywhere ([#57](https://github.com/discordjs/discord-api-types/issues/57)) ([664ad80](https://github.com/discordjs/discord-api-types/commit/664ad800ccdfb84cc1547dd151c0f6e16157e04b))
- **RESTPatchAPIChannelJSONBody:** add missing bitrate field ([#60](https://github.com/discordjs/discord-api-types/issues/60)) ([15892ec](https://github.com/discordjs/discord-api-types/commit/15892ec870ff818d7f66bd9b57969638e5f17e1f))
### Features
- **GatewayActivity:** add missing fields ([#39](https://github.com/discordjs/discord-api-types/issues/39)) ([dccdfe0](https://github.com/discordjs/discord-api-types/commit/dccdfe044fb4c02b6cfc910e2d39e469ebd9c75a))
## [0.11.2](https://github.com/discordjs/discord-api-types/compare/0.11.1...0.11.2) (2020-12-20)
## [0.11.1](https://github.com/discordjs/discord-api-types/compare/0.11.0...0.11.1) (2020-12-19)
### Bug Fixes
- **APIAuditLogEntry:** user_id is not nullable ([#52](https://github.com/discordjs/discord-api-types/issues/52)) ([2b89beb](https://github.com/discordjs/discord-api-types/commit/2b89beb52b66a4865124b75069ca6bc3d5886c48))
- **RESTPostAPIGuildsJSONBody:** system_channel_flags is optional ([#53](https://github.com/discordjs/discord-api-types/issues/53)) ([ba4c0d7](https://github.com/discordjs/discord-api-types/commit/ba4c0d78f4ba3755f524b5f63420a36580a1a08e))
# [0.11.0](https://github.com/discordjs/discord-api-types/compare/0.10.0...0.11.0) (2020-12-19)
### Bug Fixes
- **APIGuildMember:** drop nullability of `pending` prop ([#49](https://github.com/discordjs/discord-api-types/issues/49)) ([c2f0dee](https://github.com/discordjs/discord-api-types/commit/c2f0deeebd28fa3a09f795d1b263ff8fd5d9ae4d))
- **RESTPatchAPIGuildJSONBody:** multiple properties are actually nullable ([#48](https://github.com/discordjs/discord-api-types/issues/48)) ([018fc4f](https://github.com/discordjs/discord-api-types/commit/018fc4f8ea4d50f719820001822778079a055fa3))
# [0.10.0](https://github.com/discordjs/discord-api-types/compare/0.9.1...0.10.0) (2020-12-09)
### Features
- server templates ([#25](https://github.com/discordjs/discord-api-types/issues/25)) ([7d873f7](https://github.com/discordjs/discord-api-types/commit/7d873f73c7a8c64630c57d3eaf33d8c4913ed835))
## [0.9.1](https://github.com/discordjs/discord-api-types/compare/0.9.0...0.9.1) (2020-11-22)
# [0.9.0](https://github.com/discordjs/discord-api-types/compare/0.8.0...0.9.0) (2020-11-22)
### Features
- **Message:** reply updates ([#34](https://github.com/discordjs/discord-api-types/issues/34)) ([21b9ae4](https://github.com/discordjs/discord-api-types/commit/21b9ae4aaf29c276d1a6ccc4c79ace8d64a53e9d))
- **Message:** Stickers ([#32](https://github.com/discordjs/discord-api-types/issues/32)) ([39ea1f4](https://github.com/discordjs/discord-api-types/commit/39ea1f4429e5194576200635f885ab102763060b))
# [0.8.0](https://github.com/discordjs/discord-api-types/compare/0.7.0...0.8.0) (2020-11-03)
### Bug Fixes
- webhookPlatform route ([#36](https://github.com/discordjs/discord-api-types/issues/36)) ([666a0c7](https://github.com/discordjs/discord-api-types/commit/666a0c71528e385677570b5359ba266276202a95))
- **GatewayPresence:** correct type for sent activity objects ([#30](https://github.com/discordjs/discord-api-types/issues/30)) ([61db1ee](https://github.com/discordjs/discord-api-types/commit/61db1eee256037588ef27533c234cb01f1f699a4))
# [0.7.0](https://github.com/discordjs/discord-api-types/compare/0.6.0...0.7.0) (2020-10-18)
### Bug Fixes
- **GatewayHeartbeat:** d is nullable ([#26](https://github.com/discordjs/discord-api-types/issues/26)) ([0982610](https://github.com/discordjs/discord-api-types/commit/098261073163eeb4fcfc217dea3511ccea1f27c5))
- **GatewayIdentify:** use correct presence interface ([#28](https://github.com/discordjs/discord-api-types/issues/28)) ([91c63f0](https://github.com/discordjs/discord-api-types/commit/91c63f05ca1e8e92c4c1df124365405fe8d34108))
### Features
- **APIGuildWidgetMember:** add activity and use proper status type ([#24](https://github.com/discordjs/discord-api-types/issues/24)) ([f058ed6](https://github.com/discordjs/discord-api-types/commit/f058ed6aa1f7593c22e4a3f0c9dd2f4bbd0190dc))
# [0.6.0](https://github.com/discordjs/discord-api-types/compare/0.5.0...0.6.0) (2020-10-04)
### Bug Fixes
- **APIChannel:** position is optional ([#21](https://github.com/discordjs/discord-api-types/issues/21)) ([061a147](https://github.com/discordjs/discord-api-types/commit/061a147fbb381738b28ca3fb73fa1a7be0e1b108))
- **RESTPostAPIGuildsJSONBody:** use correct types ([#22](https://github.com/discordjs/discord-api-types/issues/22)) ([dcf8ddf](https://github.com/discordjs/discord-api-types/commit/dcf8ddf25b26a9c72dbb1b5712503e6d5e516ad1))
### Features
- v8 support ([#14](https://github.com/discordjs/discord-api-types/issues/14)) ([11b95c8](https://github.com/discordjs/discord-api-types/commit/11b95c86099e609128a8ca76d06d43498fae72f5))
# [0.5.0](https://github.com/discordjs/discord-api-types/compare/0.4.1...0.5.0) (2020-09-19)
### Bug Fixes
- correct typos ([#18](https://github.com/discordjs/discord-api-types/issues/18)) ([97c7b4e](https://github.com/discordjs/discord-api-types/commit/97c7b4ea24852f49b5f952e81a0e6f21ed405316))
- **APIUser:** premium_type is optional ([#19](https://github.com/discordjs/discord-api-types/issues/19)) ([8cf1ba3](https://github.com/discordjs/discord-api-types/commit/8cf1ba3f4f3c28f962afad4bfcc02f5bb897286a))
- **GatewayIdentifyProperties:** rename `device` to `$device` ([#17](https://github.com/discordjs/discord-api-types/issues/17)) ([9e5c5b5](https://github.com/discordjs/discord-api-types/commit/9e5c5b5aac30e931255f39790123b4bd3458a16f))
## [0.4.1](https://github.com/discordjs/discord-api-types/compare/0.4.0...0.4.1) (2020-09-18)
### Features
- add oauth2 types ([#16](https://github.com/discordjs/discord-api-types/issues/16)) ([10fdeba](https://github.com/discordjs/discord-api-types/commit/10fdeba1286e385e087d6c9405872f948507f183))
# [0.4.0](https://github.com/discordjs/discord-api-types/compare/0.3.0...0.4.0) (2020-09-16)
### Features
- **ActivityType:** add Competing activity type ([#11](https://github.com/discordjs/discord-api-types/issues/11)) ([94d0a16](https://github.com/discordjs/discord-api-types/commit/94d0a1680532412c8d5f9659056f87a37d1def7d))
# [0.3.0](https://github.com/discordjs/discord-api-types/compare/v0.2.0...0.3.0) (2020-09-14)
### Bug Fixes
- **APIMessage:** Correct APIMessage#mentions type ([#9](https://github.com/discordjs/discord-api-types/issues/9)) ([fe1868b](https://github.com/discordjs/discord-api-types/commit/fe1868b04f8a9f4be1c09ffba0afa60f4def8595))
# [0.2.0](https://github.com/discordjs/discord-api-types/compare/v0.1.1...v0.2.0) (2020-09-10)
### Bug Fixes
- **Readme:** add missing semicolon ([#1](https://github.com/discordjs/discord-api-types/issues/1)) ([5e3e101](https://github.com/discordjs/discord-api-types/commit/5e3e1016b5fe274d33503d36771fc276fd384ccf))
## [0.1.1](https://github.com/discordjs/discord-api-types/compare/767a833a12a8268b9f1b780f338da6f28cefa5cd...v0.1.1) (2020-08-22)
### Bug Fixes
- set target version to ES2020 ([767a833](https://github.com/discordjs/discord-api-types/commit/767a833a12a8268b9f1b780f338da6f28cefa5cd))

View File

@@ -1,9 +1,11 @@
<div style="text-align:center;"><h1>Discord API Types</h1></div>
# Discord API Types
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro).
@@ -17,34 +19,53 @@ yarn add discord-api-types
pnpm add discord-api-types
```
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where the `*` represents the API version. Below are some examples
```js
const { APIUser } = require('discord-api-types/v8');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
```
You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`, `gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and `voice/v*`. Below are some examples
```js
const { GatewayVersion } = require('discord-api-types/gateway/v8');
```
```ts
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v8';
```
> _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
### Deno
We also provide typings compatible with the [deno](https://deno.land/) runtime. You have 3 ways you can import them:
1. Directly from GitHub
```ts
// Importing the default API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing the default API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v8.ts';
```
3. From [skypack.dev](https://www.skypack.dev/)
```ts
// Importing the default API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types?dts';
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?dts';
```
@@ -71,32 +92,6 @@ The exports of each API version is split into three main parts:
- Anything else that is miscellaneous will be exported based on what it represents (for example the `REST` route object).
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `common` directory. They will still be prefixed accordingly as described above.
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above.
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will NOT be included.
## Usage
You can `require` / `import` the module directly, which will give you the latest types as of the current API version. This is considered the `default` version and will be updated according to Discord's default API version; this means it may break at any point in time.
> We **strongly recommend** you use a version when importing this module! This will prevent breaking changes when updating the module.
```js
const { APIUser } = require('discord-api-types');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types';
```
You should instead consider adding the API version you want to target by appending `/v*`, where the `*` represents the API version.
```js
const { APIUser } = require('discord-api-types/v8');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
```
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will **NOT** be included.

View File

@@ -1,4 +0,0 @@
// This file exports all the types available in the default API version
// Thereby, things MAY break in the future
export * from '../v8/index';

357
deno/CHANGELOG.md Normal file
View File

@@ -0,0 +1,357 @@
# [0.18.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.18.0) (2021-04-18)
### Bug Fixes
- **APIInvite:** `channel` is not optional ([#123](https://github.com/discordjs/discord-api-types/issues/123)) ([abe0513](https://github.com/discordjs/discord-api-types/commit/abe05136fd169f483fe09a213259b4cbd526497b))
### Code Refactoring
- **Invite:** rename `InviteTargetUserType` to `InviteTargetType` ([#124](https://github.com/discordjs/discord-api-types/issues/124)) ([bc9ab45](https://github.com/discordjs/discord-api-types/commit/bc9ab4556ca8a7c8e4c7942c87fa322c91b733dc))
### BREAKING CHANGES
- **Invite:** `InviteTargetUserType` is renamed to `InviteTargetType`, to match the documentation.
- Reference: https://github.com/discord/discord-api-docs/pull/2690
# [0.17.0](https://github.com/discordjs/discord-api-types/compare/0.16.0...0.17.0) (2021-04-17)
### Bug Fixes
- **APIChannel:** `rtc_region` is optional ([#118](https://github.com/discordjs/discord-api-types/issues/118)) ([617f507](https://github.com/discordjs/discord-api-types/commit/617f507427fae6456de228a23809ab04c1df13f6))
### Code Refactoring
- **APISticker:** remove `preview_asset` ([#119](https://github.com/discordjs/discord-api-types/issues/119)) ([9817623](https://github.com/discordjs/discord-api-types/commit/9817623291ec852a831c3de225e90a65d83dac7f))
### Features
- **WebhookMessage:** add `GET` route types ([#120](https://github.com/discordjs/discord-api-types/issues/120)) ([3294fb1](https://github.com/discordjs/discord-api-types/commit/3294fb15ae6c259c1b53b7f2eca4ea8dca2f2372))
### BREAKING CHANGES
- **APISticker:** This removes the `preview_asset` property from sticket objects
- Reference: https://github.com/discord/discord-api-docs/commit/b9b8db2
- **APIChannel:** This corrects the fact that `rtc_region` isn't present on non-voice-like channels
# [0.16.0](https://github.com/discordjs/discord-api-types/compare/0.15.1...0.16.0) (2021-04-14)
### Features
- **Guild:** add `nsfw` property ([#116](https://github.com/discordjs/discord-api-types/issues/116)) ([21b572b](https://github.com/discordjs/discord-api-types/commit/21b572b7f25a320e40f8ca2e63d6bd8b111403aa))
- **RESTJSONErrorCode:** add `UnknownInteraction` error code ([#115](https://github.com/discordjs/discord-api-types/issues/115)) ([ced37d0](https://github.com/discordjs/discord-api-types/commit/ced37d0a5ebdc80887662529922c57e2531e1e5b))
### docs
- **Routes:** add `GET` routes to `webhookMessages` ([#114](https://github.com/discordjs/discord-api-types/issues/114)) ([6451679](https://github.com/discordjs/discord-api-types/commit/6451679c9acb9d7fde593914452577669473841d))
### BREAKING CHANGES
- **Routes:** possibly a breaking change due to the fact that the messageID is now strictly typed as a Snowflake or `@me`
- Reference: discord/discord-api-docs#2410
## [0.15.1](https://github.com/discordjs/discord-api-types/compare/0.15.0...0.15.1) (2021-04-12)
### Bug Fixes
- **TypeScript:** imports not working in TypeScript ([4738c33](https://github.com/discordjs/discord-api-types/commit/4738c33b062d359a1c2fbb35cdd2daf128ab6e5b))
# [0.15.0](https://github.com/discordjs/discord-api-types/compare/0.14.0...0.15.0) (2021-04-11)
### Bug Fixes
- **APIApplicationCommand:** default_permission ([#111](https://github.com/discordjs/discord-api-types/issues/111)) ([9420c3e](https://github.com/discordjs/discord-api-types/commit/9420c3e0af7b2486f0e49bb680ed98e0d9f5c625))
- **Scripts:** `await` in `versions` script, log any errors from deno one ([9113eb1](https://github.com/discordjs/discord-api-types/commit/9113eb133c4627445e2bcd4583c243dde74a20ee))
### BREAKING CHANGES
- **APIApplicationCommand:** This renames the `default_permissions` property to `default_permission`, the correct spelling.
# [0.14.0](https://github.com/discordjs/discord-api-types/compare/0.13.3...0.14.0) (2021-04-11)
### Bug Fixes
- **APIMessage:** correct type for `application` ([ed2cbe8](https://github.com/discordjs/discord-api-types/commit/ed2cbe82c56f872ee01a9eb6991ef70dc22d8c1f))
- **GatewayGuildMemberUpdateDispatchData:** correct types ([14f14e2](https://github.com/discordjs/discord-api-types/commit/14f14e227955af41ed2823f11c6e8d03d12549ba))
- **GatewayPresenceUpdateData:** `activities` may not be `null` ([bb3cb04](https://github.com/discordjs/discord-api-types/commit/bb3cb04e016840f66eecbe39c2e07aea8ea12bc8))
- **GatewayVoiceServerUpdateDispatchData:** `endpoint` is nullable ([e8203a1](https://github.com/discordjs/discord-api-types/commit/e8203a1112a834ce9aaae4ab95f711d3aaffc20f))
- **GuildWelcomeScreenChannel:** document missing `description` property ([238695b](https://github.com/discordjs/discord-api-types/commit/238695b44d8547d51782e3d9d9729e2db85bc444))
- **OAuth2:** `scope` can be optional / not required ([bbe56a9](https://github.com/discordjs/discord-api-types/commit/bbe56a97564ce8c317f291080327484f0d987e1c))
- **OAuth2:** remove invalid parameters from refresh token request ([1c02450](https://github.com/discordjs/discord-api-types/commit/1c024507f3f55b922565845c2bedac615ffa24d5))
- **RPC:** version `RPC` same as` rest`, export again in `shortcuts` ([67e0ba1](https://github.com/discordjs/discord-api-types/commit/67e0ba1834e6d9de9ad00bd452f5e8da59ff1cc6))
- **Utils:** correct import for deno users ([42dd75f](https://github.com/discordjs/discord-api-types/commit/42dd75f2581b2a8862e4f0446b42ff838f923de0))
### chore
- **Gateway:** remove `guild_subscriptions` ([ab8b289](https://github.com/discordjs/discord-api-types/commit/ab8b289ac8f99fe1a998ef06320ad9046aafa1d2))
- **GatewayReady:** un-document `private_channels` ([457edf4](https://github.com/discordjs/discord-api-types/commit/457edf4ed43327fb871d3b1638745b905518ef91))
- **Integrations:** remove routes that bots can no longer interact with ([577c5bd](https://github.com/discordjs/discord-api-types/commit/577c5bd040dd1dc258ca6c414cf6ac69ae84916c))
- **MessageGetReactions:** remove `before` pagination ([0ec26b7](https://github.com/discordjs/discord-api-types/commit/0ec26b731cda570f34e59e05a8c21f272b1fd64e))
- **Oauth2Scopes:** remove `rpc.api` ([7ee8511](https://github.com/discordjs/discord-api-types/commit/7ee85113ea8107106460889a2eaa42b251ee05d0))
- **Permissions:** rename `USE_APPLICATION_COMMANDS` to `USE_SLASH_COMMANDS` ([2aa7f7a](https://github.com/discordjs/discord-api-types/commit/2aa7f7a7b8da3d4d46a7743830562d996d32120b))
- **UserFlags:** un-document `SYSTEM` flag ([1774d4c](https://github.com/discordjs/discord-api-types/commit/1774d4c4749d303f24bfb3c754cf79a4ca7ef699))
### Code Refactoring
- restructure module ([81cdfc2](https://github.com/discordjs/discord-api-types/commit/81cdfc2d9c523d98edd0a69f976879e848e1167b))
### Features
- **APIApplication:** document `terms_of_service` and `privacy_policy` ([598cbfb](https://github.com/discordjs/discord-api-types/commit/598cbfb958a67d5ba61696ba877ea0bae4c4be55))
- **APIAttachment:** add `content_type` ([2d432d1](https://github.com/discordjs/discord-api-types/commit/2d432d145eb8a009b092b27b6231252d7b2f2823))
- **APIChannel:** add `rtc_region` ([#108](https://github.com/discordjs/discord-api-types/issues/108)) ([07ba907](https://github.com/discordjs/discord-api-types/commit/07ba9072429dec85a13479dc211ec1f9d8788acf))
- **APIChannel:** add `video_quality_mode` ([#106](https://github.com/discordjs/discord-api-types/issues/106)) ([d8d7bcc](https://github.com/discordjs/discord-api-types/commit/d8d7bccea617ad0d1150b9d2aed3b26ec1e4f99a))
- **APIInteraction:** add type-check utilities ([3307201](https://github.com/discordjs/discord-api-types/commit/33072011c2ea9ace8350dedc0cd1068660dc2ece))
- **Exports:** add `globals` to the exported sub-modules ([5d35f61](https://github.com/discordjs/discord-api-types/commit/5d35f61334480af983c4767373ef05e395da2e18))
- **Gateway:** add `INTEGRATION_*` events ([9c3fab0](https://github.com/discordjs/discord-api-types/commit/9c3fab052619609eb543ff400c2b813b69c6b99f))
- **GuildWelcomeScreen:** document `welcome-screen` endpoint ([169ecde](https://github.com/discordjs/discord-api-types/commit/169ecde47a6a911309630e952ab26b805ac87cf0))
- **Interactions:** add batch command create / update ([edfe70a](https://github.com/discordjs/discord-api-types/commit/edfe70a1eeec9be1104ec68a20d95e83512b3268))
- **Interactions:** add Slash Command Permissions ([f517f35](https://github.com/discordjs/discord-api-types/commit/f517f3596f458a2c2e4c4a26d5c13bbed4c4a71f))
- **Invites:** document `target_application` & correct property names ([97c8ab3](https://github.com/discordjs/discord-api-types/commit/97c8ab3f5165c6f161e9338e944cff8b296756d5))
- **MessageFlags:** `EPHEMERAL` desc and added `LOADING` ([#109](https://github.com/discordjs/discord-api-types/issues/109)) ([4462255](https://github.com/discordjs/discord-api-types/commit/4462255168af2ad66c9c7405500e80d3fa41de33))
- **PatchAPIWebhookMessage:** add `file` property ([fc2f3c5](https://github.com/discordjs/discord-api-types/commit/fc2f3c58cf5ea2a8c0a1a14a62a16f432b1776e2))
- **Webhook:** add & document `url` property ([77e5bb6](https://github.com/discordjs/discord-api-types/commit/77e5bb624d86e4bc8696c8dac4f513c27eb8aff1))
- invite reminder system message type and flag ([#105](https://github.com/discordjs/discord-api-types/issues/105)) ([b90714f](https://github.com/discordjs/discord-api-types/commit/b90714f677c67c009ddb6d00734ab8998c194350))
- stage channels! ([#107](https://github.com/discordjs/discord-api-types/issues/107)) ([6cd7542](https://github.com/discordjs/discord-api-types/commit/6cd75426c6d7da145b40a656e4c1a1d3d26bfb1f))
### BREAKING CHANGES
- **APIInteraction:** This commit removes the `guild_id` property from `APIDMInteraction`
which allows type-checks to work with the `in` operator.
Because of that, we also provide utility functions that help with those type checks.
Use them in your code by importing the `Utils` object, or by directly importing them.
Check the README for examples
- **OAuth2:** This commit removes parameters that are not expected
in the refresh token request body
Reference: https://github.com/discord/discord-api-docs/commit/eaa12cbc8f96cf7cfe8c530f88e60582c24ca5dd
- **GatewayReady:** This property has been deprecated for a while, and was
returning an empty array for bot users. This commit removes it entirely
Reference: https://github.com/discord/discord-api-docs/commit/f36156dbb641f5c4d4f4593f345bfd6e27fdee08
- **Permissions:** This commit brings consistency with the documentation,
where the permission is documented as `USE_SLASH_COMMANDS`, whereas the
client has it as `USE_APPLICATION_COMMANDS` internally
Reference: https://github.com/discord/discord-api-docs/commit/c7d25885c5cd80a49b31609a40b70603b35f9dec
- **MessageGetReactions:** This query parameter is not usable and was not respected
by the API.
Reference: https://github.com/discord/discord-api-docs/commit/f72b084773d4d3989fb19be4fb4d9cf276a1e6b3
- **OAuth2:** This removes the `scope` property from the authorization
code flow, as it is not expected there.
Reference: https://github.com/discord/discord-api-docs/commit/57965033ab4216a0bb853e85d6912531cd5a9981
- **Gateway:** This removes `guild_subscriptions`, as it has been
deprecated in favor of `intents`.
Reference: https://github.com/discord/discord-api-docs/commit/8de017436d37e56fab14cb8f68f0448a45ebc731
- **Oauth2Scopes:** This removes the `rpc.api` scope, as it has been removed
from the documentation.
Reference: https://github.com/discord/discord-api-docs/commit/2641d9808f676e7316483d152cdb37ed1168f968
- **APIMessage:** This removes the `APIMessageApplication` interface, as it has
been removed from the documentation, being replaced with the OAuth2 application.
Reference: https://github.com/discord/discord-api-docs/commit/ff0c831e424f1bc17dd3cde62da48d5c3d933e88
- **APIApplication:** This renames the `GatewayPresenceLimit` flag to
`GatewayPresenceLimited`, for consistency with `GatewayGuildMembersLimited`
and the documented name.
Reference: https://github.com/discord/discord-api-docs/commit/39b254bed1cc396c475e508a3f2bf328815605c9
- **GatewayVoiceServerUpdateDispatchData:** Any code that expects `endpoint` to never be null needs
to be updated, and the conditions specified in the documentation need
to be respected regarding that.
Reference: https://github.com/discord/discord-api-docs/commit/e887382fafd4c4417f7ba62963984f25bcb643f6
- **Invites:** This renames `target_user_type` to `target_type`,
the actual value the API expects.
Reference: https://github.com/discord/discord-api-docs/commit/1b4e363e324eb1f49a47e32cb0108fbe276c8e0e
- **GatewayPresenceUpdateData:** Clearing `activities` is done by setting them to an empty
array, not by setting them to `null`.
Reference: https://github.com/discord/discord-api-docs/commit/5bf598b864fb89262fce07137f68ce6e7e583432
- **UserFlags:** This removes a flag that bots should not use, as Discord
said this is an internal flag.
Reference: https://github.com/discord/discord-api-docs/commit/9293f0d490ac6acf9d627e429e5a8131b303b528
- **Integrations:** This removes the 3 routes that bots can no longer access.
Reference: https://github.com/discord/discord-api-docs/commit/efe4e5808b6826d40302e265a5ae9b5b65d92fe7
- **Exports:** Certain objects from this file have been moved to their
appropriate spot (such as JSON Error Codes)
- Files have been moved around in order to keep them
organized. Exports might also be missing, so please report if that is the
case.
## [0.13.3](https://github.com/discordjs/discord-api-types/compare/0.13.2...0.13.3) (2021-03-28)
## [0.13.2](https://github.com/discordjs/discord-api-types/compare/0.13.1...0.13.2) (2021-03-28)
### Bug Fixes
- **ApplicationCommandInteractionDataOptionSubCommandGroup:** typo ([#102](https://github.com/discordjs/discord-api-types/issues/102)) ([15c171c](https://github.com/discordjs/discord-api-types/commit/15c171c558a10cd6d1c4880e725af0e63dd82255))
## [0.13.1](https://github.com/discordjs/discord-api-types/compare/0.13.0...0.13.1) (2021-03-27)
### Bug Fixes
- **APIInteractionResponse:** `data` should not always be present ([#100](https://github.com/discordjs/discord-api-types/issues/100)) ([ffcd95d](https://github.com/discordjs/discord-api-types/commit/ffcd95d597a5d1c5b3ea072cd1dfb44f079de4b7))
# [0.13.0](https://github.com/discordjs/discord-api-types/compare/0.12.1...0.13.0) (2021-03-27)
### Bug Fixes
- **deno:** replace `const enum` exports in deno with normal `enum`s ([#89](https://github.com/discordjs/discord-api-types/issues/89)) ([7343fab](https://github.com/discordjs/discord-api-types/commit/7343fabe82e4321808bac784aed600afa8cf4249))
- **RESTPostAPIChannelMessageJSONBody:** mark `tts` as a full boolean ([#96](https://github.com/discordjs/discord-api-types/issues/96)) ([9d8d090](https://github.com/discordjs/discord-api-types/commit/9d8d090c9c6cd5be1f7b578b2f6a6387544f3359))
- **RESTPostAPIGuildsJSONBody:** make some fields nullable ([#91](https://github.com/discordjs/discord-api-types/issues/91)) ([ae1900d](https://github.com/discordjs/discord-api-types/commit/ae1900dc2f65065153b1bf2437348e63b63db49e))
### Features
- **APIApplication:** add ApplicationFlags ([#92](https://github.com/discordjs/discord-api-types/issues/92)) ([92f76f1](https://github.com/discordjs/discord-api-types/commit/92f76f1a3c8acf80689b994e9bfaec70d198aaa1))
- **APIApplicationCommandInteractionData:** add `resolved` ([#86](https://github.com/discordjs/discord-api-types/issues/86)) ([24155ae](https://github.com/discordjs/discord-api-types/commit/24155aeb71d46de48353ce01bfb48e197a84e59b))
- **APIBaseInteraction:** add application_id ([#98](https://github.com/discordjs/discord-api-types/issues/98)) ([0582f88](https://github.com/discordjs/discord-api-types/commit/0582f883c517e5fdc2373ac0a85717a7bfeec018))
- **APIInteraction:** DM slash commands and property descriptions ([#84](https://github.com/discordjs/discord-api-types/issues/84)) ([d0b3106](https://github.com/discordjs/discord-api-types/commit/d0b310675848f4724e47c490b06d828f7ede204c))
- **APIInteractionResponse, APIInteractionResponseType:** update for UI changes ([#90](https://github.com/discordjs/discord-api-types/issues/90)) ([eafe7ba](https://github.com/discordjs/discord-api-types/commit/eafe7ba96fc6e771579850a8a7de36adade8efdc))
- **APIMessage:** add `interaction` ([#93](https://github.com/discordjs/discord-api-types/issues/93)) ([0f29b32](https://github.com/discordjs/discord-api-types/commit/0f29b32e05abe89f70f72989024b9c63493782fa))
- **APIMessageReferenceSend:** add `fail_if_not_exists` ([#82](https://github.com/discordjs/discord-api-types/issues/82)) ([855f36d](https://github.com/discordjs/discord-api-types/commit/855f36d9309ae69f57da723648d3791e3134089e))
- **PermissionFlagsBits:** add `USE_APPLICATION_COMMANDS` ([#85](https://github.com/discordjs/discord-api-types/issues/85)) ([ceb787b](https://github.com/discordjs/discord-api-types/commit/ceb787ba36ed05f25f9acab86496d3054cb15013))
- **rest:** api base routes ([#87](https://github.com/discordjs/discord-api-types/issues/87)) ([466fa95](https://github.com/discordjs/discord-api-types/commit/466fa95b0e239b7984275959886b995a5020640a))
- add Application Command events ([#75](https://github.com/discordjs/discord-api-types/issues/75)) ([da2c2e9](https://github.com/discordjs/discord-api-types/commit/da2c2e9ada39482fce095c47339b40d6c24e683a))
- add GET single Application Command ([#76](https://github.com/discordjs/discord-api-types/issues/76)) ([5826da2](https://github.com/discordjs/discord-api-types/commit/5826da22e30839b1f9fcd73479f8bc0f213001bd))
- implement FormatPatterns ([#79](https://github.com/discordjs/discord-api-types/issues/79)) ([4e4a084](https://github.com/discordjs/discord-api-types/commit/4e4a0840036eddb89a1d49d69f59905dba206afb))
- **OAuth2:** add `/oauth2/[@me](https://github.com/me)` route ([#73](https://github.com/discordjs/discord-api-types/issues/73)) ([84759d1](https://github.com/discordjs/discord-api-types/commit/84759d19bc4cd0f33f0a94608c1af2b4d6a820c6))
- **Webhook:** add Edit Webhook Message result and error 50027 ([#71](https://github.com/discordjs/discord-api-types/issues/71)) ([4c77a5d](https://github.com/discordjs/discord-api-types/commit/4c77a5d90acf627574eff571a92a6703c6ea2d13))
## [0.12.1](https://github.com/discordjs/discord-api-types/compare/0.12.0...0.12.1) (2021-01-05)
### Bug Fixes
- run deno workflow only on branch push ([#66](https://github.com/discordjs/discord-api-types/issues/66)) ([0ef4620](https://github.com/discordjs/discord-api-types/commit/0ef46202f6c8c257e6300e634b675e7e1b6ffa90))
### Features
- add Snowflake and Permissions types ([#69](https://github.com/discordjs/discord-api-types/issues/69)) ([549a6f0](https://github.com/discordjs/discord-api-types/commit/549a6f023698f05829f1dfdf1190c027a994d6cd))
# [0.12.0](https://github.com/discordjs/discord-api-types/compare/0.11.2...0.12.0) (2021-01-01)
### Bug Fixes
- **APIApplication:** flags should be omitted in REST, not optional everywhere ([#57](https://github.com/discordjs/discord-api-types/issues/57)) ([664ad80](https://github.com/discordjs/discord-api-types/commit/664ad800ccdfb84cc1547dd151c0f6e16157e04b))
- **RESTPatchAPIChannelJSONBody:** add missing bitrate field ([#60](https://github.com/discordjs/discord-api-types/issues/60)) ([15892ec](https://github.com/discordjs/discord-api-types/commit/15892ec870ff818d7f66bd9b57969638e5f17e1f))
### Features
- **GatewayActivity:** add missing fields ([#39](https://github.com/discordjs/discord-api-types/issues/39)) ([dccdfe0](https://github.com/discordjs/discord-api-types/commit/dccdfe044fb4c02b6cfc910e2d39e469ebd9c75a))
## [0.11.2](https://github.com/discordjs/discord-api-types/compare/0.11.1...0.11.2) (2020-12-20)
## [0.11.1](https://github.com/discordjs/discord-api-types/compare/0.11.0...0.11.1) (2020-12-19)
### Bug Fixes
- **APIAuditLogEntry:** user_id is not nullable ([#52](https://github.com/discordjs/discord-api-types/issues/52)) ([2b89beb](https://github.com/discordjs/discord-api-types/commit/2b89beb52b66a4865124b75069ca6bc3d5886c48))
- **RESTPostAPIGuildsJSONBody:** system_channel_flags is optional ([#53](https://github.com/discordjs/discord-api-types/issues/53)) ([ba4c0d7](https://github.com/discordjs/discord-api-types/commit/ba4c0d78f4ba3755f524b5f63420a36580a1a08e))
# [0.11.0](https://github.com/discordjs/discord-api-types/compare/0.10.0...0.11.0) (2020-12-19)
### Bug Fixes
- **APIGuildMember:** drop nullability of `pending` prop ([#49](https://github.com/discordjs/discord-api-types/issues/49)) ([c2f0dee](https://github.com/discordjs/discord-api-types/commit/c2f0deeebd28fa3a09f795d1b263ff8fd5d9ae4d))
- **RESTPatchAPIGuildJSONBody:** multiple properties are actually nullable ([#48](https://github.com/discordjs/discord-api-types/issues/48)) ([018fc4f](https://github.com/discordjs/discord-api-types/commit/018fc4f8ea4d50f719820001822778079a055fa3))
# [0.10.0](https://github.com/discordjs/discord-api-types/compare/0.9.1...0.10.0) (2020-12-09)
### Features
- server templates ([#25](https://github.com/discordjs/discord-api-types/issues/25)) ([7d873f7](https://github.com/discordjs/discord-api-types/commit/7d873f73c7a8c64630c57d3eaf33d8c4913ed835))
## [0.9.1](https://github.com/discordjs/discord-api-types/compare/0.9.0...0.9.1) (2020-11-22)
# [0.9.0](https://github.com/discordjs/discord-api-types/compare/0.8.0...0.9.0) (2020-11-22)
### Features
- **Message:** reply updates ([#34](https://github.com/discordjs/discord-api-types/issues/34)) ([21b9ae4](https://github.com/discordjs/discord-api-types/commit/21b9ae4aaf29c276d1a6ccc4c79ace8d64a53e9d))
- **Message:** Stickers ([#32](https://github.com/discordjs/discord-api-types/issues/32)) ([39ea1f4](https://github.com/discordjs/discord-api-types/commit/39ea1f4429e5194576200635f885ab102763060b))
# [0.8.0](https://github.com/discordjs/discord-api-types/compare/0.7.0...0.8.0) (2020-11-03)
### Bug Fixes
- webhookPlatform route ([#36](https://github.com/discordjs/discord-api-types/issues/36)) ([666a0c7](https://github.com/discordjs/discord-api-types/commit/666a0c71528e385677570b5359ba266276202a95))
- **GatewayPresence:** correct type for sent activity objects ([#30](https://github.com/discordjs/discord-api-types/issues/30)) ([61db1ee](https://github.com/discordjs/discord-api-types/commit/61db1eee256037588ef27533c234cb01f1f699a4))
# [0.7.0](https://github.com/discordjs/discord-api-types/compare/0.6.0...0.7.0) (2020-10-18)
### Bug Fixes
- **GatewayHeartbeat:** d is nullable ([#26](https://github.com/discordjs/discord-api-types/issues/26)) ([0982610](https://github.com/discordjs/discord-api-types/commit/098261073163eeb4fcfc217dea3511ccea1f27c5))
- **GatewayIdentify:** use correct presence interface ([#28](https://github.com/discordjs/discord-api-types/issues/28)) ([91c63f0](https://github.com/discordjs/discord-api-types/commit/91c63f05ca1e8e92c4c1df124365405fe8d34108))
### Features
- **APIGuildWidgetMember:** add activity and use proper status type ([#24](https://github.com/discordjs/discord-api-types/issues/24)) ([f058ed6](https://github.com/discordjs/discord-api-types/commit/f058ed6aa1f7593c22e4a3f0c9dd2f4bbd0190dc))
# [0.6.0](https://github.com/discordjs/discord-api-types/compare/0.5.0...0.6.0) (2020-10-04)
### Bug Fixes
- **APIChannel:** position is optional ([#21](https://github.com/discordjs/discord-api-types/issues/21)) ([061a147](https://github.com/discordjs/discord-api-types/commit/061a147fbb381738b28ca3fb73fa1a7be0e1b108))
- **RESTPostAPIGuildsJSONBody:** use correct types ([#22](https://github.com/discordjs/discord-api-types/issues/22)) ([dcf8ddf](https://github.com/discordjs/discord-api-types/commit/dcf8ddf25b26a9c72dbb1b5712503e6d5e516ad1))
### Features
- v8 support ([#14](https://github.com/discordjs/discord-api-types/issues/14)) ([11b95c8](https://github.com/discordjs/discord-api-types/commit/11b95c86099e609128a8ca76d06d43498fae72f5))
# [0.5.0](https://github.com/discordjs/discord-api-types/compare/0.4.1...0.5.0) (2020-09-19)
### Bug Fixes
- correct typos ([#18](https://github.com/discordjs/discord-api-types/issues/18)) ([97c7b4e](https://github.com/discordjs/discord-api-types/commit/97c7b4ea24852f49b5f952e81a0e6f21ed405316))
- **APIUser:** premium_type is optional ([#19](https://github.com/discordjs/discord-api-types/issues/19)) ([8cf1ba3](https://github.com/discordjs/discord-api-types/commit/8cf1ba3f4f3c28f962afad4bfcc02f5bb897286a))
- **GatewayIdentifyProperties:** rename `device` to `$device` ([#17](https://github.com/discordjs/discord-api-types/issues/17)) ([9e5c5b5](https://github.com/discordjs/discord-api-types/commit/9e5c5b5aac30e931255f39790123b4bd3458a16f))
## [0.4.1](https://github.com/discordjs/discord-api-types/compare/0.4.0...0.4.1) (2020-09-18)
### Features
- add oauth2 types ([#16](https://github.com/discordjs/discord-api-types/issues/16)) ([10fdeba](https://github.com/discordjs/discord-api-types/commit/10fdeba1286e385e087d6c9405872f948507f183))
# [0.4.0](https://github.com/discordjs/discord-api-types/compare/0.3.0...0.4.0) (2020-09-16)
### Features
- **ActivityType:** add Competing activity type ([#11](https://github.com/discordjs/discord-api-types/issues/11)) ([94d0a16](https://github.com/discordjs/discord-api-types/commit/94d0a1680532412c8d5f9659056f87a37d1def7d))
# [0.3.0](https://github.com/discordjs/discord-api-types/compare/v0.2.0...0.3.0) (2020-09-14)
### Bug Fixes
- **APIMessage:** Correct APIMessage#mentions type ([#9](https://github.com/discordjs/discord-api-types/issues/9)) ([fe1868b](https://github.com/discordjs/discord-api-types/commit/fe1868b04f8a9f4be1c09ffba0afa60f4def8595))
# [0.2.0](https://github.com/discordjs/discord-api-types/compare/v0.1.1...v0.2.0) (2020-09-10)
### Bug Fixes
- **Readme:** add missing semicolon ([#1](https://github.com/discordjs/discord-api-types/issues/1)) ([5e3e101](https://github.com/discordjs/discord-api-types/commit/5e3e1016b5fe274d33503d36771fc276fd384ccf))
## [0.1.1](https://github.com/discordjs/discord-api-types/compare/767a833a12a8268b9f1b780f338da6f28cefa5cd...v0.1.1) (2020-08-22)
### Bug Fixes
- set target version to ES2020 ([767a833](https://github.com/discordjs/discord-api-types/commit/767a833a12a8268b9f1b780f338da6f28cefa5cd))

View File

@@ -1,9 +1,11 @@
<div style="text-align:center;"><h1>Discord API Types</h1></div>
# Discord API Types
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro).
@@ -17,34 +19,53 @@ yarn add discord-api-types
pnpm add discord-api-types
```
### Usage
You can only import this module by specifying the API version you want to target. Append `/v*` to the import path, where the `*` represents the API version. Below are some examples
```js
const { APIUser } = require('discord-api-types/v8');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
```
You may also import just certain parts of the module that you need. The possible values are: `globals`, `gateway`, `gateway/v*`, `payloads`, `payloads/v*`, `rest`, `rest/v*`, `rpc`, `rpc/v*`, `utils`, `utils/v*`, `voice`, and `voice/v*`. Below are some examples
```js
const { GatewayVersion } = require('discord-api-types/gateway/v8');
```
```ts
// TypeScript/ES Module support
import { GatewayVersion } from 'discord-api-types/gateway/v8';
```
> _**Note:** The `v*` exports (`discord-api-type/v*`) include the appropriate version of `gateway`, `payloads`, `rest`, `rpc`, and `utils` you specified, alongside the `globals` exports_
### Deno
We also provide typings compatible with the [deno](https://deno.land/) runtime. You have 3 ways you can import them:
1. Directly from GitHub
```ts
// Importing the default API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing the default API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v8.ts';
```
3. From [skypack.dev](https://www.skypack.dev/)
```ts
// Importing the default API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types?dts';
// Importing a specific API version
import { APIUser } from 'https://cdn.skypack.dev/discord-api-types/v8?dts';
```
@@ -71,32 +92,6 @@ The exports of each API version is split into three main parts:
- Anything else that is miscellaneous will be exported based on what it represents (for example the `REST` route object).
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `common` directory. They will still be prefixed accordingly as described above.
- There may be types exported that are identical for all versions. These will be exported as is and can be found in the `globals` file. They will still be prefixed accordingly as described above.
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will NOT be included.
## Usage
You can `require` / `import` the module directly, which will give you the latest types as of the current API version. This is considered the `default` version and will be updated according to Discord's default API version; this means it may break at any point in time.
> We **strongly recommend** you use a version when importing this module! This will prevent breaking changes when updating the module.
```js
const { APIUser } = require('discord-api-types');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types';
```
You should instead consider adding the API version you want to target by appending `/v*`, where the `*` represents the API version.
```js
const { APIUser } = require('discord-api-types/v8');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v8';
```
**Warning**: This package documents just KNOWN (and documented) properties. Anything that isn't documented will NOT be added to this package (unless said properties are in an open Pull Request to Discord's [API Documentation repository](https://github.com/discord/discord-api-docs) or known through other means _and have received the green light to be used_). For clarification's sake, this means that properties that are only known through the process of data mining and have not yet been confirmed in a way as described will **NOT** be included.

8
deno/gateway/common.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params
*/
export interface GatewayURLQuery {
v: string;
encoding: 'json' | 'etf';
compress?: 'zlib-stream';
}

4
deno/gateway/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the types available in the recommended gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';

View File

@@ -16,7 +16,9 @@ import type {
GatewayVoiceState,
InviteTargetUserType,
PresenceUpdateStatus,
} from '../payloads/mod.ts';
} from '../payloads/v6/mod.ts';
export * from './common.ts';
/**
* @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8.

View File

@@ -2,10 +2,15 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../globals.ts';
import type {
APIApplication,
APIApplicationCommand,
APIApplicationCommandInteraction,
APIChannel,
APIEmoji,
APIGuild,
APIGuildIntegration,
APIGuildMember,
APIMessage,
APIRole,
@@ -14,24 +19,25 @@ import type {
GatewayActivity,
GatewayPresenceUpdate as RawGatewayPresenceUpdate,
GatewayVoiceState,
InviteTargetUserType,
InviteTargetType,
PresenceUpdateStatus,
APIApplicationCommandInteraction,
APIApplication,
} from '../payloads/index';
} from '../payloads/v8/mod.ts';
export * from './common.ts';
export const GatewayVersion = '8';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
*/
export const enum GatewayOPCodes {
export enum GatewayOPCodes {
/**
* An event was dispatched
*/
Dispatch,
/**
* Fired periodically by the client to keep the connection alive
* A bidirectional opcode to maintain an active gateway connection.
* Fired periodically by the client, or fired by the gateway to request an immediate heartbeat from the client.
*/
Heartbeat,
/**
@@ -75,7 +81,7 @@ export const enum GatewayOPCodes {
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
*/
export const enum GatewayCloseCodes {
export enum GatewayCloseCodes {
/**
* We're not sure what went wrong. Try reconnecting?
*/
@@ -155,118 +161,10 @@ export const enum GatewayCloseCodes {
DisallowedIntents,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
*/
export const enum VoiceOPCodes {
/**
* Begin a voice websocket connection
*/
Identify,
/**
* Select the voice protocol
*/
SelectProtocol,
/**
* Complete the websocket handshake
*/
Ready,
/**
* Keep the websocket connection alive
*/
Heartbeat,
/**
* Describe the session
*/
SessionDescription,
/**
* Indicate which users are speaking
*/
Speaking,
/**
* Sent to acknowledge a received client heartbeat
*/
HeartbeatAck,
/**
* Resume a connection
*/
Resume,
/**
* Time to wait between sending heartbeats in milliseconds
*/
Hello,
/**
* Acknowledge a successful session resume
*/
Resumed,
/**
* A client has connected to the voice channel
*/
ClientConnect = 12,
/**
* A client has disconnected from the voice channel
*/
ClientDisconnect,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
*/
export const enum VoiceCloseCodes {
/**
* You sent an invalid opcode
*/
UnknownOpCode = 4001,
/**
* You sent a invalid payload in your identifying to the Gateway
*/
FailedToDecode,
/**
* You sent a payload before identifying with the Gateway
*/
NotAuthenticated,
/**
* The token you sent in your identify payload is incorrect
*/
AuthenticationFailed,
/**
* You sent more than one identify payload. Stahp
*/
AlreadyAuthenticated,
/**
* Your session is no longer valid
*/
SessionNoLongerValid,
/**
* Your session has timed out
*/
SessionTimeout = 4009,
/**
* We can't find the server you're trying to connect to
*/
ServerNotFound = 4011,
/**
* We didn't recognize the protocol you sent
*/
UnknownProtocol,
/**
* Either the channel was deleted or you were kicked. Should not reconnect
*/
Disconnected = 4014,
/**
* The server crashed. Our bad! Try resuming
*/
VoiceServerCrashed,
/**
* We didn't recognize your encryption
*/
UnknownEncryptionMode,
}
/**
* https://discord.com/developers/docs/topics/gateway#list-of-intents
*/
export const enum GatewayIntentBits {
export enum GatewayIntentBits {
GUILDS = 1 << 0,
GUILD_MEMBERS = 1 << 1,
GUILD_BANS = 1 << 2,
@@ -287,43 +185,49 @@ export const enum GatewayIntentBits {
/**
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export const enum GatewayDispatchEvents {
Ready = 'READY',
Resumed = 'RESUMED',
export enum GatewayDispatchEvents {
ApplicationCommandCreate = 'APPLICATION_COMMAND_CREATE',
ApplicationCommandDelete = 'APPLICATION_COMMAND_DELETE',
ApplicationCommandUpdate = 'APPLICATION_COMMAND_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelUpdate = 'CHANNEL_UPDATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
GuildCreate = 'GUILD_CREATE',
GuildUpdate = 'GUILD_UPDATE',
GuildDelete = 'GUILD_DELETE',
ChannelUpdate = 'CHANNEL_UPDATE',
GuildBanAdd = 'GUILD_BAN_ADD',
GuildBanRemove = 'GUILD_BAN_REMOVE',
GuildCreate = 'GUILD_CREATE',
GuildDelete = 'GUILD_DELETE',
GuildEmojisUpdate = 'GUILD_EMOJIS_UPDATE',
GuildIntegrationsUpdate = 'GUILD_INTEGRATIONS_UPDATE',
GuildMemberAdd = 'GUILD_MEMBER_ADD',
GuildMemberRemove = 'GUILD_MEMBER_REMOVE',
GuildMemberUpdate = 'GUILD_MEMBER_UPDATE',
GuildMembersChunk = 'GUILD_MEMBERS_CHUNK',
GuildMemberUpdate = 'GUILD_MEMBER_UPDATE',
GuildRoleCreate = 'GUILD_ROLE_CREATE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildRoleDelete = 'GUILD_ROLE_DELETE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildUpdate = 'GUILD_UPDATE',
IntegrationCreate = 'INTEGRATION_CREATE',
IntegrationDelete = 'INTEGRATION_DELETE',
IntegrationUpdate = 'INTEGRATION_UPDATE',
InteractionCreate = 'INTERACTION_CREATE',
InviteCreate = 'INVITE_CREATE',
InviteDelete = 'INVITE_DELETE',
MessageCreate = 'MESSAGE_CREATE',
MessageUpdate = 'MESSAGE_UPDATE',
MessageDelete = 'MESSAGE_DELETE',
MessageDeleteBulk = 'MESSAGE_DELETE_BULK',
MessageReactionAdd = 'MESSAGE_REACTION_ADD',
MessageReactionRemove = 'MESSAGE_REACTION_REMOVE',
MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL',
MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI',
MessageUpdate = 'MESSAGE_UPDATE',
PresenceUpdate = 'PRESENCE_UPDATE',
Ready = 'READY',
Resumed = 'RESUMED',
TypingStart = 'TYPING_START',
UserUpdate = 'USER_UPDATE',
VoiceStateUpdate = 'VOICE_STATE_UPDATE',
VoiceServerUpdate = 'VOICE_SERVER_UPDATE',
VoiceStateUpdate = 'VOICE_STATE_UPDATE',
WebhooksUpdate = 'WEBHOOKS_UPDATE',
}
@@ -344,41 +248,95 @@ export type GatewayReceivePayload =
| GatewayDispatchPayload;
export type GatewayDispatchPayload =
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayChannelModifyDispatch
| GatewayChannelPinsUpdateDispatch
| GatewayGuildModifyDispatch
| GatewayGuildDeleteDispatch
| GatewayGuildBanModifyDispatch
| GatewayGuildDeleteDispatch
| GatewayGuildEmojisUpdateDispatch
| GatewayGuildIntegrationsUpdateDispatch
| GatewayGuildMemberAddDispatch
| GatewayGuildMemberRemoveDispatch
| GatewayGuildMemberUpdateDispatch
| GatewayGuildMembersChunkDispatch
| GatewayGuildRoleModifyDispatch
| GatewayGuildMemberUpdateDispatch
| GatewayGuildModifyDispatch
| GatewayGuildRoleDeleteDispatch
| GatewayGuildRoleModifyDispatch
| GatewayIntegrationCreateDispatch
| GatewayIntegrationDeleteDispatch
| GatewayIntegrationUpdateDispatch
| GatewayInteractionCreateDispatch
| GatewayInviteCreateDispatch
| GatewayInviteDeleteDispatch
| GatewayMessageCreateDispatch
| GatewayMessageUpdateDispatch
| GatewayMessageDeleteDispatch
| GatewayMessageDeleteBulkDispatch
| GatewayMessageDeleteDispatch
| GatewayMessageReactionAddDispatch
| GatewayMessageReactionRemoveDispatch
| GatewayMessageReactionRemoveAllDispatch
| GatewayMessageReactionRemoveDispatch
| GatewayMessageReactionRemoveEmojiDispatch
| GatewayMessageUpdateDispatch
| GatewayPresenceUpdateDispatch
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayTypingStartDispatch
| GatewayUserUpdateDispatch
| GatewayVoiceStateUpdateDispatch
| GatewayVoiceServerUpdateDispatch
| GatewayVoiceStateUpdateDispatch
| GatewayWebhooksUpdateDispatch;
// #region Dispatch Payloads
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandModifyDispatch = DataPayload<
| GatewayDispatchEvents.ApplicationCommandCreate
| GatewayDispatchEvents.ApplicationCommandUpdate
| GatewayDispatchEvents.ApplicationCommandDelete,
GatewayApplicationCommandModifyDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
guild_id?: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
*/
export type GatewayApplicationCommandCreateDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
*/
export type GatewayApplicationCommandCreateDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-update
*/
export type GatewayApplicationCommandUpdateDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-update
*/
export type GatewayApplicationCommandUpdateDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandDeleteDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandDeleteDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#hello
*/
@@ -455,10 +413,6 @@ export interface GatewayReadyDispatchData {
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: APIUser;
/**
* Empty array
*/
private_channels: [];
/**
* The guilds the user is in
*
@@ -550,11 +504,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The time at which the most recent pinned message was pinned
*/
@@ -623,7 +577,7 @@ export interface GatewayGuildBanModifyDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The banned user
*
@@ -667,7 +621,7 @@ export interface GatewayGuildEmojisUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Array of emojis
*
@@ -691,7 +645,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData {
/**
* ID of the guild whose integrations were updated
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -709,7 +663,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -727,7 +681,7 @@ export interface GatewayGuildMemberRemoveDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The user who was removed
*
@@ -747,12 +701,14 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute'> & {
/**
* The id of the guild
*/
guild_id: string;
};
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user'> &
Partial<Pick<APIGuildMember, 'deaf' | 'mute'>> &
Required<Pick<APIGuildMember, 'user'>> & {
/**
* The id of the guild
*/
guild_id: Snowflake;
};
/**
* https://discord.com/developers/docs/topics/gateway#guild-members-chunk
@@ -769,7 +725,7 @@ export interface GatewayGuildMembersChunkDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Set of guild members
*
@@ -819,7 +775,7 @@ export interface GatewayGuildRoleModifyDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The role created or updated
*
@@ -863,11 +819,63 @@ export interface GatewayGuildRoleDeleteDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the role
*/
role_id: string;
role_id: Snowflake;
}
/**
* https://discord.com/developers/docs/topics/gateway#integration-create
*/
export type GatewayIntegrationCreateDispatch = DataPayload<
GatewayDispatchEvents.IntegrationCreate,
GatewayIntegrationCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-create
*/
export type GatewayIntegrationCreateDispatchData = APIGuildIntegration & { guild_id: Snowflake };
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationUpdateDispatch = DataPayload<
GatewayDispatchEvents.IntegrationUpdate,
GatewayIntegrationUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationUpdateDispatchData = APIGuildIntegration & { guild_id: Snowflake };
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationDeleteDispatch = DataPayload<
GatewayDispatchEvents.IntegrationDelete,
GatewayIntegrationDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-delete
*/
export interface GatewayIntegrationDeleteDispatchData {
/**
* Integration id
*/
id: Snowflake;
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* ID of the bot/OAuth2 application for this Discord integration
*/
application_id?: Snowflake;
}
/**
@@ -898,7 +906,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The channel the invite is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The unique invite code
*
@@ -912,7 +920,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The user that created the invite
*
@@ -928,17 +936,21 @@ export interface GatewayInviteCreateDispatchData {
*/
max_uses: number;
/**
* The target user for this invite
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
target_type?: InviteTargetType;
/**
* The user whose stream to display for this voice channel stream invite
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
target_user?: APIUser;
/**
* The type of user target for this invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
* The embedded application to open for this voice channel embedded application invite
*/
target_user_type?: InviteTargetUserType;
target_application?: Partial<APIApplication>;
/**
* Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role)
*/
@@ -964,11 +976,11 @@ export interface GatewayInviteDeleteDispatchData {
/**
* The channel of the invite
*/
channel_id: string;
channel_id: Snowflake;
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The unique invite code
*
@@ -1002,8 +1014,8 @@ export type GatewayMessageUpdateDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatchData = {
id: string;
channel_id: string;
id: Snowflake;
channel_id: Snowflake;
} & Partial<APIMessage>;
/**
@@ -1021,15 +1033,15 @@ export interface GatewayMessageDeleteDispatchData {
/**
* The id of the message
*/
id: string;
id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1047,15 +1059,15 @@ export interface GatewayMessageDeleteBulkDispatchData {
/**
* The ids of the messages
*/
ids: string[];
ids: Snowflake[];
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1134,15 +1146,15 @@ export interface GatewayTypingStartDispatchData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* Unix time (in seconds) of when the user started typing
*/
@@ -1197,11 +1209,15 @@ export interface GatewayVoiceServerUpdateDispatchData {
/**
* The guild this voice server update is for
*/
guild_id: string;
guild_id: Snowflake;
/**
* The voice server host
*
* A `null` endpoint means that the voice server allocated has gone away and is trying to be reallocated.
* You should attempt to disconnect from the currently connected voice server, and not attempt to reconnect
* until a new voice server is allocated
*/
endpoint: string;
endpoint: string | null;
}
/**
@@ -1219,11 +1235,11 @@ export interface GatewayWebhooksUpdateDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
}
// #endregion Dispatch Payloads
@@ -1290,13 +1306,6 @@ export interface GatewayIdentifyData {
* See https://discord.com/developers/docs/topics/gateway#update-status
*/
presence?: GatewayPresenceUpdateData;
/**
* Enables dispatching of guild subscription events (presence and typing events)
*
* @default true
* @deprecated Use `intents` instead
*/
guild_subscriptions?: boolean;
/**
* The Gateway Intents you wish to receive
*
@@ -1364,7 +1373,7 @@ export interface GatewayRequestGuildMembersData {
/**
* ID of the guild to get members for
*/
guild_id: string | string[];
guild_id: Snowflake;
/**
* String that username starts with, or an empty string to return all members
*/
@@ -1381,10 +1390,12 @@ export interface GatewayRequestGuildMembersData {
/**
* Used to specify which users you wish to fetch
*/
user_ids?: string | string[];
user_ids?: Snowflake | Snowflake[];
/**
* Nonce to identify the Guild Members Chunk response
*
* Nonce can only be up to 32 bytes. If you send an invalid nonce it will be ignored and the reply member_chunk(s) will not have a `nonce` set.
*
* See https://discord.com/developers/docs/topics/gateway#guild-members-chunk
*/
nonce?: string;
@@ -1405,11 +1416,11 @@ export interface GatewayVoiceStateUpdateData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* ID of the voice channel client wants to join (`null` if disconnecting)
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* Is the client muted
*/
@@ -1437,11 +1448,11 @@ export interface GatewayPresenceUpdateData {
*/
since: number | null;
/**
* `null`, or the user's activities
* The user's activities
*
* See https://discord.com/developers/docs/topics/gateway#activity-object
*/
activities: GatewayActivityUpdateData[] | null;
activities: GatewayActivityUpdateData[];
/**
* The user's new status
*
@@ -1496,19 +1507,19 @@ type ReactionData<E extends GatewayDispatchEvents, O extends string = never> = D
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The member who reacted if this happened in a guild
*
@@ -1530,14 +1541,14 @@ interface MessageReactionRemoveData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
// #endregion Shared

70
deno/globals.ts Normal file
View File

@@ -0,0 +1,70 @@
/**
* https://discord.com/developers/docs/reference#snowflakes
*/
export type Snowflake = `${bigint}`;
/**
* https://discord.com/developers/docs/topics/permissions
* @internal
*/
export type Permissions = `${bigint}`;
/**
* https://discord.com/developers/docs/reference#message-formatting-formats
*/
export const FormattingPatterns = {
/**
* Regular expression for matching a user mention, strictly without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
User: /<@(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, strictly with a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithNickname: /<@!(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, with or without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithOptionalNickname: /<@!?(?<id>\d{17,20})>/,
/**
* Regular expression for matching a channel mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Channel: /<#(?<id>\d{17,20})>/,
/**
* Regular expression for matching a role mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Role: /<@&(?<id>\d{17,20})>/,
/**
* Regular expression for matching a custom emoji, either static or animated
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
Emoji: /<(?<animated>a)?:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly an animated custom emoji
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
AnimatedEmoji: /<(?<animated>a):(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly a static custom emoji
*
* The `name` and `id` group properties are present on the `exec` result of this expression
*/
StaticEmoji: /<:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
} as const;
/**
* Freezes the formatting patterns
* @internal
*/
Object.freeze(FormattingPatterns);

4
deno/payloads/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the payloads available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8/mod.ts';

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/audit-log
*/
import type { Snowflake } from '../../globals.ts';
import type { APIOverwrite, ChannelType } from './channel.ts';
import type {
APIGuildIntegration,
@@ -62,14 +63,13 @@ export interface APIAuditLogEntry {
/**
* The user who made the changes
*
* *Against all odds, this can be `null` in some cases (webhooks deleting themselves
* by using their own token, for example)*
* This can be `null` in some cases (webhooks deleting themselves by using their own token, for example)
*/
user_id: string | null;
user_id: Snowflake | null;
/**
* ID of the entry
*/
id: string;
id: Snowflake;
/**
* Type of action that occurred
*
@@ -91,7 +91,7 @@ export interface APIAuditLogEntry {
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
*/
export const enum AuditLogEvent {
export enum AuditLogEvent {
GUILD_UPDATE = 1,
CHANNEL_CREATE = 10,
@@ -165,7 +165,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_UNPIN
* - MESSAGE_DELETE
*/
channel_id?: string;
channel_id?: Snowflake;
/**
* ID of the message that was targeted
@@ -174,7 +174,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_PIN
* - MESSAGE_UNPIN
*/
message_id?: string;
message_id?: Snowflake;
/**
* Number of entities that were targeted
@@ -195,7 +195,7 @@ export interface APIAuditLogOptions {
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*/
id?: string;
id?: Snowflake;
/**
* Type of overwritten entity - "0" for "role" or "1" for "member"
@@ -222,7 +222,7 @@ export interface APIAuditLogOptions {
role_name?: string;
}
export const enum AuditLogOptionsType {
export enum AuditLogOptionsType {
Role = '0',
Member = '1',
}
@@ -232,12 +232,18 @@ export const enum AuditLogOptionsType {
*/
export type APIAuditLogChange =
| APIAuditLogChangeKeyName
| APIAuditLogChangeKeyDescription
| APIAuditLogChangeKeyIconHash
| APIAuditLogChangeKeySplashHash
| APIAuditLogChangeKeyDiscoverySplashHash
| APIAuditLogChangeKeyBannerHash
| APIAuditLogChangeKeyOwnerID
| APIAuditLogChangeKeyRegion
| APIAuditLogChangeKeyPreferredLocale
| APIAuditLogChangeKeyAFKChannelID
| APIAuditLogChangeKeyAFKTimeout
| APIAuditLogChangeKeyRulesChannelID
| APIAuditLogChangeKeyPublicUpdatesChannelID
| APIAuditLogChangeKeyMFALevel
| APIAuditLogChangeKeyVerificationLevel
| APIAuditLogChangeKeyExplicitContentFilter
@@ -277,13 +283,19 @@ export type APIAuditLogChange =
| APIAuditLogChangeKeyType
| APIAuditLogChangeKeyEnableEmoticons
| APIAuditLogChangeKeyExpireBehavior
| APIAuditLogChangeKeyExpireGracePeriod;
| APIAuditLogChangeKeyExpireGracePeriod
| APIAuditLogChangeKeyUserLimit;
/**
* Returned when a guild's name is changed
*/
export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>;
/**
* Returned when a guild's description is changed
*/
export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>;
/**
* Returned when a guild's icon is changed
*/
@@ -295,25 +307,50 @@ export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', strin
export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>;
/**
* Returned when a guild's owner ID is changed
* Returned when a guild's discovery splash is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>;
export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>;
/**
* Returned when a guild's banner hash is changed
*/
export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>;
/**
* Returned when a guild's owner_id is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowflake>;
/**
* Returned when a guild's region is changed
*/
export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>;
/**
* Returned when a guild's preferred_locale is changed
*/
export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>;
/**
* Returned when a guild's afk_channel_id is changed
*/
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>;
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', Snowflake>;
/**
* Returned when a guild's afk_timeout is changed
*/
export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>;
/**
* Returned when a guild's rules_channel_id is changed
*/
export type APIAuditLogChangeKeyRulesChannelID = AuditLogChangeData<'rules_channel_id', string>;
/**
* Returned when a guild's public_updates_channel_id is changed
*/
export type APIAuditLogChangeKeyPublicUpdatesChannelID = AuditLogChangeData<'public_updates_channel_id', string>;
/**
* Returned when a guild's mfa_level is changed
*/
@@ -368,12 +405,12 @@ export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabl
/**
* Returned when a guild's widget_channel_id is changed
*/
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>;
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', Snowflake>;
/**
* Returned when a guild's system_channel_id is changed
*/
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', string>;
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', Snowflake>;
/**
* Returned when a channel's position is changed
@@ -403,7 +440,7 @@ export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>;
/**
* The application ID of the added or removed Webhook or Bot
*/
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', string>;
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', Snowflake>;
/**
* Returned when a channel's amount of seconds a user has to wait before sending another message
@@ -449,12 +486,12 @@ export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>;
/**
* Returned when an invite's channel_id is changed
*/
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>;
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', Snowflake>;
/**
* Returned when an invite's inviter_id is changed
*/
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>;
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', Snowflake>;
/**
* Returned when an invite's max_uses is changed
@@ -499,7 +536,7 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s
/**
* The ID of the changed entity - sometimes used in conjunction with other keys
*/
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', string>;
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>;
/**
* The type of entity created
@@ -522,10 +559,18 @@ export type APIAuditLogChangeKeyExpireBehavior = AuditLogChangeData<'expire_beha
export type APIAuditLogChangeKeyExpireGracePeriod = AuditLogChangeData<'expire_grace_period', number>;
/**
* @internal
* Returned when a voice channel's user_limit is changed
*/
export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', number>;
interface AuditLogChangeData<K extends string, D extends unknown> {
key: K;
/**
* The new value
*
* If `new_value` is not present in the change object, while `old_value` is,
* that means the property that was changed has been reset, or set to `null`
*/
new_value?: D;
old_value?: D;
}

View File

@@ -2,8 +2,12 @@
* Types extracted from https://discord.com/developers/docs/resources/channel
*/
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIPartialEmoji } from './emoji.ts';
import type { APIGuildMember } from './guild.ts';
import type { APIMessageInteraction } from './interactions.ts';
import { APIApplication } from './oauth2.ts';
import type { APIRole } from './permissions.ts';
import type { APIUser } from './user.ts';
/**
@@ -13,7 +17,7 @@ export interface APIPartialChannel {
/**
* The id of the channel
*/
id: string;
id: Snowflake;
/**
* The type of the channel
*
@@ -31,9 +35,9 @@ export interface APIPartialChannel {
*/
export interface APIChannel extends APIPartialChannel {
/**
* The id of the guild
* The id of the guild (may be missing for some channel objects received over gateway guild dispatches)
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* Sorting position of the channel
*/
@@ -55,7 +59,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: string | null;
last_message_id?: Snowflake | null;
/**
* The bitrate (in bits) of the voice channel
*/
@@ -82,30 +86,42 @@ export interface APIChannel extends APIPartialChannel {
/**
* ID of the DM creator
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* Application id of the group DM creator if it is bot-created
*/
application_id?: string;
application_id?: Snowflake;
/**
* ID of the parent category for a channel (each parent category can contain up to 50 channels)
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
/**
* When the last pinned message was pinned.
* This may be `null` in events such as `GUILD_CREATE` when a message is not pinned
*/
last_pin_timestamp?: string | null;
/**
* Voice region id for the voice or stage channel, automatic when set to `null`
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
/**
* The camera video quality mode of the voice channel, `1` when not present
*
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode;
}
/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*/
export const enum ChannelType {
export enum ChannelType {
/**
* A text channel within a guild
*/
GUILD_TEXT = 0,
GUILD_TEXT,
/**
* A direct message between users
*/
@@ -136,6 +152,23 @@ export const enum ChannelType {
* See https://discord.com/developers/docs/game-and-server-management/special-channels
*/
GUILD_STORE,
/**
* A voice channel for hosting events with an audience
*
* See https://support.discord.com/hc/en-us/articles/1500005513722
*/
GUILD_STAGE_VOICE = 13,
}
export enum VideoQualityMode {
/**
* Discord chooses the quality for optimal performance
*/
AUTO = 1,
/**
* 720p
*/
FULL,
}
/**
@@ -145,15 +178,15 @@ export interface APIMessage {
/**
* ID of the message
*/
id: string;
id: Snowflake;
/**
* ID of the channel the message was sent in
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the guild the message was sent in
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The author of this message (only a valid user in the case where the message is generated by a user or bot user)
*
@@ -207,7 +240,7 @@ export interface APIMessage {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
mention_roles: string[];
mention_roles: APIRole['id'][];
/**
* Channels specifically mentioned in this message
*
@@ -239,7 +272,7 @@ export interface APIMessage {
*/
reactions?: APIReaction[];
/**
* Used for validating a message was sent
* A nonce that can be used for optimistic message sending (up to 25 characters)
*
* **You will not receive this from further fetches. This is received only once from a `MESSAGE_CREATE`
* event to ensure it got sent**
@@ -252,7 +285,7 @@ export interface APIMessage {
/**
* If the message is generated by a webhook, this is the webhook's id
*/
webhook_id?: string;
webhook_id?: Snowflake;
/**
* Type of message
*
@@ -270,7 +303,7 @@ export interface APIMessage {
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
*/
application?: APIMessageApplication;
application?: Partial<APIApplication>;
/**
* Reference data sent with crossposted messages and replies
*
@@ -305,12 +338,16 @@ export interface APIMessage {
* See https://discord.com/developers/docs/resources/channel#message-object
*/
referenced_message?: APIMessage | null;
/**
* Sent if the message is a response to an Interaction
*/
interaction?: APIMessageInteraction;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-types
*/
export const enum MessageType {
export enum MessageType {
DEFAULT,
RECIPIENT_ADD,
RECIPIENT_REMOVE,
@@ -330,6 +367,7 @@ export const enum MessageType {
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING,
REPLY = 19,
APPLICATION_COMMAND,
GUILD_INVITE_REMINDER = 22,
}
/**
@@ -350,32 +388,6 @@ export interface APIMessageActivity {
party_id?: string;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
*/
export interface APIMessageApplication {
/**
* ID of the application
*/
id: string;
/**
* ID of the embed's image asset
*/
cover_image?: string;
/**
* Application's description
*/
description: string;
/**
* ID of the application's icon
*/
icon: string | null;
/**
* Name of the application
*/
name: string;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
@@ -383,21 +395,21 @@ export interface APIMessageReference {
/**
* ID of the originating message
*/
message_id?: string;
message_id?: Snowflake;
/**
* ID of the originating message's channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the originating message's guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
*/
export const enum MessageActivityType {
export enum MessageActivityType {
JOIN = 1,
SPECTATE,
LISTEN,
@@ -407,7 +419,7 @@ export const enum MessageActivityType {
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-flags
*/
export const enum MessageFlags {
export enum MessageFlags {
/**
* This message has been published to subscribed channels (via Channel Following)
*/
@@ -428,7 +440,14 @@ export const enum MessageFlags {
* This message came from the urgent message system
*/
URGENT = 1 << 4,
/**
* This message is only visible to the user who invoked the Interaction
*/
EPHEMERAL = 1 << 6,
/**
* This message is an Interaction Response and the bot is "thinking"
*/
LOADING = 1 << 7,
}
/**
@@ -438,11 +457,11 @@ export interface APISticker {
/**
* ID of the sticker
*/
id: string;
id: Snowflake;
/**
* ID of the pack the sticker is from
*/
pack_id: string;
pack_id: Snowflake;
/**
* Name of the sticker
*/
@@ -459,10 +478,6 @@ export interface APISticker {
* Sticker asset hash
*/
asset: string;
/**
* Sticker preview asset hash
*/
preview_asset: string | null;
/**
* Type of sticker format
*
@@ -474,7 +489,7 @@ export interface APISticker {
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types
*/
export const enum StickerFormatType {
export enum StickerFormatType {
PNG = 1,
APNG,
LOTTIE,
@@ -487,11 +502,11 @@ export interface APIFollowedChannel {
/**
* Source channel id
*/
channel_id: string;
channel_id: Snowflake;
/**
* Created target webhook id
*/
webhook_id: string;
webhook_id: Snowflake;
}
/**
@@ -521,7 +536,7 @@ export interface APIOverwrite {
/**
* Role or user id
*/
id: string;
id: Snowflake;
/**
* Either 0 (role) or 1 (member)
*
@@ -535,7 +550,7 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* Permission bit set
*
@@ -543,10 +558,10 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
}
export const enum OverwriteType {
export enum OverwriteType {
Role,
Member,
}
@@ -639,7 +654,7 @@ export interface APIEmbed {
* https://discord.com/developers/docs/resources/channel#embed-object-embed-types
* @deprecated *Embed types should be considered deprecated and might be removed in a future API version*
*/
export const enum EmbedType {
export enum EmbedType {
/**
* Generic embed rendered from embed attributes
*/
@@ -815,11 +830,17 @@ export interface APIAttachment {
/**
* Attachment id
*/
id: string;
id: Snowflake;
/**
* Name of file attached
*/
filename: string;
/**
* The attachment's media type
*
* See https://en.wikipedia.org/wiki/Media_type
*/
content_type?: string;
/**
* Size of file in bytes
*/
@@ -849,11 +870,11 @@ export interface APIChannelMention {
/**
* ID of the channel
*/
id: string;
id: Snowflake;
/**
* ID of the guild containing the channel
*/
guild_id: string;
guild_id: Snowflake;
/**
* The type of channel
*
@@ -869,7 +890,7 @@ export interface APIChannelMention {
/**
* https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types
*/
export const enum AllowedMentionsTypes {
export enum AllowedMentionsTypes {
/**
* Controls @everyone and @here mentions
*/
@@ -897,11 +918,11 @@ export interface APIAllowedMentions {
/**
* Array of role_ids to mention (Max size of 100)
*/
roles?: string[];
roles?: Snowflake[];
/**
* Array of user_ids to mention (Max size of 100)
*/
users?: string[];
users?: Snowflake[];
/**
* For replies, whether to mention the author of the message being replied to (default false)
*

View File

@@ -2,6 +2,8 @@
* Types extracted from https://discord.com/developers/docs/resources/emoji
*/
import type { Snowflake } from '../../globals.ts';
import type { APIRole } from './permissions.ts';
import type { APIUser } from './user.ts';
/**
@@ -11,7 +13,7 @@ export interface APIPartialEmoji {
/**
* Emoji id
*/
id: string | null;
id: Snowflake | null;
/**
* Emoji name (can be null only in reaction emoji objects)
*/
@@ -29,7 +31,7 @@ export interface APIEmoji extends APIPartialEmoji {
/**
* Roles this emoji is whitelisted to
*/
roles?: string[];
roles?: APIRole['id'][];
/**
* User that created this emoji
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../globals.ts';
import type { APIEmoji } from './emoji.ts';
import type { APIUser } from './user.ts';
@@ -67,13 +68,11 @@ export interface GatewayPresenceUpdate {
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: Partial<APIUser> & {
id: string;
};
user: Partial<APIUser> & Pick<APIUser, 'id'>;
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Either "idle", "dnd", "online", or "offline"
*/
@@ -92,7 +91,7 @@ export interface GatewayPresenceUpdate {
client_status?: GatewayPresenceClientStatus;
}
export const enum PresenceUpdateStatus {
export enum PresenceUpdateStatus {
Online = 'online',
DoNotDisturb = 'dnd',
Idle = 'idle',
@@ -156,7 +155,7 @@ export interface GatewayActivity {
/**
* Application id for the game
*/
application_id?: string;
application_id?: Snowflake;
/**
* What the player is currently doing
*/
@@ -202,6 +201,9 @@ export interface GatewayActivity {
* See https://en.wikipedia.org/wiki/Bit_field
*/
flags?: ActivityFlags;
/**
* The custom buttons shown in the Rich Presence (max 2)
*/
buttons?: string[] | GatewayActivityButton[];
}
@@ -214,7 +216,7 @@ export enum ActivityPlatform {
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*/
export const enum ActivityType {
export enum ActivityType {
/**
* Playing {game}
*/
@@ -289,7 +291,7 @@ export type GatewayActivitySecrets = Partial<Record<'join' | 'spectate' | 'match
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*/
export const enum ActivityFlags {
export enum ActivityFlags {
INSTANCE = 1 << 0,
JOIN = 1 << 1,
SPECTATE = 1 << 2,
@@ -299,6 +301,12 @@ export const enum ActivityFlags {
}
export interface GatewayActivityButton {
/**
* The text shown on the button (1-32 characters)
*/
label: string;
/**
* The url opened when clicking the button (1-512 characters)
*/
url: string;
}

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts';
@@ -16,7 +17,7 @@ export interface APIUnavailableGuild {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* `true` if this guild is unavailable due to an outage
*/
@@ -100,7 +101,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* ID of owner
*/
owner_id: string;
owner_id: Snowflake;
/**
* Total permissions for the user in the guild (excludes overrides)
*
@@ -108,17 +109,18 @@ export interface APIGuild extends APIPartialGuild {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions?: string;
permissions?: Permissions;
/**
* Voice region id for the guild
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
* @deprecated This field has been deprecated in favor of `rtc_region` on the channel.
*/
region: string;
/**
* ID of afk channel
*/
afk_channel_id: string | null;
afk_channel_id: Snowflake | null;
/**
* afk timeout in seconds
*/
@@ -130,7 +132,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The channel id that the widget will generate an invite to, or `null` if set to no invite
*/
widget_channel_id?: string | null;
widget_channel_id?: Snowflake | null;
/**
* Verification level required for the guild
*
@@ -176,11 +178,11 @@ export interface APIGuild extends APIPartialGuild {
/**
* Application id of the guild creator if it is bot-created
*/
application_id: string | null;
application_id: Snowflake | null;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id: string | null;
system_channel_id: Snowflake | null;
/**
* System channel flags
*
@@ -190,7 +192,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: string | null;
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
@@ -282,7 +284,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id: string | null;
public_updates_channel_id: Snowflake | null;
/**
* The maximum amount of users in a video channel
*/
@@ -295,13 +297,24 @@ export interface APIGuild extends APIPartialGuild {
* **This field is only received from https://discord.com/developers/docs/resources/guild#get-guild with the `with_counts` query parameter set to `true`**
*/
approximate_presence_count?: number;
/**
* The welcome screen of a Community guild, shown to new members
*
* Returned in the invite object
*/
welcome_screen?: APIGuildWelcomeScreen;
/**
* `true` if this guild is designated as NSFW
*
* See https://support.discord.com/hc/en-us/articles/1500005389362-NSFW-Server-Designation
*/
nsfw: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
export const enum GuildDefaultMessageNotifications {
export enum GuildDefaultMessageNotifications {
ALL_MESSAGES,
ONLY_MENTIONS,
}
@@ -309,7 +322,7 @@ export const enum GuildDefaultMessageNotifications {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
export const enum GuildExplicitContentFilter {
export enum GuildExplicitContentFilter {
DISABLED,
MEMBERS_WITHOUT_ROLES,
ALL_MEMBERS,
@@ -318,7 +331,7 @@ export const enum GuildExplicitContentFilter {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
*/
export const enum GuildMFALevel {
export enum GuildMFALevel {
NONE,
ELEVATED,
}
@@ -326,7 +339,7 @@ export const enum GuildMFALevel {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
export const enum GuildVerificationLevel {
export enum GuildVerificationLevel {
/**
* Unrestricted
*/
@@ -352,7 +365,7 @@ export const enum GuildVerificationLevel {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
*/
export const enum GuildPremiumTier {
export enum GuildPremiumTier {
NONE,
TIER_1,
TIER_2,
@@ -362,7 +375,7 @@ export const enum GuildPremiumTier {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
export const enum GuildSystemChannelFlags {
export enum GuildSystemChannelFlags {
/**
* Suppress member join notifications
*/
@@ -371,12 +384,16 @@ export const enum GuildSystemChannelFlags {
* Suppress server boost notifications
*/
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1,
/**
* Suppress server setup tips
*/
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2,
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
export const enum GuildFeature {
export enum GuildFeature {
/**
* Guild has access to set an animated guild icon
*/
@@ -447,7 +464,7 @@ export interface APIGuildPreview {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* Guild name (2-100 characters)
*/
@@ -507,7 +524,7 @@ export interface APIGuildWidgetSettings {
/**
* The widget channel id
*/
channel_id: string | null;
channel_id: Snowflake | null;
}
/**
@@ -531,7 +548,7 @@ export interface APIGuildMember {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles: string[];
roles: Snowflake[];
/**
* When the user joined the guild
*/
@@ -565,7 +582,7 @@ export interface APIGuildIntegration {
/**
* Integration id
*/
id: string;
id: Snowflake;
/**
* Integration name
*/
@@ -589,7 +606,7 @@ export interface APIGuildIntegration {
*
* **This field is not provided for `discord` bot integrations.**
*/
role_id?: string;
role_id?: Snowflake;
/**
* Whether emoticons should be synced for this integration (`twitch` only currently)
*
@@ -657,7 +674,7 @@ export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
/**
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
*/
export const enum IntegrationExpireBehavior {
export enum IntegrationExpireBehavior {
RemoveRole,
Kick,
}
@@ -683,7 +700,7 @@ export interface APIGuildIntegrationApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -728,7 +745,7 @@ export interface APIBan {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidget {
id: string;
id: Snowflake;
name: string;
instant_invite: string | null;
channels: APIGuildWidgetChannel[];
@@ -740,7 +757,7 @@ export interface APIGuildWidget {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidgetChannel {
id: string;
id: Snowflake;
name: string;
position: number;
}
@@ -761,7 +778,7 @@ export interface APIGuildWidgetMember {
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options
*/
export const enum GuildWidgetStyle {
export enum GuildWidgetStyle {
/**
* Shield style widget with Discord icon and guild members online count
*/
@@ -800,11 +817,15 @@ export interface APIGuildWelcomeScreenChannel {
/**
* The channel id that is suggested
*/
channel_id: string;
channel_id: Snowflake;
/**
* The description shown for the channel
*/
description: string;
/**
* The emoji id of the emoji that is shown on the left of the channel
*/
emoji_id: string | null;
emoji_id: Snowflake | null;
/**
* The emoji name of the emoji that is shown on the left of the channel
*/
@@ -847,7 +868,7 @@ export interface APIGuildMembershipScreeningField {
required: boolean;
}
export const enum MembershipScreeningFieldType {
export enum MembershipScreeningFieldType {
/**
* Server Rules
*/

View File

@@ -0,0 +1,396 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v8/mod.ts';
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './mod.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
*/
export interface APIApplicationCommand {
/**
* Unique id of the command
*/
id: Snowflake;
/**
* Unique id of the parent application
*/
application_id: Snowflake;
/**
* 1-32 character name matching `^[\w-]{1,32}$`
*/
name: string;
/**
* 1-100 character description
*/
description: string;
/**
* The parameters for the command
*/
options?: APIApplicationCommandOption[];
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
*/
default_permission?: boolean;
}
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.BOOLEAN
| ApplicationCommandOptionType.USER
| ApplicationCommandOptionType.CHANNEL
| ApplicationCommandOptionType.ROLE;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.SUB_COMMAND | ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.STRING | ApplicationCommandOptionType.INTEGER;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
*/
export enum ApplicationCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIBaseInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The command data payload
*/
data?: APIApplicationCommandInteractionData;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIGuildInteraction extends APIBaseInteraction {
/**
* The guild it was sent from
*
* In the case of an `APIDMInteraction`, this will not be present
*/
guild_id: Snowflake;
/**
* Guild member data for the invoking user, including permissions
*/
member: APIGuildMember & { permissions: Permissions; user: APIUser };
channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIDMInteraction extends APIBaseInteraction {
/**
* User object for the invoking user, if invoked in a DM
*/
user: APIUser;
channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export type APIInteraction = APIGuildInteraction | APIDMInteraction;
/**
* Like APIGuildInteraction, only with the `data` property always present
*
* @see APIGuildInteraction
*/
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
/**
* Like APIDMInteraction, only with the `data` property always present
*
* @see APIDMInteraction
*/
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
/**
* Like APIInteraction, only with the `data` property always present
*
* @see APIInteraction
*/
export type APIApplicationCommandInteraction =
| APIApplicationCommandGuildInteraction
| APIApplicationCommandDMInteraction;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
*/
export enum InteractionType {
Ping = 1,
ApplicationCommand,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
*/
export interface APIGuildApplicationCommandPermissions {
/**
* The id of the command
*/
id: Snowflake;
/**
* The id of the application the command belongs to
*/
application_id: Snowflake;
/**
* The id of the guild
*/
guild_id: Snowflake;
/**
* The permissions for the command in the guild
*/
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
*/
export interface APIApplicationCommandPermission {
/**
* The id of the role or user
*/
id: Snowflake;
/**
* Role or user
*/
type: ApplicationCommandPermissionType;
/**
* `true` to allow, `false`, to disallow
*/
permission: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
*/
export enum ApplicationCommandPermissionType {
ROLE = 1,
USER,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: Snowflake;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
resolved?: {
users?: Record<string, APIUser>;
roles?: Record<string, APIRole>;
members?: Record<string, Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> & { permissions: Permissions }>;
channels?: Record<string, Required<APIPartialChannel> & { permissions: Permissions }>;
};
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
*/
export type APIApplicationCommandInteractionDataOption =
| ApplicationCommandInteractionDataOptionSubCommand
| ApplicationCommandInteractionDataOptionSubCommandGroup
| APIApplicationCommandInteractionDataOptionWithValues;
export interface ApplicationCommandInteractionDataOptionSubCommand {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND;
options: APIApplicationCommandInteractionDataOptionWithValues[];
}
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options: ApplicationCommandInteractionDataOptionSubCommand[];
}
export type APIApplicationCommandInteractionDataOptionWithValues =
| ApplicationCommandInteractionDataOptionString
| ApplicationCommandInteractionDataOptionRole
| ApplicationCommandInteractionDataOptionChannel
| ApplicationCommandInteractionDataOptionUser
| ApplicationCommandInteractionDataOptionInteger
| ApplicationCommandInteractionDataOptionBoolean;
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
ApplicationCommandOptionType.STRING,
string
>;
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
ApplicationCommandOptionType.ROLE,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
ApplicationCommandOptionType.CHANNEL,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
ApplicationCommandOptionType.USER,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
ApplicationCommandOptionType.INTEGER,
number
>;
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
ApplicationCommandOptionType.BOOLEAN,
boolean
>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseChannelMessageWithSource
| APIInteractionResponseDeferredChannelMessageWithSource;
export interface APIInteractionResponsePong {
type: InteractionResponseType.Pong;
}
export interface APIInteractionResponseChannelMessageWithSource {
type: InteractionResponseType.ChannelMessageWithSource;
data: APIInteractionApplicationCommandCallbackData;
}
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
*/
export enum InteractionResponseType {
/**
* ACK a `Ping`
*/
Pong = 1,
/**
* Respond to an interaction with a message
*/
ChannelMessageWithSource = 4,
/**
* ACK an interaction and edit to a response later, the user sees a loading state
*/
DeferredChannelMessageWithSource,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
*/
export type APIInteractionApplicationCommandCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };
/**
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the ApplicationCommand
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
}
/**
* @internal
*/
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
name: string;
type: T;
value: D;
}

View File

@@ -4,6 +4,7 @@
import type { APIPartialChannel } from './channel.ts';
import type { APIPartialGuild } from './guild.ts';
import type { APIApplication } from './oauth2.ts';
import type { APIUser } from './user.ts';
/**
@@ -25,7 +26,7 @@ export interface APIInvite {
*
* See https://discord.com/developers/docs/resources/channel#channel-object
*/
channel?: Required<APIPartialChannel>;
channel: Required<APIPartialChannel>;
/**
* The user who created the invite
*
@@ -33,32 +34,39 @@ export interface APIInvite {
*/
inviter?: APIUser;
/**
* The target user for this invite
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
*/
target_type?: InviteTargetType;
/**
* The user whose stream to display for this voice channel stream invite
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
target_user?: APIUser;
/**
* The type of user target for this invite
* The embedded application to open for this voice channel embedded application invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
* See https://discord.com/developers/docs/topics/oauth2#application
*/
target_user_type?: InviteTargetUserType;
target_application?: Partial<APIApplication>;
/**
* Approximate count of online members (only present when `target_user` is set)
* Approximate count of online members, returned from the `GET /invites/<code>` endpoint when `with_counts` is `true`
*/
approximate_presence_count?: number;
/**
* Approximate count of total members
* Approximate count of total members, returned from the `GET /invites/<code>` endpoint when `with_counts` is `true`
*/
approximate_member_count?: number;
}
/**
* https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
* https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
export const enum InviteTargetUserType {
export enum InviteTargetType {
STREAM = 1,
EMBEDDED_APPLICATION,
}
/**

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
import type { Snowflake } from '../../globals.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
@@ -12,7 +13,7 @@ export interface APIApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -37,6 +38,14 @@ export interface APIApplication {
* When `true` the app's bot will only join upon completion of the full oauth2 code grant flow
*/
bot_require_code_grant: boolean;
/**
* The url of the application's terms of service
*/
terms_of_service_url?: string;
/**
* The url of the application's privacy policy
*/
privacy_policy_url?: string;
/**
* Partial user object containing info on the owner of the application
*
@@ -49,7 +58,7 @@ export interface APIApplication {
*/
summary: string;
/**
* The base64 encoded key for the GameSDK's GetTicket
* The hexadecimal encoded key for verification in interactions and the GameSDK's GetTicket function
*
* See https://discord.com/developers/docs/game-sdk/applications#get-ticket
*/
@@ -63,11 +72,11 @@ export interface APIApplication {
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: string;
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
@@ -79,10 +88,22 @@ export interface APIApplication {
/**
* The application's public flags
*/
flags: number;
flags: ApplicationFlags;
}
export const enum OAuth2Scopes {
export enum ApplicationFlags {
ManagedEmoji = 1 << 2,
GroupDMCreate = 1 << 4,
RPCHasConnected = 1 << 11,
GatewayPresence = 1 << 12,
GatewayPresenceLimited = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}
export enum OAuth2Scopes {
/**
* For oauth2 bots, this puts the bot in the user's selected guild by default
*/
@@ -135,10 +156,6 @@ export const enum OAuth2Scopes {
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
*/
RPC = 'rpc',
/**
* For local rpc server api access, this allows you to access the API as the local user - whitelist only
*/
RPCApi = 'rpc.api',
/**
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
*/

View File

@@ -2,13 +2,14 @@
* Types extracted from https://discord.com/developers/docs/topics/permissions
*/
import type { Permissions, Snowflake } from '../../globals.ts';
/**
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*
* These flags are exported as `BigInt`s and NOT numbers. For most of them, you can
* convert them in a number by wrapping it in `Number()`, however be careful as any
* further bits added may cause issues if done so. Try to use BigInts as much as possible
* or modules that can replicate them in some way
* These flags are exported as `BigInt`s and NOT numbers. Wrapping them in `Number()`
* may cause issues, try to use BigInts as much as possible or modules that can
* replicate them in some way
*/
export const PermissionFlagsBits = {
CREATE_INSTANT_INVITE: 1n << 0n,
@@ -42,6 +43,8 @@ export const PermissionFlagsBits = {
MANAGE_ROLES: 1n << 28n,
MANAGE_WEBHOOKS: 1n << 29n,
MANAGE_EMOJIS: 1n << 30n,
USE_SLASH_COMMANDS: 1n << 31n,
REQUEST_TO_SPEAK: 1n << 32n,
} as const;
/**
@@ -57,7 +60,7 @@ export interface APIRole {
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Role name
*/
@@ -79,7 +82,7 @@ export interface APIRole {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions: string;
permissions: Permissions;
/**
* Whether this role is managed by an integration
*/
@@ -101,7 +104,7 @@ export interface APIRoleTags {
/**
* The id of the bot this role belongs to
*/
bot_id?: string;
bot_id?: Snowflake;
/**
* Whether this is the guild's premium subscriber role
*/
@@ -109,5 +112,5 @@ export interface APIRoleTags {
/**
* The id of the integration this role belongs to
*/
integration_id?: string;
integration_id?: Snowflake;
}

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/teams
*/
import type { Snowflake } from '../../globals.ts';
import type { APIUser } from './user.ts';
/**
@@ -15,7 +16,7 @@ export interface APITeam {
/**
* The unique id of the team
*/
id: string;
id: Snowflake;
/**
* The members of the team
*/
@@ -23,7 +24,7 @@ export interface APITeam {
/**
* The user id of the current team owner
*/
owner_user_id: string;
owner_user_id: Snowflake;
}
/**
@@ -43,7 +44,7 @@ export interface APITeamMember {
/**
* The id of the parent team of which they are a member
*/
team_id: string;
team_id: Snowflake;
/**
* The avatar, discriminator, id, and username of the user
*
@@ -55,7 +56,7 @@ export interface APITeamMember {
/**
* https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum
*/
export const enum TeamMemberMembershipState {
export enum TeamMemberMembershipState {
INVITED = 1,
ACCEPTED,
}

View File

@@ -2,8 +2,9 @@
* Types extracted from https://discord.com/developers/docs/resources/template
*/
import type { Snowflake } from '../../globals.ts';
import type { RESTPostAPIGuildsJSONBody } from '../../rest/v8/mod.ts';
import type { APIUser } from './user.ts';
import type { RESTPostAPIGuildsJSONBody } from '../rest/mod.ts';
/**
* https://discord.com/developers/docs/resources/template#template-object
@@ -28,7 +29,7 @@ export interface APITemplate {
/**
* The ID of the user who created the template
*/
creator_id: string;
creator_id: Snowflake;
/**
* The user who created the template
*
@@ -46,7 +47,7 @@ export interface APITemplate {
/**
* The ID of the guild this template is based on
*/
source_guild_id: string;
source_guild_id: Snowflake;
/**
* The guild snapshot this template contains
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/user
*/
import type { Snowflake } from '../../globals.ts';
import type { APIGuildIntegration } from './guild.ts';
/**
@@ -11,7 +12,7 @@ export interface APIUser {
/**
* The user's id
*/
id: string;
id: Snowflake;
/**
* The user's username, not unique across the platform
*/
@@ -73,7 +74,7 @@ export interface APIUser {
/**
* https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
export const enum UserFlags {
export enum UserFlags {
None = 0,
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
@@ -84,7 +85,6 @@ export const enum UserFlags {
HypeSquadHouseBalance = 1 << 8,
EarlySupporter = 1 << 9,
TeamUser = 1 << 10,
System = 1 << 12,
BugHunterLevel2 = 1 << 14,
VerifiedBot = 1 << 16,
EarlyVerifiedBotDeveloper = 1 << 17,
@@ -93,7 +93,7 @@ export const enum UserFlags {
/**
* https://discord.com/developers/docs/resources/user#user-object-premium-types
*/
export const enum UserPremiumType {
export enum UserPremiumType {
None,
NitroClassic,
Nitro,
@@ -145,7 +145,7 @@ export interface APIConnection {
visibility: ConnectionVisibility;
}
export const enum ConnectionVisibility {
export enum ConnectionVisibility {
/**
* Invisible to everyone except the user themselves
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/voice
*/
import type { Snowflake } from '../../globals.ts';
import type { APIGuildMember } from './guild.ts';
/**
@@ -11,15 +12,15 @@ export interface GatewayVoiceState {
/**
* The guild id this voice state is for
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The channel id this user is connected to
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* The user id this voice state is for
*/
user_id: string;
user_id: Snowflake;
/**
* The guild member this voice state is for
*
@@ -58,6 +59,10 @@ export interface GatewayVoiceState {
* Whether this user is muted by the current user
*/
suppress: boolean;
/**
* The time at which the user requested to speak
*/
request_to_speak_timestamp: string | null;
}
/**

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/webhook
*/
import type { Snowflake } from '../../globals.ts';
import type { APIPartialChannel, APIPartialGuild, APIUser } from './mod.ts';
/**
@@ -11,7 +12,7 @@ export interface APIWebhook {
/**
* The id of the webhook
*/
id: string;
id: Snowflake;
/**
* The type of the webhook
*
@@ -21,11 +22,11 @@ export interface APIWebhook {
/**
* The guild id this webhook is for
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The channel id this webhook is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The user this webhook was created by (not returned when getting a webhook with its token)
*
@@ -47,12 +48,22 @@ export interface APIWebhook {
/**
* The bot/OAuth2 application that created this webhook
*/
application_id: string | null;
application_id: Snowflake | null;
/**
* The guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
*/
source_guild?: APIPartialGuild;
/**
* The channel that this webhook is following (returned for Channel Follower Webhooks)
*/
source_channel?: APIPartialChannel;
/**
* The url used for executing the webhook (returned by the webhooks OAuth2 flow)
*/
url?: string;
}
export const enum WebhookType {
export enum WebhookType {
/**
* Incoming Webhooks can post messages to channels with a generated token
*/

View File

@@ -1,7 +1,7 @@
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes
*/
export const enum RESTJSONErrorCodes {
export enum RESTJSONErrorCodes {
GeneralError,
UnknownAccount = 10001,
@@ -30,6 +30,11 @@ export const enum RESTJSONErrorCodes {
UnknownRedistributable = 10036,
UnknownGuildTemplate = 10057,
UnknownInteraction = 10062,
UnknownApplicationCommand,
BotsCannotUseThisEndpoint = 20001,
OnlyBotsCanUseThisEndpoint,
@@ -87,6 +92,8 @@ export const enum RESTJSONErrorCodes {
CannotExecuteActionOnThisChannelType = 50024,
InvalidOauth2AccessToken,
InvalidWebhookToken = 50027,
InvalidRecipients = 50033,
OneOfTheMessagesProvidedWasTooOldForBulkDelete,
InvalidFormBodyOrContentType,
@@ -104,46 +111,3 @@ export const enum RESTJSONErrorCodes {
APIResourceOverloaded = 130000,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes
*/
export const enum RPCErrorCodes {
UnknownError = 1000,
InvalidPayload = 4000,
InvalidCommand = 4002,
InvalidGuild,
InvalidEvent,
InvalidChannel,
InvalidPermissions,
InvalidClientID,
InvalidOrigin,
InvalidToken,
InvalidUser,
OAuth2Error = 5000,
SelectChannelTimedOut,
GetGuildTimedOut,
SelectVoiceForceRequired,
CaptureShortcutAlreadyListening,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
*/
export const enum RPCCloseEventCodes {
InvalidClientID = 4000,
InvalidOrigin,
RateLimited,
TokenRevoked,
InvalidVersion,
InvalidEncoding,
}
/**
* https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params
*/
export interface GatewayConnectQuery {
v: string;
encoding: 'json' | 'etf';
compress?: 'zlib-stream';
}

4
deno/rest/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the types available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8/mod.ts';

View File

@@ -1,4 +1,4 @@
import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog';
import type { APIAuditLog, AuditLogEvent } from '../../payloads/v6/auditLog.ts';
/**
* https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log

View File

@@ -11,7 +11,7 @@ import type {
InviteTargetUserType,
MessageFlags,
OverwriteType,
} from '../payloads/index';
} from '../../payloads/v6/mod.ts';
// #region TypeDefs

View File

@@ -1,4 +1,4 @@
import type { APIEmoji } from '../payloads/index';
import type { APIEmoji } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis

View File

@@ -1,4 +1,4 @@
import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/mod.ts';
import type { APIGatewayBotInfo, APIGatewayInfo } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway

View File

@@ -15,7 +15,7 @@ import type {
GuildVerificationLevel,
GuildWidgetStyle,
IntegrationExpireBehavior,
} from '../payloads/mod.ts';
} from '../../payloads/v6/mod.ts';
import type { RESTPutAPIChannelPermissionsJSONBody } from './channel.ts';
/**

View File

@@ -1,4 +1,4 @@
import type { APIInvite } from '../payloads/mod.ts';
import type { APIInvite } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/resources/invite#get-invite

View File

@@ -1,3 +1,5 @@
export * from '../common.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';

View File

@@ -1,4 +1,4 @@
import type { APIApplication, APIGuild, APIWebhook } from '../payloads/index';
import type { APIApplication, APIGuild, APIWebhook } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information

View File

@@ -1,4 +1,4 @@
import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/mod.ts';
import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/resources/user#get-current-user

View File

@@ -1,4 +1,4 @@
import type { APIVoiceRegion } from '../payloads/mod.ts';
import type { APIVoiceRegion } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/resources/voice#list-voice-regions

View File

@@ -1,5 +1,5 @@
import type { APIAllowedMentionsSend } from './channel.ts';
import type { APIEmbed, APIMessage, APIWebhook } from '../payloads/mod.ts';
import type { APIEmbed, APIMessage, APIWebhook } from '../../payloads/v6/mod.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook

View File

@@ -1,4 +1,5 @@
import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog';
import type { Snowflake } from '../../globals.ts';
import type { APIAuditLog, AuditLogEvent } from '../../payloads/v8/auditLog.ts';
/**
* https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
@@ -7,7 +8,7 @@ export interface RESTGetAPIAuditLogQuery {
/**
* Filter the log for actions made by a user
*/
user_id?: string;
user_id?: Snowflake;
/**
* The type of audit log events
*/
@@ -15,7 +16,7 @@ export interface RESTGetAPIAuditLogQuery {
/**
* Filter the log before a certain entry ID
*/
before?: string;
before?: Snowflake;
/**
* How many entries are returned (default 50, minimum 1, maximum 100)
*

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIAllowedMentions,
APIChannel,
@@ -9,10 +10,11 @@ import type {
APIOverwrite,
APIUser,
ChannelType,
InviteTargetUserType,
InviteTargetType,
MessageFlags,
OverwriteType,
} from '../payloads/mod.ts';
VideoQualityMode,
} from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/channel#get-channel
@@ -86,7 +88,19 @@ export interface RESTPatchAPIChannelJSONBody {
*
* Channel types: text, news, store, voice
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
/**
* Voice region id for the voice or stage channel, automatic when set to `null`
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
/**
* The camera video quality mode of the voice channel
*
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode | null;
}
/**
@@ -106,15 +120,15 @@ export interface RESTGetAPIChannelMessagesQuery {
/**
* Get messages around this message ID
*/
around?: string;
around?: Snowflake;
/**
* Get messages before this message ID
*/
before?: string;
before?: Snowflake;
/**
* Get messages after this message ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of messages to return (1-100)
*
@@ -133,7 +147,18 @@ export type RESTGetAPIChannelMessagesResult = APIMessage[];
*/
export type RESTGetAPIChannelMessageResult = APIMessage;
export type APIMessageReferenceSend = Partial<APIMessageReference> & Required<Pick<APIMessageReference, 'message_id'>>;
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
*/
export type APIMessageReferenceSend = Partial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> & {
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
};
/**
* https://discord.com/developers/docs/resources/channel#create-message
@@ -150,7 +175,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
/**
* `true` if this is a TTS message
*/
tts?: true;
tts?: boolean;
/**
* Embedded `rich` content
*
@@ -221,14 +246,10 @@ export type RESTDeleteAPIChannelMessageUserReactionResult = never;
* https://discord.com/developers/docs/resources/channel#get-reactions
*/
export interface RESTGetAPIChannelMessageReactionUsersQuery {
/**
* Get users before this user ID
*/
before?: string;
/**
* Get users after this user ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of users to return (1-100)
*
@@ -294,7 +315,7 @@ export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody {
/**
* An array of message ids to delete (2-100)
*/
messages: string[];
messages: Snowflake[];
}
/**
@@ -311,13 +332,13 @@ export interface RESTPutAPIChannelPermissionJSONBody {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* The bitwise value of all disallowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
/**
* `0` for a role or `1` for a member
*/
@@ -364,13 +385,23 @@ export interface RESTPostAPIChannelInviteJSONBody {
*/
unique?: boolean;
/**
* The target user id for this invite
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
target_user_id?: string;
target_type?: InviteTargetType;
/**
* The type of target user for this invite
* The id of the user whose stream to display for this invite
* - Required if `target_type` is 1
* - The user must be streaming in the channel
*/
target_user_type?: InviteTargetUserType;
target_user_id?: Snowflake;
/**
* The id of the embedded application to open for this invite
* - Required if `target_type` is 2
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}
/**
@@ -390,7 +421,7 @@ export interface RESTPostAPIChannelFollowersJSONBody {
/**
* ID of target channel
*/
webhook_channel_id: string;
webhook_channel_id: Snowflake;
}
/**

View File

@@ -1,4 +1,5 @@
import type { APIEmoji } from '../payloads/index';
import type { Snowflake } from '../../globals.ts';
import type { APIEmoji } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/emoji#list-guild-emojis
@@ -27,7 +28,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[];
roles?: Snowflake[];
}
/**
@@ -46,7 +47,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
}
/**

View File

@@ -1,4 +1,4 @@
import type { APIGatewayBotInfo, APIGatewayInfo } from '../payloads/mod.ts';
import type { APIGatewayBotInfo, APIGatewayInfo } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/topics/gateway#get-gateway

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIBan,
APIChannel,
@@ -7,6 +8,7 @@ import type {
APIGuildMember,
APIGuildMembershipScreening,
APIGuildPreview,
APIGuildWelcomeScreen,
APIGuildWidget,
APIGuildWidgetSettings,
APIRole,
@@ -17,8 +19,7 @@ import type {
GuildSystemChannelFlags,
GuildVerificationLevel,
GuildWidgetStyle,
IntegrationExpireBehavior,
} from '../payloads/mod.ts';
} from '../../payloads/v8/mod.ts';
import type { RESTPutAPIChannelPermissionJSONBody } from './channel.ts';
export interface APIGuildCreateOverwrite extends RESTPutAPIChannelPermissionJSONBody {
@@ -30,7 +31,7 @@ export type APIGuildCreatePartialChannel = Partial<
> & {
name: string;
id?: number | string;
parent_id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
@@ -105,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: number | string;
afk_channel_id?: number | Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -113,7 +114,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: number | string;
system_channel_id?: number | Snowflake | null;
/**
* System channel flags
*
@@ -184,7 +185,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: string | null;
afk_channel_id?: Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -198,7 +199,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* User id to transfer guild ownership to (must be owner)
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature)
*
@@ -216,7 +217,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: string | null;
system_channel_id?: Snowflake | null;
/**
* System channel flags
*
@@ -226,11 +227,11 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where Community guilds display rules and/or guidelines
*/
rules_channel_id?: string | null;
rules_channel_id?: Snowflake | null;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id?: string | null;
public_updates_channel_id?: Snowflake | null;
/**
* The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US"
*
@@ -281,7 +282,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the channel
*/
@@ -293,7 +294,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* The new parent id of this channel
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
}>;
/**
@@ -321,7 +322,7 @@ export interface RESTGetAPIGuildMembersQuery {
*
* @default 0
*/
after?: string;
after?: Snowflake;
}
/**
@@ -329,6 +330,9 @@ export interface RESTGetAPIGuildMembersQuery {
*/
export type RESTGetAPIGuildMembersResult = APIGuildMember[];
/**
* https://discord.com/developers/docs/resources/guild#search-guild-members
*/
export interface RESTGetAPIGuildMembersSearchQuery {
/**
* Query string to match username(s) and nickname(s) against
@@ -363,7 +367,7 @@ export interface RESTPutAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[];
roles?: Snowflake[];
/**
* Whether the user is muted in voice channels
*
@@ -395,7 +399,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
/**
* Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel
*
@@ -413,7 +417,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: string | null;
channel_id?: Snowflake | null;
}
/**
@@ -507,7 +511,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
*
* @default "default role permissions in guild"
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*
@@ -540,7 +544,7 @@ export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the role
*/
@@ -563,7 +567,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*/
@@ -635,7 +639,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
/**
* Role(s) to include
*/
include_roles?: string[];
include_roles?: Snowflake[];
}
/**
@@ -660,51 +664,11 @@ export type RESTGetAPIGuildInvitesResult = APIExtendedInvite[];
*/
export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[];
/**
* https://discord.com/developers/docs/resources/guild#create-guild-integration
*/
export interface RESTPostAPIGuildIntegrationJSONBody {
type: string;
id: string;
}
export type RESTPostAPIGuildIntegrationResult = never;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-integration
*/
export interface RESTPatchAPIGuildIntegrationJSONBody {
/**
* The behavior when an integration subscription lapses
*
* See https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
*/
expire_behavior?: IntegrationExpireBehavior | null;
/**
* Period (in days) where the integration will ignore lapsed subscriptions
*/
expire_grace_period?: number | null;
/**
* Whether emoticons should be synced for this integration (`twitch` only currently)
*/
enable_emoticons?: boolean | null;
}
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-integration
*/
export type RESTPatchAPIGuildIntegrationResult = never;
/**
* https://discord.com/developers/docs/resources/guild#delete-guild-integration
*/
export type RESTDeleteAPIGuildIntegrationResult = never;
/**
* https://discord.com/developers/docs/resources/guild#sync-guild-integration
*/
export type RESTPostAPIGuildIntegrationSyncResult = never;
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
*/
@@ -769,3 +733,48 @@ export interface RESTPatchAPIGuildMemberVerificationJSONBody {
}
export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
export interface RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody {
/**
* The id of the channel the user is currently in
*/
channel_id: Snowflake;
/**
* Toggles the user's suppress state
*/
suppress?: boolean;
/**
* Sets the user's request to speak
*/
request_to_speak_timestamp?: string | null;
}
export interface RESTPatchAPIGuildVoiceStateUserJSONBody {
/**
* The id of the channel the user is currently in
*/
channel_id: Snowflake;
/**
* Toggles the user's suppress state
*/
suppress?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
*/
export type RESTGetAPIGuildWelcomeScreenResult = APIGuildWelcomeScreen;
/**
* https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
*/
export interface RESTPatchAPIGuildWelcomeScreenJSONBody extends Nullable<Partial<APIGuildWelcomeScreen>> {
/**
* Whether the welcome screen is enabled
*/
enabled?: boolean | null;
}
type Nullable<T> = {
[P in keyof T]: T[P] | null;
};

View File

@@ -0,0 +1,147 @@
import type {
APIApplicationCommand,
APIApplicationCommandPermission,
APIGuildApplicationCommandPermissions,
APIInteractionResponse,
} from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
*/
export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command
*/
export type RESTGetAPIApplicationCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsJSONBody = Omit<APIApplicationCommand, 'id' | 'application_id'>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
*/
export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
*/
export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands
*/
export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command
*/
export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
*/
export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial<RESTPostAPIApplicationCommandsJSONBody>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
*/
export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand;
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
*/
export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse;
/**
* https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response
*/
export type RESTPostAPIInteractionCallbackFormDataBody =
| {
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| (RESTPostAPIInteractionCallbackJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions
*/
export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions
*/
export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions;
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
*/
export interface RESTPutAPIApplicationCommandPermissionsJSONBody {
permissions: APIApplicationCommandPermission[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
*/
export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions;
/**
* https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
*/
export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick<
APIGuildApplicationCommandPermissions,
'id' | 'permissions'
>[];
/**
* https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
*/
export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[];

View File

@@ -1,4 +1,4 @@
import type { APIInvite } from '../payloads/index';
import type { APIInvite } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/invite#get-invite

View File

@@ -1,3 +1,7 @@
import type { Snowflake } from '../../globals.ts';
export * from '../common.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';
@@ -12,13 +16,14 @@ export * from './voice.ts';
export * from './webhook.ts';
export const APIVersion = '8';
export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/audit-logs`
*/
guildAuditLog(guildID: string) {
return `/guilds/${guildID}/audit-logs`;
guildAuditLog(guildID: Snowflake) {
return `/guilds/${guildID}/audit-logs` as const;
},
/**
@@ -27,8 +32,8 @@ export const Routes = {
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelID: string) {
return `/channels/${channelID}`;
channel(channelID: Snowflake) {
return `/channels/${channelID}` as const;
},
/**
@@ -36,8 +41,8 @@ export const Routes = {
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelID: string) {
return `/channels/${channelID}/messages`;
channelMessages(channelID: Snowflake) {
return `/channels/${channelID}/messages` as const;
},
/**
@@ -46,16 +51,16 @@ export const Routes = {
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}`;
channelMessage(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelMessageCrosspost(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/crosspost`;
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
},
/**
@@ -65,8 +70,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`;
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
},
/**
@@ -75,8 +80,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`;
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
},
/**
@@ -86,24 +91,24 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions`;
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelID: string) {
return `/channels/${channelID}/messages/bulk-delete`;
channelBulkDelete(channelID: Snowflake) {
return `/channels/${channelID}/messages/bulk-delete` as const;
},
/**
@@ -111,8 +116,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermission(channelID: string, overwriteID: string) {
return `/channels/${channelID}/permissions/${overwriteID}`;
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
return `/channels/${channelID}/permissions/${overwriteID}` as const;
},
/**
@@ -120,32 +125,32 @@ export const Routes = {
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvites(channelID: string) {
return `/channels/${channelID}/invites`;
channelInvites(channelID: Snowflake) {
return `/channels/${channelID}/invites` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/followers`
*/
channelFollowers(channelID: string) {
return `/channels/${channelID}/followers`;
channelFollowers(channelID: Snowflake) {
return `/channels/${channelID}/followers` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/typing`
*/
channelTyping(channelID: string) {
return `/channels/${channelID}/typing`;
channelTyping(channelID: Snowflake) {
return `/channels/${channelID}/typing` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/pins`
*/
channelPins(channelID: string) {
return `/channels/${channelID}/pins`;
channelPins(channelID: Snowflake) {
return `/channels/${channelID}/pins` as const;
},
/**
@@ -153,8 +158,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelID: string, messageID: string) {
return `/channels/${channelID}/pins/${messageID}`;
channelPin(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/pins/${messageID}` as const;
},
/**
@@ -162,8 +167,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelID: string, userID: string) {
return `/channels/${channelID}/recipients/${userID}`;
channelRecipient(channelID: Snowflake, userID: Snowflake) {
return `/channels/${channelID}/recipients/${userID}` as const;
},
/**
@@ -171,8 +176,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildID: string) {
return `/guilds/${guildID}/emojis`;
guildEmojis(guildID: Snowflake) {
return `/guilds/${guildID}/emojis` as const;
},
/**
@@ -181,8 +186,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildID: string, emojiID: string) {
return `/guilds/${guildID}/emojis/${emojiID}`;
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
return `/guilds/${guildID}/emojis/${emojiID}` as const;
},
/**
@@ -190,7 +195,7 @@ export const Routes = {
* - POST `/guilds`
*/
guilds() {
return '/guilds';
return '/guilds' as const;
},
/**
@@ -199,16 +204,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildID: string) {
return `/guilds/${guildID}`;
guild(guildID: Snowflake) {
return `/guilds/${guildID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/preview`
*/
guildPreview(guildID: string) {
return `/guilds/${guildID}/preview`;
guildPreview(guildID: Snowflake) {
return `/guilds/${guildID}/preview` as const;
},
/**
@@ -217,8 +222,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildID: string) {
return `/guilds/${guildID}/channels`;
guildChannels(guildID: Snowflake) {
return `/guilds/${guildID}/channels` as const;
},
/**
@@ -228,32 +233,32 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildID: string, userID: string) {
return `/guilds/${guildID}/members/${userID}`;
guildMember(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/members/${userID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members`
*/
guildMembers(guildID: string) {
return `/guilds/${guildID}/members`;
guildMembers(guildID: Snowflake) {
return `/guilds/${guildID}/members` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/search`
*/
guildMembersSearch(guildID: string) {
return `/guilds/${guildID}/members/search`;
guildMembersSearch(guildID: Snowflake) {
return `/guilds/${guildID}/members/search` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/members/@me/nick`
*/
guildCurrentMemberNickname(guildID: string) {
return `/guilds/${guildID}/members/@me/nick`;
guildCurrentMemberNickname(guildID: Snowflake) {
return `/guilds/${guildID}/members/@me/nick` as const;
},
/**
@@ -261,16 +266,16 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
*/
guildMemberRole(guildID: string, memberID: string, roleID: string) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans`
*/
guildBans(guildID: string) {
return `/guilds/${guildID}/bans`;
guildBans(guildID: Snowflake) {
return `/guilds/${guildID}/bans` as const;
},
/**
@@ -279,8 +284,8 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildID: string, userID: string) {
return `/guilds/${guildID}/bans/${userID}`;
guildBan(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/bans/${userID}` as const;
},
/**
@@ -289,8 +294,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildID: string) {
return `/guilds/${guildID}/roles`;
guildRoles(guildID: Snowflake) {
return `/guilds/${guildID}/roles` as const;
},
/**
@@ -298,8 +303,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildID: string, roleID: string) {
return `/guilds/${guildID}/roles/${roleID}`;
guildRole(guildID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/roles/${roleID}` as const;
},
/**
@@ -307,50 +312,40 @@ export const Routes = {
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildID: string) {
return `/guilds/${guildID}/prune`;
guildPrune(guildID: Snowflake) {
return `/guilds/${guildID}/prune` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/regions`
*/
guildVoiceRegions(guildID: string) {
return `/guilds/${guildID}/regions`;
guildVoiceRegions(guildID: Snowflake) {
return `/guilds/${guildID}/regions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/invites`
*/
guildInvites(guildID: string) {
return `/guilds/${guildID}/invites`;
guildInvites(guildID: Snowflake) {
return `/guilds/${guildID}/invites` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/integrations`
* - POST `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildID: string) {
return `/guilds/${guildID}/integrations`;
guildIntegrations(guildID: Snowflake) {
return `/guilds/${guildID}/integrations` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/integrations/{integration.id}`
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}`;
},
/**
* Route for:
* - POST `/guilds/{guild.id}/integrations/{integration.id}/sync`
*/
guildIntegrationSync(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}/sync`;
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}` as const;
},
/**
@@ -358,32 +353,32 @@ export const Routes = {
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildID: string) {
return `/guilds/${guildID}/widget`;
guildWidgetSettings(guildID: Snowflake) {
return `/guilds/${guildID}/widget` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidgetJSON(guildID: string) {
return `/guilds/${guildID}/widget.json`;
guildWidgetJSON(guildID: Snowflake) {
return `/guilds/${guildID}/widget.json` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/vanity-url`
*/
guildVanityUrl(guildID: string) {
return `/guilds/${guildID}/vanity-url`;
guildVanityUrl(guildID: Snowflake) {
return `/guilds/${guildID}/vanity-url` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.png`
*/
guildWidgetImage(guildID: string) {
return `/guilds/${guildID}/widget.png`;
guildWidgetImage(guildID: Snowflake) {
return `/guilds/${guildID}/widget.png` as const;
},
/**
@@ -392,7 +387,7 @@ export const Routes = {
* - DELETE `/invites/{invite.code}`
*/
invite(code: string) {
return `/invites/${code}`;
return `/invites/${code}` as const;
},
/**
@@ -401,7 +396,7 @@ export const Routes = {
* - POST `/guilds/templates/{template.code}`
*/
template(code: string) {
return `/guilds/templates/${code}`;
return `/guilds/templates/${code}` as const;
},
/**
@@ -409,8 +404,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildID: string) {
return `/guilds/${guildID}/templates`;
guildTemplates(guildID: Snowflake) {
return `/guilds/${guildID}/templates` as const;
},
/**
@@ -419,8 +414,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildID: string, code: string) {
return `/guilds/${guildID}/templates/${code}`;
guildTemplate(guildID: Snowflake, code: string) {
return `/guilds/${guildID}/templates/${code}` as const;
},
/**
@@ -431,8 +426,8 @@ export const Routes = {
*
* @param [userID='@me'] The user ID, defaulted to `@me`
*/
user(userID = '@me') {
return `/users/${userID}`;
user(userID: Snowflake | '@me' = '@me') {
return `/users/${userID}` as const;
},
/**
@@ -440,15 +435,15 @@ export const Routes = {
* - GET `/users/@me/guilds`
*/
userGuilds() {
return `/users/@me/guilds`;
return `/users/@me/guilds` as const;
},
/**
* Route for:
* - DELETE `/users/@me/guilds/{guild.id}`
*/
userGuild(guildID: string) {
return `/users/@me/guilds/${guildID}`;
userGuild(guildID: Snowflake) {
return `/users/@me/guilds/${guildID}` as const;
},
/**
@@ -456,7 +451,7 @@ export const Routes = {
* - POST `/users/@me/channels`
*/
userChannels() {
return `/users/@me/channels`;
return `/users/@me/channels` as const;
},
/**
@@ -464,7 +459,7 @@ export const Routes = {
* - GET `/users/@me/connections`
*/
userConnections() {
return `/users/@me/connections`;
return `/users/@me/connections` as const;
},
/**
@@ -472,7 +467,7 @@ export const Routes = {
* - GET `/voice/regions`
*/
voiceRegions() {
return `/voice/regions`;
return `/voice/regions` as const;
},
/**
@@ -480,16 +475,16 @@ export const Routes = {
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
*/
channelWebhooks(channelID: string) {
return `/channels/${channelID}/webhooks`;
channelWebhooks(channelID: Snowflake) {
return `/channels/${channelID}/webhooks` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/webhooks`
*/
guildWebhooks(guildID: string) {
return `/guilds/${guildID}/webhooks`;
guildWebhooks(guildID: Snowflake) {
return `/guilds/${guildID}/webhooks` as const;
},
/**
@@ -504,16 +499,18 @@ export const Routes = {
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookID: string, webhookToken?: string) {
webhook(webhookID: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookID];
if (webhookToken) parts.push(webhookToken);
return parts.join('/');
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
},
/**
* Route for:
* - GET `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - GET `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
@@ -525,8 +522,8 @@ export const Routes = {
*
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID: Snowflake | '@original' = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
},
/**
@@ -534,8 +531,8 @@ export const Routes = {
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
},
/**
@@ -543,7 +540,7 @@ export const Routes = {
* - GET `/gateway`
*/
gateway() {
return `/gateway`;
return `/gateway` as const;
},
/**
@@ -551,7 +548,7 @@ export const Routes = {
* - GET `/gateway/bot`
*/
gatewayBot() {
return `/gateway/bot`;
return `/gateway/bot` as const;
},
/**
@@ -559,51 +556,63 @@ export const Routes = {
* - GET `/oauth2/applications/@me`
*/
oauth2CurrentApplication() {
return `/oauth2/applications/@me`;
return `/oauth2/applications/@me` as const;
},
/**
* Route for:
* - GET `/oauth2/@me`
*/
oauth2CurrentAuthorization() {
return `/oauth2/@me` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands`
* - PUT `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationID: string) {
return `/applications/${applicationID}/commands`;
applicationCommands(applicationID: Snowflake) {
return `/applications/${applicationID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationID: string, commandID: string) {
return `/applications/${applicationID}/commands/${commandID}`;
applicationCommand(applicationID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/commands/${commandID}` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands`
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
*/
applicationGuildCommands(applicationID: string, guildID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands`;
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
applicationGuildCommand(applicationID: string, guildID: string, commandID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`;
applicationGuildCommand(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionID: string, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback`;
interactionCallback(interactionID: Snowflake, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
},
/**
@@ -611,11 +620,58 @@ export const Routes = {
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildID: string) {
return `/guilds/${guildID}/member-verification`;
guildMemberVerification(guildID: Snowflake) {
return `/guilds/${guildID}/member-verification` as const;
},
/**
* 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;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/permissions`
*/
guildApplicationCommandsPermissions(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/permissions` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
* - PUT `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions`
*/
applicationCommandPermissions(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}/permissions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/welcome-screen`
* - PATCH `/guilds/{guild.id}/welcome-screen`
*/
guildWelcomeScreen(guildID: Snowflake) {
return `/guilds/${guildID}/welcome-screen` as const;
},
};
export const RouteBases = {
api: 'https://discord.com/api',
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
gift: 'https://discord.gift',
} as const;
// Freeze bases object
Object.freeze(RouteBases);
export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
@@ -625,8 +681,5 @@ export const OAuth2Routes = {
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
} as const;
/**
* Freeze route object
* @internal
*/
// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);

View File

@@ -1,16 +1,39 @@
import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/index';
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-application-information
*/
export type RESTGetAPIOauth2CurrentApplicationResult = Omit<APIApplication, 'flags'>;
/**
* https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information
*/
export interface RESTGetAPIOauth2CurrentAuthorizationResult {
/**
* the current application
*/
application: Partial<APIApplication>;
/**
* the scopes the user has authorized the application for
*/
scopes: OAuth2Scopes[];
/**
* when the access token expires
*/
expires: string;
/**
* the user who has authorized, if the user has authorized with the `identify` scope
*/
user?: APIUser;
}
/**
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant
*/
export interface RESTOAuth2AuthorizationQuery {
response_type: 'code';
client_id: string;
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
@@ -29,12 +52,11 @@ export interface RESTOAuth2AuthorizationQueryResult {
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*/
export interface RESTPostOAuth2AccessTokenURLEncodedData {
client_id: string;
client_id: Snowflake;
client_secret: string;
grant_type: 'authorization_code';
code: string;
redirect_uri?: string;
scope: string;
}
/**
@@ -52,12 +74,10 @@ export interface RESTPostOAuth2AccessTokenResult {
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
*/
export interface RESTPostOAuth2RefreshTokenURLEncodedData {
client_id: string;
client_id: Snowflake;
client_secret: string;
grant_type: 'refresh_token';
refresh_token: string;
redirect_uri?: string;
scope: string;
}
export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult;
@@ -67,7 +87,7 @@ export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult;
*/
export interface RESTOAuth2ImplicitAuthorizationQuery {
response_type: 'token';
client_id: string;
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
@@ -96,7 +116,7 @@ export interface RESTOAuth2BotAuthorizationQuery {
/**
* Your app's client id
*/
client_id: string;
client_id: Snowflake;
/**
* Needs to include bot for the bot flow
*/
@@ -110,11 +130,11 @@ export interface RESTOAuth2BotAuthorizationQuery {
*
* See https://discord.com/developers/docs/topics/permissions
*/
permissions?: string;
permissions?: Permissions;
/**
* Pre-fills the dropdown picker with a guild for the user
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* `true` or `false`disallows the user from changing the guild dropdown
*/
@@ -125,7 +145,7 @@ export interface RESTOAuth2BotAuthorizationQuery {
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization
*/
export interface RESTOAuth2AdvancedBotAuthorizationQuery {
client_id: string;
client_id: Snowflake;
/**
* This assumes you include the `bot` scope alongside others (like `identify` for example)
*/
@@ -137,8 +157,8 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
/**
* The required permissions bitfield, stringified
*/
permissions?: string;
guild_id?: string;
permissions?: Permissions;
guild_id?: Snowflake;
disable_guild_select?: boolean;
response_type: string;
redirect_uri?: string;
@@ -147,8 +167,8 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
export interface RESTOAuth2AdvancedBotAuthorizationQueryResult {
code: string;
state?: string;
guild_id: string;
permissions: string;
guild_id: Snowflake;
permissions: Permissions;
}
/**

View File

@@ -1,4 +1,4 @@
import type { APIGuild, APITemplate } from '../payloads/mod.ts';
import type { APIGuild, APITemplate } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/template#get-template

View File

@@ -1,4 +1,5 @@
import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../payloads/mod.ts';
import type { Permissions, Snowflake } from '../../globals.ts';
import type { APIChannel, APIConnection, APIUser, GuildFeature } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/user#get-current-user
@@ -36,11 +37,11 @@ export interface RESTGetAPICurrentUserGuildsQuery {
/**
* Get guilds before this guild ID
*/
before?: string;
before?: Snowflake;
/**
* Get guilds after this guild ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of guilds to return (1-100)
*
@@ -50,12 +51,12 @@ export interface RESTGetAPICurrentUserGuildsQuery {
}
export interface RESTAPIPartialCurrentUserGuild {
id: string;
id: Snowflake;
name: string;
icon: string | null;
owner: boolean;
features: GuildFeature[];
permissions: string;
permissions: Permissions;
}
/**

View File

@@ -1,4 +1,4 @@
import type { APIVoiceRegion } from '../payloads/index';
import type { APIVoiceRegion } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/voice#list-voice-regions

View File

@@ -1,4 +1,5 @@
import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../payloads/index';
import type { Snowflake } from '../../globals.ts';
import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../../payloads/v8/mod.ts';
/**
* https://discord.com/developers/docs/resources/webhook#create-webhook
@@ -58,7 +59,7 @@ export interface RESTPatchAPIWebhookJSONBody {
/**
* The new channel id this webhook should be moved to
*/
channel_id?: string;
channel_id?: Snowflake;
}
/**
@@ -206,11 +207,36 @@ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = Nullable<
Pick<RESTPostAPIWebhookWithTokenJSONBody, 'content' | 'embeds' | 'allowed_mentions'>
>;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageFormDataBody =
| {
payload_json: string;
/**
* JSON stringified message body
*/
payload_json?: string;
/**
* The file contents
*/
file: unknown;
}
| RESTPatchAPIWebhookWithTokenMessageJSONBody;
| (RESTPatchAPIWebhookWithTokenMessageJSONBody & {
/**
* The file contents
*/
file: unknown;
});
/**
* https://discord.com/developers/docs/resources/webhook#get-webhook-message
*/
export type RESTGetAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
*/
export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/webhook#delete-webhook-message

4
deno/rpc/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the types available in the recommended API version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';

33
deno/rpc/v8.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes
*/
export enum RPCErrorCodes {
UnknownError = 1000,
InvalidPayload = 4000,
InvalidCommand = 4002,
InvalidGuild,
InvalidEvent,
InvalidChannel,
InvalidPermissions,
InvalidClientID,
InvalidOrigin,
InvalidToken,
InvalidUser,
OAuth2Error = 5000,
SelectChannelTimedOut,
GetGuildTimedOut,
SelectVoiceForceRequired,
CaptureShortcutAlreadyListening,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
*/
export enum RPCCloseEventCodes {
InvalidClientID = 4000,
InvalidOrigin,
RateLimited,
TokenRevoked,
InvalidVersion,
InvalidEncoding,
}

4
deno/utils/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the utility functions available in the recommended API / Gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8.ts';

48
deno/utils/v8.ts Normal file
View File

@@ -0,0 +1,48 @@
import {
APIApplicationCommandDMInteraction,
APIApplicationCommandGuildInteraction,
APIApplicationCommandInteraction,
APIDMInteraction,
APIGuildInteraction,
APIInteraction,
} from '../payloads/v8/mod.ts';
/**
* A type-guard check for guild interactions.
* @param interaction The interaction to check against the
* @returns A boolean that indicates if the interaction was received from a guild
*/
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
return Reflect.has(interaction, 'guild_id');
}
/**
* A type-guard check for DM interactions.
* @param interaction The interaction to check against
* @returns A boolean that indicates if the interaction was received from a direct message
*/
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
return !isGuildInteraction(interaction);
}
/**
* A type-guard check for guild application command interactions.
* @param interaction The interaction to check against
* @returns A boolean that indicates if the command interaction was received from a guild
*/
export function isApplicationCommandGuildInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandGuildInteraction {
return isGuildInteraction(interaction);
}
/**
* A type-guard check for direct message application command interactions.
* @param interaction The interaction to check against
* @returns A boolean that indicates if the command interaction was received from a direct message
*/
export function isApplicationCommandDMInteraction(
interaction: APIApplicationCommandInteraction,
): interaction is APIApplicationCommandDMInteraction {
return !isGuildInteraction(interaction);
}

4
deno/v6.ts Normal file
View File

@@ -0,0 +1,4 @@
export * from './globals.ts';
export * from './gateway/v6.ts';
export * from './payloads/v6/mod.ts';
export * from './rest/v6/mod.ts';

6
deno/v8.ts Normal file
View File

@@ -0,0 +1,6 @@
export * from './globals.ts';
export * from './gateway/v8.ts';
export * from './payloads/v8/mod.ts';
export * from './rest/v8/mod.ts';
export * from './rpc/v8.ts';
export * as Utils from './utils/v8.ts';

4
deno/voice/mod.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the types available in the recommended voice gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v4.ts';

109
deno/voice/v4.ts Normal file
View File

@@ -0,0 +1,109 @@
export const VoiceGatewayVersion = '4';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
*/
export enum VoiceOPCodes {
/**
* Begin a voice websocket connection
*/
Identify,
/**
* Select the voice protocol
*/
SelectProtocol,
/**
* Complete the websocket handshake
*/
Ready,
/**
* Keep the websocket connection alive
*/
Heartbeat,
/**
* Describe the session
*/
SessionDescription,
/**
* Indicate which users are speaking
*/
Speaking,
/**
* Sent to acknowledge a received client heartbeat
*/
HeartbeatAck,
/**
* Resume a connection
*/
Resume,
/**
* Time to wait between sending heartbeats in milliseconds
*/
Hello,
/**
* Acknowledge a successful session resume
*/
Resumed,
/**
* A client has connected to the voice channel
*/
ClientConnect = 12,
/**
* A client has disconnected from the voice channel
*/
ClientDisconnect,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
*/
export enum VoiceCloseCodes {
/**
* You sent an invalid opcode
*/
UnknownOpCode = 4001,
/**
* You sent a invalid payload in your identifying to the Gateway
*/
FailedToDecode,
/**
* You sent a payload before identifying with the Gateway
*/
NotAuthenticated,
/**
* The token you sent in your identify payload is incorrect
*/
AuthenticationFailed,
/**
* You sent more than one identify payload. Stahp
*/
AlreadyAuthenticated,
/**
* Your session is no longer valid
*/
SessionNoLongerValid,
/**
* Your session has timed out
*/
SessionTimeout = 4009,
/**
* We can't find the server you're trying to connect to
*/
ServerNotFound = 4011,
/**
* We didn't recognize the protocol you sent
*/
UnknownProtocol,
/**
* Either the channel was deleted, you were kicked, or the main gateway session was dropped. Should not reconnect
*/
Disconnected = 4014,
/**
* The server crashed. Our bad! Try resuming
*/
VoiceServerCrashed,
/**
* We didn't recognize your encryption
*/
UnknownEncryptionMode,
}

8
gateway/common.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* https://discord.com/developers/docs/topics/gateway#connecting-gateway-url-params
*/
export interface GatewayURLQuery {
v: string;
encoding: 'json' | 'etf';
compress?: 'zlib-stream';
}

4
gateway/index.ts Normal file
View File

@@ -0,0 +1,4 @@
// This file exports all the types available in the recommended gateway version
// Thereby, things MAY break in the future. Try sticking to imports from a specific version
export * from './v8';

View File

@@ -16,7 +16,9 @@ import type {
GatewayVoiceState,
InviteTargetUserType,
PresenceUpdateStatus,
} from '../payloads/index';
} from '../payloads/v6/index';
export * from './common';
/**
* @deprecated Gateway v6 is deprecated and the types will not receive further updates, please update to v8.

View File

@@ -2,10 +2,15 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../globals';
import type {
APIApplication,
APIApplicationCommand,
APIApplicationCommandInteraction,
APIChannel,
APIEmoji,
APIGuild,
APIGuildIntegration,
APIGuildMember,
APIMessage,
APIRole,
@@ -14,11 +19,11 @@ import type {
GatewayActivity,
GatewayPresenceUpdate as RawGatewayPresenceUpdate,
GatewayVoiceState,
InviteTargetUserType,
InviteTargetType,
PresenceUpdateStatus,
APIApplicationCommandInteraction,
APIApplication,
} from '../payloads/mod.ts';
} from '../payloads/v8/index';
export * from './common';
export const GatewayVersion = '8';
@@ -31,7 +36,8 @@ export const enum GatewayOPCodes {
*/
Dispatch,
/**
* Fired periodically by the client to keep the connection alive
* A bidirectional opcode to maintain an active gateway connection.
* Fired periodically by the client, or fired by the gateway to request an immediate heartbeat from the client.
*/
Heartbeat,
/**
@@ -155,114 +161,6 @@ export const enum GatewayCloseCodes {
DisallowedIntents,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
*/
export const enum VoiceOPCodes {
/**
* Begin a voice websocket connection
*/
Identify,
/**
* Select the voice protocol
*/
SelectProtocol,
/**
* Complete the websocket handshake
*/
Ready,
/**
* Keep the websocket connection alive
*/
Heartbeat,
/**
* Describe the session
*/
SessionDescription,
/**
* Indicate which users are speaking
*/
Speaking,
/**
* Sent to acknowledge a received client heartbeat
*/
HeartbeatAck,
/**
* Resume a connection
*/
Resume,
/**
* Time to wait between sending heartbeats in milliseconds
*/
Hello,
/**
* Acknowledge a successful session resume
*/
Resumed,
/**
* A client has connected to the voice channel
*/
ClientConnect = 12,
/**
* A client has disconnected from the voice channel
*/
ClientDisconnect,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
*/
export const enum VoiceCloseCodes {
/**
* You sent an invalid opcode
*/
UnknownOpCode = 4001,
/**
* You sent a invalid payload in your identifying to the Gateway
*/
FailedToDecode,
/**
* You sent a payload before identifying with the Gateway
*/
NotAuthenticated,
/**
* The token you sent in your identify payload is incorrect
*/
AuthenticationFailed,
/**
* You sent more than one identify payload. Stahp
*/
AlreadyAuthenticated,
/**
* Your session is no longer valid
*/
SessionNoLongerValid,
/**
* Your session has timed out
*/
SessionTimeout = 4009,
/**
* We can't find the server you're trying to connect to
*/
ServerNotFound = 4011,
/**
* We didn't recognize the protocol you sent
*/
UnknownProtocol,
/**
* Either the channel was deleted or you were kicked. Should not reconnect
*/
Disconnected = 4014,
/**
* The server crashed. Our bad! Try resuming
*/
VoiceServerCrashed,
/**
* We didn't recognize your encryption
*/
UnknownEncryptionMode,
}
/**
* https://discord.com/developers/docs/topics/gateway#list-of-intents
*/
@@ -288,42 +186,48 @@ export const enum GatewayIntentBits {
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export const enum GatewayDispatchEvents {
Ready = 'READY',
Resumed = 'RESUMED',
ApplicationCommandCreate = 'APPLICATION_COMMAND_CREATE',
ApplicationCommandDelete = 'APPLICATION_COMMAND_DELETE',
ApplicationCommandUpdate = 'APPLICATION_COMMAND_UPDATE',
ChannelCreate = 'CHANNEL_CREATE',
ChannelUpdate = 'CHANNEL_UPDATE',
ChannelDelete = 'CHANNEL_DELETE',
ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE',
GuildCreate = 'GUILD_CREATE',
GuildUpdate = 'GUILD_UPDATE',
GuildDelete = 'GUILD_DELETE',
ChannelUpdate = 'CHANNEL_UPDATE',
GuildBanAdd = 'GUILD_BAN_ADD',
GuildBanRemove = 'GUILD_BAN_REMOVE',
GuildCreate = 'GUILD_CREATE',
GuildDelete = 'GUILD_DELETE',
GuildEmojisUpdate = 'GUILD_EMOJIS_UPDATE',
GuildIntegrationsUpdate = 'GUILD_INTEGRATIONS_UPDATE',
GuildMemberAdd = 'GUILD_MEMBER_ADD',
GuildMemberRemove = 'GUILD_MEMBER_REMOVE',
GuildMemberUpdate = 'GUILD_MEMBER_UPDATE',
GuildMembersChunk = 'GUILD_MEMBERS_CHUNK',
GuildMemberUpdate = 'GUILD_MEMBER_UPDATE',
GuildRoleCreate = 'GUILD_ROLE_CREATE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildRoleDelete = 'GUILD_ROLE_DELETE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildUpdate = 'GUILD_UPDATE',
IntegrationCreate = 'INTEGRATION_CREATE',
IntegrationDelete = 'INTEGRATION_DELETE',
IntegrationUpdate = 'INTEGRATION_UPDATE',
InteractionCreate = 'INTERACTION_CREATE',
InviteCreate = 'INVITE_CREATE',
InviteDelete = 'INVITE_DELETE',
MessageCreate = 'MESSAGE_CREATE',
MessageUpdate = 'MESSAGE_UPDATE',
MessageDelete = 'MESSAGE_DELETE',
MessageDeleteBulk = 'MESSAGE_DELETE_BULK',
MessageReactionAdd = 'MESSAGE_REACTION_ADD',
MessageReactionRemove = 'MESSAGE_REACTION_REMOVE',
MessageReactionRemoveAll = 'MESSAGE_REACTION_REMOVE_ALL',
MessageReactionRemoveEmoji = 'MESSAGE_REACTION_REMOVE_EMOJI',
MessageUpdate = 'MESSAGE_UPDATE',
PresenceUpdate = 'PRESENCE_UPDATE',
Ready = 'READY',
Resumed = 'RESUMED',
TypingStart = 'TYPING_START',
UserUpdate = 'USER_UPDATE',
VoiceStateUpdate = 'VOICE_STATE_UPDATE',
VoiceServerUpdate = 'VOICE_SERVER_UPDATE',
VoiceStateUpdate = 'VOICE_STATE_UPDATE',
WebhooksUpdate = 'WEBHOOKS_UPDATE',
}
@@ -344,41 +248,95 @@ export type GatewayReceivePayload =
| GatewayDispatchPayload;
export type GatewayDispatchPayload =
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayChannelModifyDispatch
| GatewayChannelPinsUpdateDispatch
| GatewayGuildModifyDispatch
| GatewayGuildDeleteDispatch
| GatewayGuildBanModifyDispatch
| GatewayGuildDeleteDispatch
| GatewayGuildEmojisUpdateDispatch
| GatewayGuildIntegrationsUpdateDispatch
| GatewayGuildMemberAddDispatch
| GatewayGuildMemberRemoveDispatch
| GatewayGuildMemberUpdateDispatch
| GatewayGuildMembersChunkDispatch
| GatewayGuildRoleModifyDispatch
| GatewayGuildMemberUpdateDispatch
| GatewayGuildModifyDispatch
| GatewayGuildRoleDeleteDispatch
| GatewayGuildRoleModifyDispatch
| GatewayIntegrationCreateDispatch
| GatewayIntegrationDeleteDispatch
| GatewayIntegrationUpdateDispatch
| GatewayInteractionCreateDispatch
| GatewayInviteCreateDispatch
| GatewayInviteDeleteDispatch
| GatewayMessageCreateDispatch
| GatewayMessageUpdateDispatch
| GatewayMessageDeleteDispatch
| GatewayMessageDeleteBulkDispatch
| GatewayMessageDeleteDispatch
| GatewayMessageReactionAddDispatch
| GatewayMessageReactionRemoveDispatch
| GatewayMessageReactionRemoveAllDispatch
| GatewayMessageReactionRemoveDispatch
| GatewayMessageReactionRemoveEmojiDispatch
| GatewayMessageUpdateDispatch
| GatewayPresenceUpdateDispatch
| GatewayReadyDispatch
| GatewayResumedDispatch
| GatewayTypingStartDispatch
| GatewayUserUpdateDispatch
| GatewayVoiceStateUpdateDispatch
| GatewayVoiceServerUpdateDispatch
| GatewayVoiceStateUpdateDispatch
| GatewayWebhooksUpdateDispatch;
// #region Dispatch Payloads
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandModifyDispatch = DataPayload<
| GatewayDispatchEvents.ApplicationCommandCreate
| GatewayDispatchEvents.ApplicationCommandUpdate
| GatewayDispatchEvents.ApplicationCommandDelete,
GatewayApplicationCommandModifyDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
* https://discord.com/developers/docs/topics/gateway#application-command-update
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
guild_id?: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
*/
export type GatewayApplicationCommandCreateDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-create
*/
export type GatewayApplicationCommandCreateDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-update
*/
export type GatewayApplicationCommandUpdateDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-update
*/
export type GatewayApplicationCommandUpdateDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandDeleteDispatch = GatewayApplicationCommandModifyDispatch;
/**
* https://discord.com/developers/docs/topics/gateway#application-command-delete
*/
export type GatewayApplicationCommandDeleteDispatchData = GatewayApplicationCommandModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#hello
*/
@@ -455,10 +413,6 @@ export interface GatewayReadyDispatchData {
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: APIUser;
/**
* Empty array
*/
private_channels: [];
/**
* The guilds the user is in
*
@@ -550,11 +504,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The time at which the most recent pinned message was pinned
*/
@@ -623,7 +577,7 @@ export interface GatewayGuildBanModifyDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The banned user
*
@@ -667,7 +621,7 @@ export interface GatewayGuildEmojisUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Array of emojis
*
@@ -691,7 +645,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData {
/**
* ID of the guild whose integrations were updated
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -709,7 +663,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -727,7 +681,7 @@ export interface GatewayGuildMemberRemoveDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The user who was removed
*
@@ -747,12 +701,14 @@ export type GatewayGuildMemberUpdateDispatch = DataPayload<
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute'> & {
/**
* The id of the guild
*/
guild_id: string;
};
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute' | 'user'> &
Partial<Pick<APIGuildMember, 'deaf' | 'mute'>> &
Required<Pick<APIGuildMember, 'user'>> & {
/**
* The id of the guild
*/
guild_id: Snowflake;
};
/**
* https://discord.com/developers/docs/topics/gateway#guild-members-chunk
@@ -769,7 +725,7 @@ export interface GatewayGuildMembersChunkDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Set of guild members
*
@@ -819,7 +775,7 @@ export interface GatewayGuildRoleModifyDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The role created or updated
*
@@ -863,11 +819,63 @@ export interface GatewayGuildRoleDeleteDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the role
*/
role_id: string;
role_id: Snowflake;
}
/**
* https://discord.com/developers/docs/topics/gateway#integration-create
*/
export type GatewayIntegrationCreateDispatch = DataPayload<
GatewayDispatchEvents.IntegrationCreate,
GatewayIntegrationCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-create
*/
export type GatewayIntegrationCreateDispatchData = APIGuildIntegration & { guild_id: Snowflake };
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationUpdateDispatch = DataPayload<
GatewayDispatchEvents.IntegrationUpdate,
GatewayIntegrationUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationUpdateDispatchData = APIGuildIntegration & { guild_id: Snowflake };
/**
* https://discord.com/developers/docs/topics/gateway#integration-update
*/
export type GatewayIntegrationDeleteDispatch = DataPayload<
GatewayDispatchEvents.IntegrationDelete,
GatewayIntegrationDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#integration-delete
*/
export interface GatewayIntegrationDeleteDispatchData {
/**
* Integration id
*/
id: Snowflake;
/**
* ID of the guild
*/
guild_id: Snowflake;
/**
* ID of the bot/OAuth2 application for this Discord integration
*/
application_id?: Snowflake;
}
/**
@@ -898,7 +906,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The channel the invite is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The unique invite code
*
@@ -912,7 +920,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The user that created the invite
*
@@ -928,17 +936,21 @@ export interface GatewayInviteCreateDispatchData {
*/
max_uses: number;
/**
* The target user for this invite
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
target_type?: InviteTargetType;
/**
* The user whose stream to display for this voice channel stream invite
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
target_user?: APIUser;
/**
* The type of user target for this invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
* The embedded application to open for this voice channel embedded application invite
*/
target_user_type?: InviteTargetUserType;
target_application?: Partial<APIApplication>;
/**
* Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role)
*/
@@ -964,11 +976,11 @@ export interface GatewayInviteDeleteDispatchData {
/**
* The channel of the invite
*/
channel_id: string;
channel_id: Snowflake;
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The unique invite code
*
@@ -1002,8 +1014,8 @@ export type GatewayMessageUpdateDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatchData = {
id: string;
channel_id: string;
id: Snowflake;
channel_id: Snowflake;
} & Partial<APIMessage>;
/**
@@ -1021,15 +1033,15 @@ export interface GatewayMessageDeleteDispatchData {
/**
* The id of the message
*/
id: string;
id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1047,15 +1059,15 @@ export interface GatewayMessageDeleteBulkDispatchData {
/**
* The ids of the messages
*/
ids: string[];
ids: Snowflake[];
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1134,15 +1146,15 @@ export interface GatewayTypingStartDispatchData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* Unix time (in seconds) of when the user started typing
*/
@@ -1197,11 +1209,15 @@ export interface GatewayVoiceServerUpdateDispatchData {
/**
* The guild this voice server update is for
*/
guild_id: string;
guild_id: Snowflake;
/**
* The voice server host
*
* A `null` endpoint means that the voice server allocated has gone away and is trying to be reallocated.
* You should attempt to disconnect from the currently connected voice server, and not attempt to reconnect
* until a new voice server is allocated
*/
endpoint: string;
endpoint: string | null;
}
/**
@@ -1219,11 +1235,11 @@ export interface GatewayWebhooksUpdateDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
}
// #endregion Dispatch Payloads
@@ -1290,13 +1306,6 @@ export interface GatewayIdentifyData {
* See https://discord.com/developers/docs/topics/gateway#update-status
*/
presence?: GatewayPresenceUpdateData;
/**
* Enables dispatching of guild subscription events (presence and typing events)
*
* @default true
* @deprecated Use `intents` instead
*/
guild_subscriptions?: boolean;
/**
* The Gateway Intents you wish to receive
*
@@ -1364,7 +1373,7 @@ export interface GatewayRequestGuildMembersData {
/**
* ID of the guild to get members for
*/
guild_id: string | string[];
guild_id: Snowflake;
/**
* String that username starts with, or an empty string to return all members
*/
@@ -1381,10 +1390,12 @@ export interface GatewayRequestGuildMembersData {
/**
* Used to specify which users you wish to fetch
*/
user_ids?: string | string[];
user_ids?: Snowflake | Snowflake[];
/**
* Nonce to identify the Guild Members Chunk response
*
* Nonce can only be up to 32 bytes. If you send an invalid nonce it will be ignored and the reply member_chunk(s) will not have a `nonce` set.
*
* See https://discord.com/developers/docs/topics/gateway#guild-members-chunk
*/
nonce?: string;
@@ -1405,11 +1416,11 @@ export interface GatewayVoiceStateUpdateData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* ID of the voice channel client wants to join (`null` if disconnecting)
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* Is the client muted
*/
@@ -1437,11 +1448,11 @@ export interface GatewayPresenceUpdateData {
*/
since: number | null;
/**
* `null`, or the user's activities
* The user's activities
*
* See https://discord.com/developers/docs/topics/gateway#activity-object
*/
activities: GatewayActivityUpdateData[] | null;
activities: GatewayActivityUpdateData[];
/**
* The user's new status
*
@@ -1496,19 +1507,19 @@ type ReactionData<E extends GatewayDispatchEvents, O extends string = never> = D
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The member who reacted if this happened in a guild
*
@@ -1530,14 +1541,14 @@ interface MessageReactionRemoveData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
// #endregion Shared

70
globals.ts Normal file
View File

@@ -0,0 +1,70 @@
/**
* https://discord.com/developers/docs/reference#snowflakes
*/
export type Snowflake = `${bigint}`;
/**
* https://discord.com/developers/docs/topics/permissions
* @internal
*/
export type Permissions = `${bigint}`;
/**
* https://discord.com/developers/docs/reference#message-formatting-formats
*/
export const FormattingPatterns = {
/**
* Regular expression for matching a user mention, strictly without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
User: /<@(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, strictly with a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithNickname: /<@!(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, with or without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithOptionalNickname: /<@!?(?<id>\d{17,20})>/,
/**
* Regular expression for matching a channel mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Channel: /<#(?<id>\d{17,20})>/,
/**
* Regular expression for matching a role mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Role: /<@&(?<id>\d{17,20})>/,
/**
* Regular expression for matching a custom emoji, either static or animated
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
Emoji: /<(?<animated>a)?:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly an animated custom emoji
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
AnimatedEmoji: /<(?<animated>a):(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly a static custom emoji
*
* The `name` and `id` group properties are present on the `exec` result of this expression
*/
StaticEmoji: /<:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
} as const;
/**
* Freezes the formatting patterns
* @internal
*/
Object.freeze(FormattingPatterns);

Some files were not shown because too many files have changed in this diff Show More