mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-22 03:10:13 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc4b7e2708 | ||
|
|
15c171c558 | ||
|
|
ebd5754242 | ||
|
|
ffcd95d597 | ||
|
|
2636bd0949 | ||
|
|
ceb787ba36 | ||
|
|
ca61396577 | ||
|
|
0582f883c5 | ||
|
|
9d8d090c9c | ||
|
|
eb3f8e1dea | ||
|
|
24155aeb71 | ||
|
|
76651acd49 | ||
|
|
92f76f1a3c | ||
|
|
0f29b32e05 | ||
|
|
7343fabe82 | ||
|
|
d0b3106758 | ||
|
|
eafe7ba96f | ||
|
|
ff761755a6 | ||
|
|
ae1900dc2f | ||
|
|
466fa95b0e | ||
|
|
70bfe9f4aa | ||
|
|
63096d807d | ||
|
|
855f36d930 | ||
|
|
3bf9738a72 | ||
|
|
4e4a084003 | ||
|
|
75ed123018 | ||
|
|
5826da22e3 | ||
|
|
da2c2e9ada | ||
|
|
4c77a5d90a | ||
|
|
84759d19bc |
76
.github/CODE_OF_CONDUCT.md
vendored
Normal file
76
.github/CODE_OF_CONDUCT.md
vendored
Normal 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
91
.github/COMMIT_CONVENTION.md
vendored
Normal 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
53
.github/CONTRIBUTING.md
vendored
Normal 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
25
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal 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
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal 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.
|
||||
21
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal 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
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal 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
8
.github/SUPPORT.md
vendored
Normal 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.
|
||||
@@ -1,22 +1,47 @@
|
||||
name: Deno Deploy
|
||||
name: Continuous Integration / Deployment
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
BuildDeno:
|
||||
name: Publish Deno Types
|
||||
testing:
|
||||
name: ESLint and TypeScript compilation
|
||||
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@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@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
42
.github/workflows/codequality.yml
vendored
42
.github/workflows/codequality.yml
vendored
@@ -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
|
||||
4
.npmrc
Normal file
4
.npmrc
Normal file
@@ -0,0 +1,4 @@
|
||||
audit=false
|
||||
fund=false
|
||||
node-version=false
|
||||
legacy-peer-deps=true
|
||||
8
.prettierrc.json
Normal file
8
.prettierrc.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"quoteProps": "as-needed",
|
||||
"trailingComma": "all",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"files.eol": "\n"
|
||||
}
|
||||
"files.eol": "\n",
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
||||
21
README.md
21
README.md
@@ -34,19 +34,13 @@ import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api
|
||||
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/mod.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';
|
||||
```
|
||||
@@ -81,18 +75,7 @@ The exports of each API version is split into three main parts:
|
||||
|
||||
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.
|
||||
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');
|
||||
|
||||
@@ -30,6 +30,10 @@ export const enum RESTJSONErrorCodes {
|
||||
|
||||
UnknownRedistributable = 10036,
|
||||
|
||||
UnknownGuildTemplate = 10057,
|
||||
|
||||
UnknownApplicationCommand = 10063,
|
||||
|
||||
BotsCannotUseThisEndpoint = 20001,
|
||||
OnlyBotsCanUseThisEndpoint,
|
||||
|
||||
@@ -87,6 +91,8 @@ export const enum RESTJSONErrorCodes {
|
||||
CannotExecuteActionOnThisChannelType = 50024,
|
||||
InvalidOauth2AccessToken,
|
||||
|
||||
InvalidWebhookToken = 50027,
|
||||
|
||||
InvalidRecipients = 50033,
|
||||
OneOfTheMessagesProvidedWasTooOldForBulkDelete,
|
||||
InvalidFormBodyOrContentType,
|
||||
@@ -158,3 +164,63 @@ export type Snowflake = `${bigint}`;
|
||||
* @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);
|
||||
|
||||
@@ -34,19 +34,13 @@ import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api
|
||||
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/mod.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';
|
||||
```
|
||||
@@ -81,18 +75,7 @@ The exports of each API version is split into three main parts:
|
||||
|
||||
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.
|
||||
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');
|
||||
|
||||
@@ -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,10 @@ export const enum RESTJSONErrorCodes {
|
||||
|
||||
UnknownRedistributable = 10036,
|
||||
|
||||
UnknownGuildTemplate = 10057,
|
||||
|
||||
UnknownApplicationCommand = 10063,
|
||||
|
||||
BotsCannotUseThisEndpoint = 20001,
|
||||
OnlyBotsCanUseThisEndpoint,
|
||||
|
||||
@@ -87,6 +91,8 @@ export const enum RESTJSONErrorCodes {
|
||||
CannotExecuteActionOnThisChannelType = 50024,
|
||||
InvalidOauth2AccessToken,
|
||||
|
||||
InvalidWebhookToken = 50027,
|
||||
|
||||
InvalidRecipients = 50033,
|
||||
OneOfTheMessagesProvidedWasTooOldForBulkDelete,
|
||||
InvalidFormBodyOrContentType,
|
||||
@@ -108,7 +114,7 @@ export const enum RESTJSONErrorCodes {
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes
|
||||
*/
|
||||
export const enum RPCErrorCodes {
|
||||
export enum RPCErrorCodes {
|
||||
UnknownError = 1000,
|
||||
InvalidPayload = 4000,
|
||||
InvalidCommand = 4002,
|
||||
@@ -130,7 +136,7 @@ export const enum RPCErrorCodes {
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
|
||||
*/
|
||||
export const enum RPCCloseEventCodes {
|
||||
export enum RPCCloseEventCodes {
|
||||
InvalidClientID = 4000,
|
||||
InvalidOrigin,
|
||||
RateLimited,
|
||||
@@ -158,3 +164,63 @@ export type Snowflake = `${bigint}`;
|
||||
* @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);
|
||||
|
||||
@@ -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';
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
import type { Snowflake } from '../../common/mod.ts';
|
||||
import type {
|
||||
APIApplication,
|
||||
APIApplicationCommand,
|
||||
APIApplicationCommandInteraction,
|
||||
APIChannel,
|
||||
APIEmoji,
|
||||
APIGuild,
|
||||
@@ -17,8 +20,6 @@ import type {
|
||||
GatewayVoiceState,
|
||||
InviteTargetUserType,
|
||||
PresenceUpdateStatus,
|
||||
APIApplicationCommandInteraction,
|
||||
APIApplication,
|
||||
} from '../payloads/mod.ts';
|
||||
|
||||
export const GatewayVersion = '8';
|
||||
@@ -26,13 +27,14 @@ 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,
|
||||
/**
|
||||
@@ -76,7 +78,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?
|
||||
*/
|
||||
@@ -159,7 +161,7 @@ export const enum GatewayCloseCodes {
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
|
||||
*/
|
||||
export const enum VoiceOPCodes {
|
||||
export enum VoiceOPCodes {
|
||||
/**
|
||||
* Begin a voice websocket connection
|
||||
*/
|
||||
@@ -213,7 +215,7 @@ export const enum VoiceOPCodes {
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
|
||||
*/
|
||||
export const enum VoiceCloseCodes {
|
||||
export enum VoiceCloseCodes {
|
||||
/**
|
||||
* You sent an invalid opcode
|
||||
*/
|
||||
@@ -267,7 +269,7 @@ export const enum VoiceCloseCodes {
|
||||
/**
|
||||
* 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,
|
||||
@@ -288,43 +290,46 @@ 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',
|
||||
ApplicationCommandUpdate = 'APPLICATION_COMMAND_UPDATE',
|
||||
ApplicationCommandDelete = 'APPLICATION_COMMAND_DELETE',
|
||||
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',
|
||||
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',
|
||||
}
|
||||
|
||||
@@ -345,41 +350,92 @@ 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
|
||||
| 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
|
||||
*/
|
||||
|
||||
@@ -92,7 +92,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,
|
||||
@@ -223,7 +223,7 @@ export interface APIAuditLogOptions {
|
||||
role_name?: string;
|
||||
}
|
||||
|
||||
export const enum AuditLogOptionsType {
|
||||
export enum AuditLogOptionsType {
|
||||
Role = '0',
|
||||
Member = '1',
|
||||
}
|
||||
@@ -233,12 +233,18 @@ export const enum AuditLogOptionsType {
|
||||
*/
|
||||
export type APIAuditLogChange =
|
||||
| APIAuditLogChangeKeyName
|
||||
| APIAuditLogChangeKeyDescription
|
||||
| APIAuditLogChangeKeyIconHash
|
||||
| APIAuditLogChangeKeySplashHash
|
||||
| APIAuditLogChangeKeyDiscoverySplashHash
|
||||
| APIAuditLogChangeKeyBannerHash
|
||||
| APIAuditLogChangeKeyOwnerID
|
||||
| APIAuditLogChangeKeyRegion
|
||||
| APIAuditLogChangeKeyPreferredLocale
|
||||
| APIAuditLogChangeKeyAFKChannelID
|
||||
| APIAuditLogChangeKeyAFKTimeout
|
||||
| APIAuditLogChangeKeyRulesChannelID
|
||||
| APIAuditLogChangeKeyPublicUpdatesChannelID
|
||||
| APIAuditLogChangeKeyMFALevel
|
||||
| APIAuditLogChangeKeyVerificationLevel
|
||||
| APIAuditLogChangeKeyExplicitContentFilter
|
||||
@@ -278,13 +284,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
|
||||
*/
|
||||
@@ -296,7 +308,17 @@ 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 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>;
|
||||
|
||||
@@ -305,6 +327,11 @@ export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowfla
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -315,6 +342,16 @@ export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_i
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -523,10 +560,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;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import type { Permissions, Snowflake } from '../../common/mod.ts';
|
||||
import type { APIPartialEmoji } from './emoji.ts';
|
||||
import type { APIGuildMember } from './guild.ts';
|
||||
import type { APIMessageInteraction } from './interactions.ts';
|
||||
import type { APIRole } from './permissions.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
|
||||
@@ -103,7 +104,7 @@ export interface APIChannel extends APIPartialChannel {
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
||||
*/
|
||||
export const enum ChannelType {
|
||||
export enum ChannelType {
|
||||
/**
|
||||
* A text channel within a guild
|
||||
*/
|
||||
@@ -307,12 +308,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,
|
||||
@@ -399,7 +404,7 @@ export interface APIMessageReference {
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
|
||||
*/
|
||||
export const enum MessageActivityType {
|
||||
export enum MessageActivityType {
|
||||
JOIN = 1,
|
||||
SPECTATE,
|
||||
LISTEN,
|
||||
@@ -409,7 +414,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)
|
||||
*/
|
||||
@@ -476,7 +481,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,
|
||||
@@ -548,7 +553,7 @@ export interface APIOverwrite {
|
||||
deny: Permissions;
|
||||
}
|
||||
|
||||
export const enum OverwriteType {
|
||||
export enum OverwriteType {
|
||||
Role,
|
||||
Member,
|
||||
}
|
||||
@@ -641,7 +646,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
|
||||
*/
|
||||
@@ -871,7 +876,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
|
||||
*/
|
||||
|
||||
@@ -91,7 +91,7 @@ export interface GatewayPresenceUpdate {
|
||||
client_status?: GatewayPresenceClientStatus;
|
||||
}
|
||||
|
||||
export const enum PresenceUpdateStatus {
|
||||
export enum PresenceUpdateStatus {
|
||||
Online = 'online',
|
||||
DoNotDisturb = 'dnd',
|
||||
Idle = 'idle',
|
||||
@@ -213,7 +213,7 @@ export enum ActivityPlatform {
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
|
||||
*/
|
||||
export const enum ActivityType {
|
||||
export enum ActivityType {
|
||||
/**
|
||||
* Playing {game}
|
||||
*/
|
||||
@@ -288,7 +288,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,
|
||||
|
||||
@@ -302,7 +302,7 @@ export interface APIGuild extends APIPartialGuild {
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
|
||||
*/
|
||||
export const enum GuildDefaultMessageNotifications {
|
||||
export enum GuildDefaultMessageNotifications {
|
||||
ALL_MESSAGES,
|
||||
ONLY_MENTIONS,
|
||||
}
|
||||
@@ -310,7 +310,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,
|
||||
@@ -319,7 +319,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,
|
||||
}
|
||||
@@ -327,7 +327,7 @@ export const enum GuildMFALevel {
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-object-verification-level
|
||||
*/
|
||||
export const enum GuildVerificationLevel {
|
||||
export enum GuildVerificationLevel {
|
||||
/**
|
||||
* Unrestricted
|
||||
*/
|
||||
@@ -353,7 +353,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,
|
||||
@@ -363,7 +363,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
|
||||
*/
|
||||
@@ -377,7 +377,7 @@ export const enum GuildSystemChannelFlags {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -658,7 +658,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,
|
||||
}
|
||||
@@ -762,7 +762,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
|
||||
*/
|
||||
@@ -848,7 +848,7 @@ export interface APIGuildMembershipScreeningField {
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
export const enum MembershipScreeningFieldType {
|
||||
export enum MembershipScreeningFieldType {
|
||||
/**
|
||||
* Server Rules
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Permissions, Snowflake } from '../../common/mod.ts';
|
||||
import type { APIGuildMember, APIUser, MessageFlags } from './mod.ts';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/mod.ts';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './mod.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
@@ -46,7 +46,7 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
/**
|
||||
* 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,
|
||||
* 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'> {
|
||||
@@ -57,7 +57,7 @@ export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicatio
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||
*/
|
||||
export const enum ApplicationCommandOptionType {
|
||||
export enum ApplicationCommandOptionType {
|
||||
SUB_COMMAND = 1,
|
||||
SUB_COMMAND_GROUP,
|
||||
STRING,
|
||||
@@ -79,26 +79,80 @@ export interface APIApplicationCommandOptionChoice {
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIInteraction {
|
||||
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;
|
||||
guild_id: Snowflake;
|
||||
channel_id: Snowflake;
|
||||
member: APIGuildMember & { permissions: Permissions; user: APIUser };
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like See APIInteraction, only with the `data` property always present
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
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 {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id?: never;
|
||||
/**
|
||||
* 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 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 {
|
||||
export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
}
|
||||
@@ -110,72 +164,147 @@ 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 interface APIApplicationCommandInteractionDataOption {
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
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[];
|
||||
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-interaction-response
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseAcknowledge
|
||||
| APIInteractionResponseAcknowledgeWithSource
|
||||
| APIInteractionResponseChannelMessage
|
||||
| APIInteractionResponseChannelMessageWithSource;
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource;
|
||||
|
||||
export type APIInteractionResponsePong = InteractionResponsePayload<APIInteractionResponseType.Pong>;
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export type APIInteractionResponseAcknowledge = InteractionResponsePayload<APIInteractionResponseType.Acknowledge>;
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
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,
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionapplicationcommandcallbackdata
|
||||
* 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 InteractionResponsePayload<T extends APIInteractionResponseType, D = false> {
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
data?: D extends true ? APIInteractionApplicationCommandCallbackData : never;
|
||||
value: D;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export interface APIInvite {
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
|
||||
*/
|
||||
export const enum InviteTargetUserType {
|
||||
export enum InviteTargetUserType {
|
||||
STREAM = 1,
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,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,
|
||||
GatewayPresenceLimit = 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
|
||||
*/
|
||||
|
||||
@@ -7,10 +7,9 @@ import type { Permissions, Snowflake } from '../../common/mod.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,
|
||||
@@ -44,6 +43,7 @@ export const PermissionFlagsBits = {
|
||||
MANAGE_ROLES: 1n << 28n,
|
||||
MANAGE_WEBHOOKS: 1n << 29n,
|
||||
MANAGE_EMOJIS: 1n << 30n,
|
||||
USE_APPLICATION_COMMANDS: 1n << 31n,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,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,
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import type { Snowflake } from '../../common/mod.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
import type { RESTPostAPIGuildsJSONBody } from '../rest/mod.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#template-object
|
||||
|
||||
@@ -74,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,
|
||||
@@ -94,7 +94,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,
|
||||
@@ -146,7 +146,7 @@ export interface APIConnection {
|
||||
visibility: ConnectionVisibility;
|
||||
}
|
||||
|
||||
export const enum ConnectionVisibility {
|
||||
export enum ConnectionVisibility {
|
||||
/**
|
||||
* Invisible to everyone except the user themselves
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,7 @@ export interface APIWebhook {
|
||||
source_channel?: APIPartialChannel;
|
||||
}
|
||||
|
||||
export const enum WebhookType {
|
||||
export enum WebhookType {
|
||||
/**
|
||||
* Incoming Webhooks can post messages to channels with a generated token
|
||||
*/
|
||||
|
||||
@@ -134,7 +134,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
|
||||
@@ -151,7 +162,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
|
||||
/**
|
||||
* `true` if this is a TTS message
|
||||
*/
|
||||
tts?: true;
|
||||
tts?: boolean;
|
||||
/**
|
||||
* Embedded `rich` content
|
||||
*
|
||||
|
||||
@@ -31,7 +31,7 @@ export type APIGuildCreatePartialChannel = Partial<
|
||||
> & {
|
||||
name: string;
|
||||
id?: number | string;
|
||||
parent_id?: number | string;
|
||||
parent_id?: number | string | null;
|
||||
permission_overwrites?: APIGuildCreateOverwrite[];
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody {
|
||||
/**
|
||||
* ID for afk channel
|
||||
*/
|
||||
afk_channel_id?: number | Snowflake;
|
||||
afk_channel_id?: number | Snowflake | null;
|
||||
/**
|
||||
* AFK timeout in seconds
|
||||
*/
|
||||
@@ -114,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 | Snowflake;
|
||||
system_channel_id?: number | Snowflake | null;
|
||||
/**
|
||||
* System channel flags
|
||||
*
|
||||
|
||||
@@ -5,6 +5,11 @@ import type { APIApplicationCommand, APIInteractionResponse } from '../payloads/
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -30,6 +35,11 @@ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand;
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/audit-logs`
|
||||
*/
|
||||
guildAuditLog(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/audit-logs`;
|
||||
return `/guilds/${guildID}/audit-logs` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}`
|
||||
*/
|
||||
channel(channelID: Snowflake) {
|
||||
return `/channels/${channelID}`;
|
||||
return `/channels/${channelID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages`
|
||||
*/
|
||||
channelMessages(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/messages`;
|
||||
return `/channels/${channelID}/messages` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/messages/{message.id}`
|
||||
*/
|
||||
channelMessage(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}`;
|
||||
return `/channels/${channelID}/messages/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
|
||||
*/
|
||||
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/crosspost`;
|
||||
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
|
||||
*/
|
||||
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages/bulk-delete`
|
||||
*/
|
||||
channelBulkDelete(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/bulk-delete`;
|
||||
return `/channels/${channelID}/messages/bulk-delete` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
|
||||
*/
|
||||
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
|
||||
return `/channels/${channelID}/permissions/${overwriteID}`;
|
||||
return `/channels/${channelID}/permissions/${overwriteID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/invites`
|
||||
*/
|
||||
channelInvites(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/invites`;
|
||||
return `/channels/${channelID}/invites` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/followers`
|
||||
*/
|
||||
channelFollowers(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/followers`;
|
||||
return `/channels/${channelID}/followers` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/typing`
|
||||
*/
|
||||
channelTyping(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/typing`;
|
||||
return `/channels/${channelID}/typing` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ export const Routes = {
|
||||
* - GET `/channels/{channel.id}/pins`
|
||||
*/
|
||||
channelPins(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/pins`;
|
||||
return `/channels/${channelID}/pins` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/pins/{message.id}`
|
||||
*/
|
||||
channelPin(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/pins/${messageID}`;
|
||||
return `/channels/${channelID}/pins/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
|
||||
*/
|
||||
channelRecipient(channelID: Snowflake, userID: Snowflake) {
|
||||
return `/channels/${channelID}/recipients/${userID}`;
|
||||
return `/channels/${channelID}/recipients/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/emojis`
|
||||
*/
|
||||
guildEmojis(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/emojis`;
|
||||
return `/guilds/${guildID}/emojis` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
|
||||
*/
|
||||
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
|
||||
return `/guilds/${guildID}/emojis/${emojiID}`;
|
||||
return `/guilds/${guildID}/emojis/${emojiID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ export const Routes = {
|
||||
* - POST `/guilds`
|
||||
*/
|
||||
guilds() {
|
||||
return '/guilds';
|
||||
return '/guilds' as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -202,7 +202,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}`
|
||||
*/
|
||||
guild(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}`;
|
||||
return `/guilds/${guildID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/preview`
|
||||
*/
|
||||
guildPreview(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/preview`;
|
||||
return `/guilds/${guildID}/preview` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/channels`
|
||||
*/
|
||||
guildChannels(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/channels`;
|
||||
return `/guilds/${guildID}/channels` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -231,7 +231,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/members/{user.id}`
|
||||
*/
|
||||
guildMember(guildID: Snowflake, userID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/${userID}`;
|
||||
return `/guilds/${guildID}/members/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/members`
|
||||
*/
|
||||
guildMembers(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members`;
|
||||
return `/guilds/${guildID}/members` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/members/search`
|
||||
*/
|
||||
guildMembersSearch(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/search`;
|
||||
return `/guilds/${guildID}/members/search` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/members/@me/nick`
|
||||
*/
|
||||
guildCurrentMemberNickname(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/@me/nick`;
|
||||
return `/guilds/${guildID}/members/@me/nick` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
|
||||
*/
|
||||
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
|
||||
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -272,7 +272,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/bans`
|
||||
*/
|
||||
guildBans(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/bans`;
|
||||
return `/guilds/${guildID}/bans` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -282,7 +282,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
|
||||
*/
|
||||
guildBan(guildID: Snowflake, userID: Snowflake) {
|
||||
return `/guilds/${guildID}/bans/${userID}`;
|
||||
return `/guilds/${guildID}/bans/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -292,7 +292,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/roles`
|
||||
*/
|
||||
guildRoles(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/roles`;
|
||||
return `/guilds/${guildID}/roles` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
|
||||
*/
|
||||
guildRole(guildID: Snowflake, roleID: Snowflake) {
|
||||
return `/guilds/${guildID}/roles/${roleID}`;
|
||||
return `/guilds/${guildID}/roles/${roleID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -310,7 +310,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/prune`
|
||||
*/
|
||||
guildPrune(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/prune`;
|
||||
return `/guilds/${guildID}/prune` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/regions`
|
||||
*/
|
||||
guildVoiceRegions(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/regions`;
|
||||
return `/guilds/${guildID}/regions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -326,7 +326,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/invites`
|
||||
*/
|
||||
guildInvites(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/invites`;
|
||||
return `/guilds/${guildID}/invites` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -335,7 +335,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/integrations`
|
||||
*/
|
||||
guildIntegrations(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations`;
|
||||
return `/guilds/${guildID}/integrations` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
|
||||
*/
|
||||
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations/${integrationID}`;
|
||||
return `/guilds/${guildID}/integrations/${integrationID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -352,7 +352,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/integrations/{integration.id}/sync`
|
||||
*/
|
||||
guildIntegrationSync(guildID: Snowflake, integrationID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations/${integrationID}/sync`;
|
||||
return `/guilds/${guildID}/integrations/${integrationID}/sync` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -361,7 +361,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/widget`
|
||||
*/
|
||||
guildWidgetSettings(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget`;
|
||||
return `/guilds/${guildID}/widget` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -369,7 +369,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/widget.json`
|
||||
*/
|
||||
guildWidgetJSON(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget.json`;
|
||||
return `/guilds/${guildID}/widget.json` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/vanity-url`
|
||||
*/
|
||||
guildVanityUrl(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/vanity-url`;
|
||||
return `/guilds/${guildID}/vanity-url` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -385,7 +385,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/widget.png`
|
||||
*/
|
||||
guildWidgetImage(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget.png`;
|
||||
return `/guilds/${guildID}/widget.png` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -394,7 +394,7 @@ export const Routes = {
|
||||
* - DELETE `/invites/{invite.code}`
|
||||
*/
|
||||
invite(code: string) {
|
||||
return `/invites/${code}`;
|
||||
return `/invites/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -403,7 +403,7 @@ export const Routes = {
|
||||
* - POST `/guilds/templates/{template.code}`
|
||||
*/
|
||||
template(code: string) {
|
||||
return `/guilds/templates/${code}`;
|
||||
return `/guilds/templates/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -412,7 +412,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/templates`
|
||||
*/
|
||||
guildTemplates(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/templates`;
|
||||
return `/guilds/${guildID}/templates` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -422,7 +422,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
|
||||
*/
|
||||
guildTemplate(guildID: Snowflake, code: string) {
|
||||
return `/guilds/${guildID}/templates/${code}`;
|
||||
return `/guilds/${guildID}/templates/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -434,7 +434,7 @@ export const Routes = {
|
||||
* @param [userID='@me'] The user ID, defaulted to `@me`
|
||||
*/
|
||||
user(userID = '@me') {
|
||||
return `/users/${userID}`;
|
||||
return `/users/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -442,7 +442,7 @@ export const Routes = {
|
||||
* - GET `/users/@me/guilds`
|
||||
*/
|
||||
userGuilds() {
|
||||
return `/users/@me/guilds`;
|
||||
return `/users/@me/guilds` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -450,7 +450,7 @@ export const Routes = {
|
||||
* - DELETE `/users/@me/guilds/{guild.id}`
|
||||
*/
|
||||
userGuild(guildID: Snowflake) {
|
||||
return `/users/@me/guilds/${guildID}`;
|
||||
return `/users/@me/guilds/${guildID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -458,7 +458,7 @@ export const Routes = {
|
||||
* - POST `/users/@me/channels`
|
||||
*/
|
||||
userChannels() {
|
||||
return `/users/@me/channels`;
|
||||
return `/users/@me/channels` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -466,7 +466,7 @@ export const Routes = {
|
||||
* - GET `/users/@me/connections`
|
||||
*/
|
||||
userConnections() {
|
||||
return `/users/@me/connections`;
|
||||
return `/users/@me/connections` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -474,7 +474,7 @@ export const Routes = {
|
||||
* - GET `/voice/regions`
|
||||
*/
|
||||
voiceRegions() {
|
||||
return `/voice/regions`;
|
||||
return `/voice/regions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -483,7 +483,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/webhooks`
|
||||
*/
|
||||
channelWebhooks(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/webhooks`;
|
||||
return `/channels/${channelID}/webhooks` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -491,7 +491,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/webhooks`
|
||||
*/
|
||||
guildWebhooks(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/webhooks`;
|
||||
return `/guilds/${guildID}/webhooks` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -511,7 +511,7 @@ export const Routes = {
|
||||
|
||||
if (webhookToken) parts.push(webhookToken);
|
||||
|
||||
return parts.join('/');
|
||||
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -528,7 +528,7 @@ export const Routes = {
|
||||
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
|
||||
*/
|
||||
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID = '@original') {
|
||||
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
|
||||
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -537,7 +537,7 @@ export const Routes = {
|
||||
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
|
||||
*/
|
||||
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
|
||||
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
|
||||
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -545,7 +545,7 @@ export const Routes = {
|
||||
* - GET `/gateway`
|
||||
*/
|
||||
gateway() {
|
||||
return `/gateway`;
|
||||
return `/gateway` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -553,7 +553,7 @@ export const Routes = {
|
||||
* - GET `/gateway/bot`
|
||||
*/
|
||||
gatewayBot() {
|
||||
return `/gateway/bot`;
|
||||
return `/gateway/bot` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -561,7 +561,15 @@ 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;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -570,16 +578,17 @@ export const Routes = {
|
||||
* - POST `/applications/{application.id}/commands`
|
||||
*/
|
||||
applicationCommands(applicationID: Snowflake) {
|
||||
return `/applications/${applicationID}/commands`;
|
||||
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: Snowflake, commandID: Snowflake) {
|
||||
return `/applications/${applicationID}/commands/${commandID}`;
|
||||
return `/applications/${applicationID}/commands/${commandID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -588,16 +597,17 @@ export const Routes = {
|
||||
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
|
||||
*/
|
||||
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands`;
|
||||
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: Snowflake, guildID: Snowflake, commandID: Snowflake) {
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`;
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -605,7 +615,7 @@ export const Routes = {
|
||||
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
|
||||
*/
|
||||
interactionCallback(interactionID: Snowflake, interactionToken: string) {
|
||||
return `/interactions/${interactionID}/${interactionToken}/callback`;
|
||||
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -614,10 +624,24 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/member-verification`
|
||||
*/
|
||||
guildMemberVerification(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/member-verification`;
|
||||
return `/guilds/${guildID}/member-verification` 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
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(RouteBases);
|
||||
|
||||
export const OAuth2Routes = {
|
||||
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
|
||||
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
|
||||
@@ -628,7 +652,7 @@ export const OAuth2Routes = {
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Freeze route object
|
||||
* Freeze OAuth2 route object
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(OAuth2Routes);
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
import type { Permissions, Snowflake } from '../../common/mod.ts';
|
||||
import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/mod.ts';
|
||||
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../payloads/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
|
||||
*/
|
||||
|
||||
@@ -207,12 +207,20 @@ 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;
|
||||
}
|
||||
| RESTPatchAPIWebhookWithTokenMessageJSONBody;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
|
||||
*/
|
||||
export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/webhook#delete-webhook-message
|
||||
*/
|
||||
|
||||
10987
package-lock.json
generated
10987
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
package.json
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "discord-api-types",
|
||||
"version": "0.12.1",
|
||||
"version": "0.13.2",
|
||||
"description": "Discord API typings that are kept up to date for use in bot library creation.",
|
||||
"main": "./default/index.js",
|
||||
"types": "./default/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./default/index.js",
|
||||
"import": "./default/index.mjs"
|
||||
"./common": {
|
||||
"require": "./common/index.js",
|
||||
"import": "./common/index.mjs"
|
||||
},
|
||||
"./v6": {
|
||||
"require": "./v6/index.js",
|
||||
@@ -19,19 +19,19 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "run-s clean test:lint build:node",
|
||||
"postpublish": "run-s clean:node build:deno",
|
||||
"build:ci": "tsc --noEmit --incremental false",
|
||||
"build:deno": "node ./scripts/deno.mjs",
|
||||
"build:node": "tsc && run-p esm:*",
|
||||
"clean:deno": "rimraf deno/",
|
||||
"clean:node": "rimraf {v*,default,common}/**/*.{js,mjs,d.ts,map}",
|
||||
"clean": "run-p clean:*",
|
||||
"esm:common": "gen-esm-wrapper ./common/index.js ./common/index.mjs",
|
||||
"esm:default": "gen-esm-wrapper ./default/index.js ./default/index.mjs",
|
||||
"esm:v6": "gen-esm-wrapper ./v6/index.js ./v6/index.mjs",
|
||||
"esm:v8": "gen-esm-wrapper ./v8/index.js ./v8/index.mjs",
|
||||
"lint": "eslint --fix --ext mjs,js,ts {v*,default,common}/**",
|
||||
"test:lint": "eslint --ext mjs,js,ts {v*,default,common}/**",
|
||||
"clean": "run-p clean:*",
|
||||
"clean:node": "rimraf {v*,default,common}/**/*.{js,mjs,d.ts,map}",
|
||||
"clean:deno": "rimraf deno/"
|
||||
"postpublish": "run-s clean:node build:deno",
|
||||
"prepublishOnly": "run-s clean test:lint build:node",
|
||||
"test:lint": "eslint --ext mjs,js,ts {v*,default,common}/**"
|
||||
},
|
||||
"keywords": [
|
||||
"discord",
|
||||
@@ -53,21 +53,22 @@
|
||||
"node": ">=12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^11.0.0",
|
||||
"@commitlint/config-angular": "^11.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.10.0",
|
||||
"@typescript-eslint/parser": "^4.10.0",
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-marine": "^7.2.0",
|
||||
"eslint-config-prettier": "^7.0.0",
|
||||
"eslint-plugin-prettier": "^3.3.0",
|
||||
"@commitlint/cli": "^12.0.1",
|
||||
"@commitlint/config-angular": "^12.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
||||
"@typescript-eslint/parser": "^4.18.0",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-marine": "^8.3.2",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"gen-esm-wrapper": "^1.1.1",
|
||||
"husky": "^4.3.6",
|
||||
"lint-staged": "^10.5.3",
|
||||
"husky": "^4.3.8",
|
||||
"lint-staged": "^10.5.4",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.2.1",
|
||||
"pretty-quick": "^3.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -87,7 +88,7 @@
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"pre-commit": "pretty-quick --staged && lint-staged && npm run build:deno && git add deno",
|
||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
import {
|
||||
copyFile, //
|
||||
mkdir,
|
||||
opendir,
|
||||
readFile,
|
||||
rm,
|
||||
writeFile,
|
||||
} from 'fs/promises';
|
||||
import { copyFile, mkdir, opendir, readFile, rm, writeFile } from 'fs/promises';
|
||||
|
||||
const baseDirectory = new URL('../', import.meta.url);
|
||||
const denoPath = new URL('deno/', baseDirectory);
|
||||
@@ -37,6 +30,15 @@ function convertImports(source) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} source The raw source
|
||||
*/
|
||||
function convertConstEnums(source) {
|
||||
return source.replace(/const enum/gi, 'enum');
|
||||
}
|
||||
|
||||
const transformers = [convertImports, convertConstEnums];
|
||||
|
||||
/**
|
||||
* @param {string} folderName The folder name
|
||||
* @param {URL} node The node path
|
||||
@@ -50,7 +52,7 @@ async function adaptFolderToDeno(folderName, node = baseDirectory, deno = denoPa
|
||||
|
||||
for await (const file of await opendir(nodeDirectory)) {
|
||||
if (file.isDirectory()) {
|
||||
await adaptFolderToDeno(`${file.name}/`, new URL(folderName, node), new URL(folderName, deno));
|
||||
await adaptFolderToDeno(`${file.name}/`, nodeDirectory, denoDirectory);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,21 +63,12 @@ async function adaptFolderToDeno(folderName, node = baseDirectory, deno = denoPa
|
||||
|
||||
const originalFile = await readFile(fullFilePath, { encoding: 'utf8' });
|
||||
|
||||
await writeFile(finalDenoPath, convertImports(originalFile));
|
||||
const finalFile = transformers.reduce((code, transformer) => transformer(code), originalFile);
|
||||
|
||||
await writeFile(finalDenoPath, finalFile);
|
||||
}
|
||||
}
|
||||
|
||||
async function createModTS() {
|
||||
const defaultFile = await readFile(new URL('./default/index.ts', baseDirectory), { encoding: 'utf8' });
|
||||
|
||||
const converted = convertImports(defaultFile).replace('../v', './v');
|
||||
|
||||
await writeFile(new URL('mod.ts', denoPath), converted);
|
||||
}
|
||||
|
||||
// Create mod.ts which is the default/index.ts
|
||||
await createModTS();
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
'common/', //
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
import type { Snowflake } from '../../common/index';
|
||||
import type {
|
||||
APIApplication,
|
||||
APIApplicationCommand,
|
||||
APIApplicationCommandInteraction,
|
||||
APIChannel,
|
||||
APIEmoji,
|
||||
APIGuild,
|
||||
@@ -17,8 +20,6 @@ import type {
|
||||
GatewayVoiceState,
|
||||
InviteTargetUserType,
|
||||
PresenceUpdateStatus,
|
||||
APIApplicationCommandInteraction,
|
||||
APIApplication,
|
||||
} from '../payloads/index';
|
||||
|
||||
export const GatewayVersion = '8';
|
||||
@@ -32,7 +33,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,
|
||||
/**
|
||||
@@ -289,42 +291,45 @@ 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',
|
||||
ApplicationCommandUpdate = 'APPLICATION_COMMAND_UPDATE',
|
||||
ApplicationCommandDelete = 'APPLICATION_COMMAND_DELETE',
|
||||
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',
|
||||
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',
|
||||
}
|
||||
|
||||
@@ -345,41 +350,92 @@ 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
|
||||
| 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
|
||||
*/
|
||||
|
||||
@@ -233,12 +233,18 @@ export const enum AuditLogOptionsType {
|
||||
*/
|
||||
export type APIAuditLogChange =
|
||||
| APIAuditLogChangeKeyName
|
||||
| APIAuditLogChangeKeyDescription
|
||||
| APIAuditLogChangeKeyIconHash
|
||||
| APIAuditLogChangeKeySplashHash
|
||||
| APIAuditLogChangeKeyDiscoverySplashHash
|
||||
| APIAuditLogChangeKeyBannerHash
|
||||
| APIAuditLogChangeKeyOwnerID
|
||||
| APIAuditLogChangeKeyRegion
|
||||
| APIAuditLogChangeKeyPreferredLocale
|
||||
| APIAuditLogChangeKeyAFKChannelID
|
||||
| APIAuditLogChangeKeyAFKTimeout
|
||||
| APIAuditLogChangeKeyRulesChannelID
|
||||
| APIAuditLogChangeKeyPublicUpdatesChannelID
|
||||
| APIAuditLogChangeKeyMFALevel
|
||||
| APIAuditLogChangeKeyVerificationLevel
|
||||
| APIAuditLogChangeKeyExplicitContentFilter
|
||||
@@ -278,13 +284,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
|
||||
*/
|
||||
@@ -296,7 +308,17 @@ 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 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>;
|
||||
|
||||
@@ -305,6 +327,11 @@ export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowfla
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -315,6 +342,16 @@ export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_i
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -523,10 +560,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;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import type { Permissions, Snowflake } from '../../common/index';
|
||||
import type { APIPartialEmoji } from './emoji';
|
||||
import type { APIGuildMember } from './guild';
|
||||
import type { APIMessageInteraction } from './interactions';
|
||||
import type { APIRole } from './permissions';
|
||||
import type { APIUser } from './user';
|
||||
|
||||
@@ -307,6 +308,10 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Permissions, Snowflake } from '../../common/index';
|
||||
import type { APIGuildMember, APIUser, MessageFlags } from './index';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest/index';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './index';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
@@ -46,7 +46,7 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
/**
|
||||
* 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,
|
||||
* 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'> {
|
||||
@@ -79,19 +79,73 @@ export interface APIApplicationCommandOptionChoice {
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIInteraction {
|
||||
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;
|
||||
guild_id: Snowflake;
|
||||
channel_id: Snowflake;
|
||||
member: APIGuildMember & { permissions: Permissions; user: APIUser };
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like See APIInteraction, only with the `data` property always present
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
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 {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id?: never;
|
||||
/**
|
||||
* 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 APIInteraction, only with the `data` property always present
|
||||
*/
|
||||
export type APIApplicationCommandInteraction = Required<APIInteraction>;
|
||||
|
||||
@@ -110,72 +164,147 @@ 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 interface APIApplicationCommandInteractionDataOption {
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
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[];
|
||||
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-interaction-response
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseAcknowledge
|
||||
| APIInteractionResponseAcknowledgeWithSource
|
||||
| APIInteractionResponseChannelMessage
|
||||
| APIInteractionResponseChannelMessageWithSource;
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource;
|
||||
|
||||
export type APIInteractionResponsePong = InteractionResponsePayload<APIInteractionResponseType.Pong>;
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export type APIInteractionResponseAcknowledge = InteractionResponsePayload<APIInteractionResponseType.Acknowledge>;
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
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,
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionapplicationcommandcallbackdata
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
|
||||
*/
|
||||
export const 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 InteractionResponsePayload<T extends APIInteractionResponseType, D = false> {
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
data?: D extends true ? APIInteractionApplicationCommandCallbackData : never;
|
||||
value: D;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,19 @@ export interface APIApplication {
|
||||
/**
|
||||
* The application's public flags
|
||||
*/
|
||||
flags: number;
|
||||
flags: ApplicationFlags;
|
||||
}
|
||||
|
||||
export const enum ApplicationFlags {
|
||||
ManagedEmoji = 1 << 2,
|
||||
GroupDMCreate = 1 << 4,
|
||||
RPCHasConnected = 1 << 11,
|
||||
GatewayPresence = 1 << 12,
|
||||
GatewayPresenceLimit = 1 << 13,
|
||||
GatewayGuildMembers = 1 << 14,
|
||||
GatewayGuildMembersLimited = 1 << 15,
|
||||
VerificationPendingGuildLimit = 1 << 16,
|
||||
Embedded = 1 << 17,
|
||||
}
|
||||
|
||||
export const enum OAuth2Scopes {
|
||||
|
||||
@@ -7,10 +7,9 @@ import type { Permissions, Snowflake } from '../../common/index';
|
||||
/**
|
||||
* 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,
|
||||
@@ -44,6 +43,7 @@ export const PermissionFlagsBits = {
|
||||
MANAGE_ROLES: 1n << 28n,
|
||||
MANAGE_WEBHOOKS: 1n << 29n,
|
||||
MANAGE_EMOJIS: 1n << 30n,
|
||||
USE_APPLICATION_COMMANDS: 1n << 31n,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import type { Snowflake } from '../../common/index';
|
||||
import type { APIUser } from './user';
|
||||
import type { RESTPostAPIGuildsJSONBody } from '../rest/index';
|
||||
import type { APIUser } from './user';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/template#template-object
|
||||
|
||||
@@ -134,7 +134,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
|
||||
@@ -151,7 +162,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
|
||||
/**
|
||||
* `true` if this is a TTS message
|
||||
*/
|
||||
tts?: true;
|
||||
tts?: boolean;
|
||||
/**
|
||||
* Embedded `rich` content
|
||||
*
|
||||
|
||||
@@ -31,7 +31,7 @@ export type APIGuildCreatePartialChannel = Partial<
|
||||
> & {
|
||||
name: string;
|
||||
id?: number | string;
|
||||
parent_id?: number | string;
|
||||
parent_id?: number | string | null;
|
||||
permission_overwrites?: APIGuildCreateOverwrite[];
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody {
|
||||
/**
|
||||
* ID for afk channel
|
||||
*/
|
||||
afk_channel_id?: number | Snowflake;
|
||||
afk_channel_id?: number | Snowflake | null;
|
||||
/**
|
||||
* AFK timeout in seconds
|
||||
*/
|
||||
@@ -114,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 | Snowflake;
|
||||
system_channel_id?: number | Snowflake | null;
|
||||
/**
|
||||
* System channel flags
|
||||
*
|
||||
|
||||
158
v8/rest/index.ts
158
v8/rest/index.ts
@@ -20,7 +20,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/audit-logs`
|
||||
*/
|
||||
guildAuditLog(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/audit-logs`;
|
||||
return `/guilds/${guildID}/audit-logs` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}`
|
||||
*/
|
||||
channel(channelID: Snowflake) {
|
||||
return `/channels/${channelID}`;
|
||||
return `/channels/${channelID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages`
|
||||
*/
|
||||
channelMessages(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/messages`;
|
||||
return `/channels/${channelID}/messages` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/messages/{message.id}`
|
||||
*/
|
||||
channelMessage(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}`;
|
||||
return `/channels/${channelID}/messages/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
|
||||
*/
|
||||
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/crosspost`;
|
||||
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ export const Routes = {
|
||||
* **Note**: You need to URL encode the emoji yourself
|
||||
*/
|
||||
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
|
||||
*/
|
||||
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions`;
|
||||
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/messages/bulk-delete`
|
||||
*/
|
||||
channelBulkDelete(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/messages/bulk-delete`;
|
||||
return `/channels/${channelID}/messages/bulk-delete` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
|
||||
*/
|
||||
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
|
||||
return `/channels/${channelID}/permissions/${overwriteID}`;
|
||||
return `/channels/${channelID}/permissions/${overwriteID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/invites`
|
||||
*/
|
||||
channelInvites(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/invites`;
|
||||
return `/channels/${channelID}/invites` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/followers`
|
||||
*/
|
||||
channelFollowers(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/followers`;
|
||||
return `/channels/${channelID}/followers` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/typing`
|
||||
*/
|
||||
channelTyping(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/typing`;
|
||||
return `/channels/${channelID}/typing` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ export const Routes = {
|
||||
* - GET `/channels/{channel.id}/pins`
|
||||
*/
|
||||
channelPins(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/pins`;
|
||||
return `/channels/${channelID}/pins` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/pins/{message.id}`
|
||||
*/
|
||||
channelPin(channelID: Snowflake, messageID: Snowflake) {
|
||||
return `/channels/${channelID}/pins/${messageID}`;
|
||||
return `/channels/${channelID}/pins/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export const Routes = {
|
||||
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
|
||||
*/
|
||||
channelRecipient(channelID: Snowflake, userID: Snowflake) {
|
||||
return `/channels/${channelID}/recipients/${userID}`;
|
||||
return `/channels/${channelID}/recipients/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/emojis`
|
||||
*/
|
||||
guildEmojis(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/emojis`;
|
||||
return `/guilds/${guildID}/emojis` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
|
||||
*/
|
||||
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
|
||||
return `/guilds/${guildID}/emojis/${emojiID}`;
|
||||
return `/guilds/${guildID}/emojis/${emojiID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ export const Routes = {
|
||||
* - POST `/guilds`
|
||||
*/
|
||||
guilds() {
|
||||
return '/guilds';
|
||||
return '/guilds' as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -202,7 +202,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}`
|
||||
*/
|
||||
guild(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}`;
|
||||
return `/guilds/${guildID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/preview`
|
||||
*/
|
||||
guildPreview(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/preview`;
|
||||
return `/guilds/${guildID}/preview` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/channels`
|
||||
*/
|
||||
guildChannels(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/channels`;
|
||||
return `/guilds/${guildID}/channels` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -231,7 +231,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/members/{user.id}`
|
||||
*/
|
||||
guildMember(guildID: Snowflake, userID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/${userID}`;
|
||||
return `/guilds/${guildID}/members/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/members`
|
||||
*/
|
||||
guildMembers(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members`;
|
||||
return `/guilds/${guildID}/members` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/members/search`
|
||||
*/
|
||||
guildMembersSearch(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/search`;
|
||||
return `/guilds/${guildID}/members/search` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/members/@me/nick`
|
||||
*/
|
||||
guildCurrentMemberNickname(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/@me/nick`;
|
||||
return `/guilds/${guildID}/members/@me/nick` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
|
||||
*/
|
||||
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
|
||||
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
|
||||
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -272,7 +272,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/bans`
|
||||
*/
|
||||
guildBans(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/bans`;
|
||||
return `/guilds/${guildID}/bans` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -282,7 +282,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
|
||||
*/
|
||||
guildBan(guildID: Snowflake, userID: Snowflake) {
|
||||
return `/guilds/${guildID}/bans/${userID}`;
|
||||
return `/guilds/${guildID}/bans/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -292,7 +292,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/roles`
|
||||
*/
|
||||
guildRoles(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/roles`;
|
||||
return `/guilds/${guildID}/roles` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
|
||||
*/
|
||||
guildRole(guildID: Snowflake, roleID: Snowflake) {
|
||||
return `/guilds/${guildID}/roles/${roleID}`;
|
||||
return `/guilds/${guildID}/roles/${roleID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -310,7 +310,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/prune`
|
||||
*/
|
||||
guildPrune(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/prune`;
|
||||
return `/guilds/${guildID}/prune` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/regions`
|
||||
*/
|
||||
guildVoiceRegions(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/regions`;
|
||||
return `/guilds/${guildID}/regions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -326,7 +326,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/invites`
|
||||
*/
|
||||
guildInvites(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/invites`;
|
||||
return `/guilds/${guildID}/invites` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -335,7 +335,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/integrations`
|
||||
*/
|
||||
guildIntegrations(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations`;
|
||||
return `/guilds/${guildID}/integrations` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
|
||||
*/
|
||||
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations/${integrationID}`;
|
||||
return `/guilds/${guildID}/integrations/${integrationID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -352,7 +352,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/integrations/{integration.id}/sync`
|
||||
*/
|
||||
guildIntegrationSync(guildID: Snowflake, integrationID: Snowflake) {
|
||||
return `/guilds/${guildID}/integrations/${integrationID}/sync`;
|
||||
return `/guilds/${guildID}/integrations/${integrationID}/sync` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -361,7 +361,7 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/widget`
|
||||
*/
|
||||
guildWidgetSettings(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget`;
|
||||
return `/guilds/${guildID}/widget` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -369,7 +369,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/widget.json`
|
||||
*/
|
||||
guildWidgetJSON(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget.json`;
|
||||
return `/guilds/${guildID}/widget.json` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/vanity-url`
|
||||
*/
|
||||
guildVanityUrl(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/vanity-url`;
|
||||
return `/guilds/${guildID}/vanity-url` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -385,7 +385,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/widget.png`
|
||||
*/
|
||||
guildWidgetImage(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/widget.png`;
|
||||
return `/guilds/${guildID}/widget.png` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -394,7 +394,7 @@ export const Routes = {
|
||||
* - DELETE `/invites/{invite.code}`
|
||||
*/
|
||||
invite(code: string) {
|
||||
return `/invites/${code}`;
|
||||
return `/invites/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -403,7 +403,7 @@ export const Routes = {
|
||||
* - POST `/guilds/templates/{template.code}`
|
||||
*/
|
||||
template(code: string) {
|
||||
return `/guilds/templates/${code}`;
|
||||
return `/guilds/templates/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -412,7 +412,7 @@ export const Routes = {
|
||||
* - POST `/guilds/{guild.id}/templates`
|
||||
*/
|
||||
guildTemplates(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/templates`;
|
||||
return `/guilds/${guildID}/templates` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -422,7 +422,7 @@ export const Routes = {
|
||||
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
|
||||
*/
|
||||
guildTemplate(guildID: Snowflake, code: string) {
|
||||
return `/guilds/${guildID}/templates/${code}`;
|
||||
return `/guilds/${guildID}/templates/${code}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -434,7 +434,7 @@ export const Routes = {
|
||||
* @param [userID='@me'] The user ID, defaulted to `@me`
|
||||
*/
|
||||
user(userID = '@me') {
|
||||
return `/users/${userID}`;
|
||||
return `/users/${userID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -442,7 +442,7 @@ export const Routes = {
|
||||
* - GET `/users/@me/guilds`
|
||||
*/
|
||||
userGuilds() {
|
||||
return `/users/@me/guilds`;
|
||||
return `/users/@me/guilds` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -450,7 +450,7 @@ export const Routes = {
|
||||
* - DELETE `/users/@me/guilds/{guild.id}`
|
||||
*/
|
||||
userGuild(guildID: Snowflake) {
|
||||
return `/users/@me/guilds/${guildID}`;
|
||||
return `/users/@me/guilds/${guildID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -458,7 +458,7 @@ export const Routes = {
|
||||
* - POST `/users/@me/channels`
|
||||
*/
|
||||
userChannels() {
|
||||
return `/users/@me/channels`;
|
||||
return `/users/@me/channels` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -466,7 +466,7 @@ export const Routes = {
|
||||
* - GET `/users/@me/connections`
|
||||
*/
|
||||
userConnections() {
|
||||
return `/users/@me/connections`;
|
||||
return `/users/@me/connections` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -474,7 +474,7 @@ export const Routes = {
|
||||
* - GET `/voice/regions`
|
||||
*/
|
||||
voiceRegions() {
|
||||
return `/voice/regions`;
|
||||
return `/voice/regions` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -483,7 +483,7 @@ export const Routes = {
|
||||
* - POST `/channels/{channel.id}/webhooks`
|
||||
*/
|
||||
channelWebhooks(channelID: Snowflake) {
|
||||
return `/channels/${channelID}/webhooks`;
|
||||
return `/channels/${channelID}/webhooks` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -491,7 +491,7 @@ export const Routes = {
|
||||
* - GET `/guilds/{guild.id}/webhooks`
|
||||
*/
|
||||
guildWebhooks(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/webhooks`;
|
||||
return `/guilds/${guildID}/webhooks` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -511,7 +511,7 @@ export const Routes = {
|
||||
|
||||
if (webhookToken) parts.push(webhookToken);
|
||||
|
||||
return parts.join('/');
|
||||
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -528,7 +528,7 @@ export const Routes = {
|
||||
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
|
||||
*/
|
||||
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID = '@original') {
|
||||
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
|
||||
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -537,7 +537,7 @@ export const Routes = {
|
||||
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
|
||||
*/
|
||||
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
|
||||
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
|
||||
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -545,7 +545,7 @@ export const Routes = {
|
||||
* - GET `/gateway`
|
||||
*/
|
||||
gateway() {
|
||||
return `/gateway`;
|
||||
return `/gateway` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -553,7 +553,7 @@ export const Routes = {
|
||||
* - GET `/gateway/bot`
|
||||
*/
|
||||
gatewayBot() {
|
||||
return `/gateway/bot`;
|
||||
return `/gateway/bot` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -561,7 +561,15 @@ 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;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -570,16 +578,17 @@ export const Routes = {
|
||||
* - POST `/applications/{application.id}/commands`
|
||||
*/
|
||||
applicationCommands(applicationID: Snowflake) {
|
||||
return `/applications/${applicationID}/commands`;
|
||||
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: Snowflake, commandID: Snowflake) {
|
||||
return `/applications/${applicationID}/commands/${commandID}`;
|
||||
return `/applications/${applicationID}/commands/${commandID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -588,16 +597,17 @@ export const Routes = {
|
||||
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
|
||||
*/
|
||||
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands`;
|
||||
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: Snowflake, guildID: Snowflake, commandID: Snowflake) {
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`;
|
||||
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -605,7 +615,7 @@ export const Routes = {
|
||||
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
|
||||
*/
|
||||
interactionCallback(interactionID: Snowflake, interactionToken: string) {
|
||||
return `/interactions/${interactionID}/${interactionToken}/callback`;
|
||||
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -614,10 +624,24 @@ export const Routes = {
|
||||
* - PATCH `/guilds/{guild.id}/member-verification`
|
||||
*/
|
||||
guildMemberVerification(guildID: Snowflake) {
|
||||
return `/guilds/${guildID}/member-verification`;
|
||||
return `/guilds/${guildID}/member-verification` 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
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(RouteBases);
|
||||
|
||||
export const OAuth2Routes = {
|
||||
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
|
||||
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
|
||||
@@ -628,7 +652,7 @@ export const OAuth2Routes = {
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Freeze route object
|
||||
* Freeze OAuth2 route object
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(OAuth2Routes);
|
||||
|
||||
@@ -5,6 +5,11 @@ import type { APIApplicationCommand, APIInteractionResponse } from '../payloads/
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -30,6 +35,11 @@ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand;
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
import type { Permissions, Snowflake } from '../../common/index';
|
||||
import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/index';
|
||||
import type { APIApplication, APIGuild, APIUser, APIWebhook, OAuth2Scopes } from '../payloads/index';
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -207,12 +207,20 @@ 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;
|
||||
}
|
||||
| RESTPatchAPIWebhookWithTokenMessageJSONBody;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/webhook#edit-webhook-message
|
||||
*/
|
||||
export type RESTPatchAPIWebhookWithTokenMessageResult = APIMessage;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/webhook#delete-webhook-message
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user