Compare commits

..

34 Commits

Author SHA1 Message Date
Vlad Frangu
fc4b7e2708 chore: release 0.13.2 (#103) 2021-03-28 12:56:01 +03:00
Tiemen
15c171c558 fix(ApplicationCommandInteractionDataOptionSubCommandGroup): typo (#102)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2021-03-28 12:48:01 +03:00
Vlad Frangu
ebd5754242 chore: release 0.13.1 (#101) 2021-03-28 00:43:10 +02:00
Advaith
ffcd95d597 fix(APIInteractionResponse): data should not always be present (#100)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-28 00:40:52 +02:00
Vlad Frangu
2636bd0949 chore: release 0.13.0 (#99) 2021-03-27 18:15:41 +02:00
Advaith
ceb787ba36 feat(PermissionFlagsBits): add USE_APPLICATION_COMMANDS (#85)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 18:09:47 +02:00
Ben Richeson
ca61396577 chore(APIApplicationCommandInteractionDataOption): add types and their values (#72)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 18:06:35 +02:00
Advaith
0582f883c5 feat(APIBaseInteraction): add application_id (#98)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-27 17:40:14 +02:00
didinele
9d8d090c9c fix(RESTPostAPIChannelMessageJSONBody): mark tts as a full boolean (#96) 2021-03-17 10:02:14 +02:00
Vlad Frangu
eb3f8e1dea chore: add missing GitHub mds (#95) 2021-03-17 01:04:10 +02:00
Advaith
24155aeb71 feat(APIApplicationCommandInteractionData): add resolved (#86)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2021-03-16 01:05:44 +02:00
Advaith
76651acd49 chore(APIInteractionResponse, APIInteractionResponseType): remove old response types (#94)
Because they're out :3

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

View File

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

View File

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

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

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

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

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

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

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

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

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

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

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

View File

@@ -0,0 +1,21 @@
---
name: Feature request
about: Request a feature for the discord-api-types library
title: ''
labels: 'discussion'
assignees: ''
---
<!-- Use Discord for questions: https://discord.gg/bRCvFy9 -->
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Eg. I'm always frustrated when [...]
**Describe the ideal solution**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

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

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

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

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

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

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

View File

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

View File

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

4
.npmrc Normal file
View File

@@ -0,0 +1,4 @@
audit=false
fund=false
node-version=false
legacy-peer-deps=true

8
.prettierrc.json Normal file
View File

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

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

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

View File

@@ -1,9 +1,11 @@
<div style="text-align:center;"><h1>Discord API Types</h1></div>
# Discord API Types
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro).
@@ -23,28 +25,22 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime.
```ts
// Importing the default API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8/mod.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing the default API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v8/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';
```
@@ -79,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');

View File

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

View File

@@ -1,9 +1,11 @@
<div style="text-align:center;"><h1>Discord API Types</h1></div>
# Discord API Types
[![GitHub](https://img.shields.io/github/license/discordjs/discord-api-types)](https://github.com/discordjs/discord-api-types/blob/main/LICENSE.md)
[![npm](https://img.shields.io/npm/v/discord-api-types?color=crimson&logo=npm)](https://www.npmjs.com/package/discord-api-types)
[![deno](https://img.shields.io/npm/v/discord-api-types?color=blue&label=deno&logo=deno)](https://deno.land/x/discord_api_types)
[![Patreon Donate](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Donate%20with%20Patreon&logo=patreon&colorB=F96854&link=https://www.patreon.com/vladfrangu)](https://www.patreon.com/vladfrangu)
[![Ko-fi Donate](https://img.shields.io/badge/kofi-donate-brightgreen.svg?label=Donate%20with%20Ko-fi&logo=ko-fi&colorB=F16061&link=https://ko-fi.com/wolfgalvlad&logoColor=FFFFFF)](https://ko-fi.com/wolfgalvlad)
[![GitHub Sponsors](https://img.shields.io/badge/patreon-donate-brightgreen.svg?label=Sponsor%20through%20GitHub&logo=github&colorB=F96854&link=https://github.com/sponsors/vladfrangu)](https://github.com/sponsors/vladfrangu)
Simple type definitions for the [Discord API](https://discord.com/developers/docs/intro).
@@ -23,28 +25,22 @@ We also provide typings compatible with the [deno](https://deno.land/) runtime.
```ts
// Importing the default API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/.deno/v8/mod.ts';
import { APIUser } from 'https://raw.githubusercontent.com/discordjs/discord-api-types/main/deno/v8/mod.ts';
```
2. From [deno.land/x](https://deno.land/x)
```ts
// Importing the default API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/mod.ts';
// Importing a specific API version
import { APIUser } from 'https://deno.land/x/discord_api_types@0.12.0/v8/mod.ts';
import { APIUser } from 'https://deno.land/x/discord_api_types/v8/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';
```
@@ -79,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');

View File

@@ -1,7 +1,7 @@
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes
*/
export const enum RESTJSONErrorCodes {
export enum RESTJSONErrorCodes {
GeneralError,
UnknownAccount = 10001,
@@ -30,6 +30,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,
@@ -147,3 +153,74 @@ export interface GatewayConnectQuery {
encoding: 'json' | 'etf';
compress?: 'zlib-stream';
}
/**
* https://discord.com/developers/docs/reference#snowflakes
*/
export type Snowflake = `${bigint}`;
/**
* https://discord.com/developers/docs/topics/permissions
* @internal
*/
export type Permissions = `${bigint}`;
/**
* https://discord.com/developers/docs/reference#message-formatting-formats
*/
export const FormattingPatterns = {
/**
* Regular expression for matching a user mention, strictly without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
User: /<@(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, strictly with a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithNickname: /<@!(?<id>\d{17,20})>/,
/**
* Regular expression for matching a user mention, with or without a nickname
*
* The `id` group property is present on the `exec` result of this expression
*/
UserWithOptionalNickname: /<@!?(?<id>\d{17,20})>/,
/**
* Regular expression for matching a channel mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Channel: /<#(?<id>\d{17,20})>/,
/**
* Regular expression for matching a role mention
*
* The `id` group property is present on the `exec` result of this expression
*/
Role: /<@&(?<id>\d{17,20})>/,
/**
* Regular expression for matching a custom emoji, either static or animated
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
Emoji: /<(?<animated>a)?:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly an animated custom emoji
*
* The `animated`, `name` and `id` group properties are present on the `exec` result of this expression
*/
AnimatedEmoji: /<(?<animated>a):(?<name>\w{2,32}):(?<id>\d{17,20})>/,
/**
* Regular expression for matching strictly a static custom emoji
*
* The `name` and `id` group properties are present on the `exec` result of this expression
*/
StaticEmoji: /<:(?<name>\w{2,32}):(?<id>\d{17,20})>/,
} as const;
/**
* Freezes the formatting patterns
* @internal
*/
Object.freeze(FormattingPatterns);

View File

@@ -2,7 +2,11 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../common/mod.ts';
import type {
APIApplication,
APIApplicationCommand,
APIApplicationCommandInteraction,
APIChannel,
APIEmoji,
APIGuild,
@@ -16,8 +20,6 @@ import type {
GatewayVoiceState,
InviteTargetUserType,
PresenceUpdateStatus,
APIApplicationCommandInteraction,
APIApplication,
} from '../payloads/mod.ts';
export const GatewayVersion = '8';
@@ -25,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,
/**
@@ -75,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?
*/
@@ -158,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
*/
@@ -212,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
*/
@@ -266,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,
@@ -287,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',
}
@@ -344,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
*/
@@ -550,11 +607,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The time at which the most recent pinned message was pinned
*/
@@ -623,7 +680,7 @@ export interface GatewayGuildBanModifyDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The banned user
*
@@ -667,7 +724,7 @@ export interface GatewayGuildEmojisUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Array of emojis
*
@@ -691,7 +748,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData {
/**
* ID of the guild whose integrations were updated
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -709,7 +766,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -727,7 +784,7 @@ export interface GatewayGuildMemberRemoveDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The user who was removed
*
@@ -751,7 +808,7 @@ export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' |
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
};
/**
@@ -769,7 +826,7 @@ export interface GatewayGuildMembersChunkDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Set of guild members
*
@@ -819,7 +876,7 @@ export interface GatewayGuildRoleModifyDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The role created or updated
*
@@ -863,11 +920,11 @@ export interface GatewayGuildRoleDeleteDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the role
*/
role_id: string;
role_id: Snowflake;
}
/**
@@ -898,7 +955,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The channel the invite is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The unique invite code
*
@@ -912,7 +969,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The user that created the invite
*
@@ -964,11 +1021,11 @@ export interface GatewayInviteDeleteDispatchData {
/**
* The channel of the invite
*/
channel_id: string;
channel_id: Snowflake;
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The unique invite code
*
@@ -1002,8 +1059,8 @@ export type GatewayMessageUpdateDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatchData = {
id: string;
channel_id: string;
id: Snowflake;
channel_id: Snowflake;
} & Partial<APIMessage>;
/**
@@ -1021,15 +1078,15 @@ export interface GatewayMessageDeleteDispatchData {
/**
* The id of the message
*/
id: string;
id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1047,15 +1104,15 @@ export interface GatewayMessageDeleteBulkDispatchData {
/**
* The ids of the messages
*/
ids: string[];
ids: Snowflake[];
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1134,15 +1191,15 @@ export interface GatewayTypingStartDispatchData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* Unix time (in seconds) of when the user started typing
*/
@@ -1197,7 +1254,7 @@ export interface GatewayVoiceServerUpdateDispatchData {
/**
* The guild this voice server update is for
*/
guild_id: string;
guild_id: Snowflake;
/**
* The voice server host
*/
@@ -1219,11 +1276,11 @@ export interface GatewayWebhooksUpdateDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
}
// #endregion Dispatch Payloads
@@ -1364,7 +1421,7 @@ export interface GatewayRequestGuildMembersData {
/**
* ID of the guild to get members for
*/
guild_id: string | string[];
guild_id: Snowflake;
/**
* String that username starts with, or an empty string to return all members
*/
@@ -1381,7 +1438,7 @@ export interface GatewayRequestGuildMembersData {
/**
* Used to specify which users you wish to fetch
*/
user_ids?: string | string[];
user_ids?: Snowflake | Snowflake[];
/**
* Nonce to identify the Guild Members Chunk response
*
@@ -1405,11 +1462,11 @@ export interface GatewayVoiceStateUpdateData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* ID of the voice channel client wants to join (`null` if disconnecting)
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* Is the client muted
*/
@@ -1496,19 +1553,19 @@ type ReactionData<E extends GatewayDispatchEvents, O extends string = never> = D
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The member who reacted if this happened in a guild
*
@@ -1530,14 +1587,14 @@ interface MessageReactionRemoveData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
// #endregion Shared

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/audit-log
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APIOverwrite, ChannelType } from './channel.ts';
import type {
APIGuildIntegration,
@@ -65,11 +66,11 @@ export interface APIAuditLogEntry {
* *Against all odds, this can be `null` in some cases (webhooks deleting themselves
* by using their own token, for example)*
*/
user_id: string | null;
user_id: Snowflake | null;
/**
* ID of the entry
*/
id: string;
id: Snowflake;
/**
* Type of action that occurred
*
@@ -91,7 +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,
@@ -165,7 +166,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_UNPIN
* - MESSAGE_DELETE
*/
channel_id?: string;
channel_id?: Snowflake;
/**
* ID of the message that was targeted
@@ -174,7 +175,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_PIN
* - MESSAGE_UNPIN
*/
message_id?: string;
message_id?: Snowflake;
/**
* Number of entities that were targeted
@@ -195,7 +196,7 @@ export interface APIAuditLogOptions {
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*/
id?: string;
id?: Snowflake;
/**
* Type of overwritten entity - "0" for "role" or "1" for "member"
@@ -222,7 +223,7 @@ export interface APIAuditLogOptions {
role_name?: string;
}
export const enum AuditLogOptionsType {
export enum AuditLogOptionsType {
Role = '0',
Member = '1',
}
@@ -232,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
@@ -277,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
*/
@@ -295,25 +308,50 @@ export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', strin
export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>;
/**
* Returned when a guild's owner ID is changed
* Returned when a guild's discovery splash is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>;
export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>;
/**
* Returned when a guild's banner hash is changed
*/
export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>;
/**
* Returned when a guild's owner_id is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowflake>;
/**
* Returned when a guild's region is changed
*/
export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>;
/**
* Returned when a guild's preferred_locale is changed
*/
export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>;
/**
* Returned when a guild's afk_channel_id is changed
*/
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>;
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', Snowflake>;
/**
* Returned when a guild's afk_timeout is changed
*/
export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>;
/**
* Returned when a guild's rules_channel_id is changed
*/
export type APIAuditLogChangeKeyRulesChannelID = AuditLogChangeData<'rules_channel_id', string>;
/**
* Returned when a guild's public_updates_channel_id is changed
*/
export type APIAuditLogChangeKeyPublicUpdatesChannelID = AuditLogChangeData<'public_updates_channel_id', string>;
/**
* Returned when a guild's mfa_level is changed
*/
@@ -368,12 +406,12 @@ export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabl
/**
* Returned when a guild's widget_channel_id is changed
*/
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>;
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', Snowflake>;
/**
* Returned when a guild's system_channel_id is changed
*/
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', string>;
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', Snowflake>;
/**
* Returned when a channel's position is changed
@@ -403,7 +441,7 @@ export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>;
/**
* The application ID of the added or removed Webhook or Bot
*/
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', string>;
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', Snowflake>;
/**
* Returned when a channel's amount of seconds a user has to wait before sending another message
@@ -449,12 +487,12 @@ export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>;
/**
* Returned when an invite's channel_id is changed
*/
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>;
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', Snowflake>;
/**
* Returned when an invite's inviter_id is changed
*/
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>;
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', Snowflake>;
/**
* Returned when an invite's max_uses is changed
@@ -499,7 +537,7 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s
/**
* The ID of the changed entity - sometimes used in conjunction with other keys
*/
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', string>;
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>;
/**
* The type of entity created
@@ -522,10 +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;
}

View File

@@ -2,8 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/channel
*/
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';
/**
@@ -13,7 +16,7 @@ export interface APIPartialChannel {
/**
* The id of the channel
*/
id: string;
id: Snowflake;
/**
* The type of the channel
*
@@ -33,7 +36,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* Sorting position of the channel
*/
@@ -55,7 +58,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: string | null;
last_message_id?: Snowflake | null;
/**
* The bitrate (in bits) of the voice channel
*/
@@ -82,15 +85,15 @@ export interface APIChannel extends APIPartialChannel {
/**
* ID of the DM creator
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* Application id of the group DM creator if it is bot-created
*/
application_id?: string;
application_id?: Snowflake;
/**
* ID of the parent category for a channel (each parent category can contain up to 50 channels)
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
/**
* When the last pinned message was pinned.
* This may be `null` in events such as `GUILD_CREATE` when a message is not pinned
@@ -101,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
*/
@@ -145,15 +148,15 @@ export interface APIMessage {
/**
* ID of the message
*/
id: string;
id: Snowflake;
/**
* ID of the channel the message was sent in
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the guild the message was sent in
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The author of this message (only a valid user in the case where the message is generated by a user or bot user)
*
@@ -207,7 +210,7 @@ export interface APIMessage {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
mention_roles: string[];
mention_roles: APIRole['id'][];
/**
* Channels specifically mentioned in this message
*
@@ -252,7 +255,7 @@ export interface APIMessage {
/**
* If the message is generated by a webhook, this is the webhook's id
*/
webhook_id?: string;
webhook_id?: Snowflake;
/**
* Type of message
*
@@ -305,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,
@@ -357,7 +364,7 @@ export interface APIMessageApplication {
/**
* ID of the application
*/
id: string;
id: Snowflake;
/**
* ID of the embed's image asset
*/
@@ -383,21 +390,21 @@ export interface APIMessageReference {
/**
* ID of the originating message
*/
message_id?: string;
message_id?: Snowflake;
/**
* ID of the originating message's channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the originating message's guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
*/
export const enum MessageActivityType {
export enum MessageActivityType {
JOIN = 1,
SPECTATE,
LISTEN,
@@ -407,7 +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)
*/
@@ -438,11 +445,11 @@ export interface APISticker {
/**
* ID of the sticker
*/
id: string;
id: Snowflake;
/**
* ID of the pack the sticker is from
*/
pack_id: string;
pack_id: Snowflake;
/**
* Name of the sticker
*/
@@ -474,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,
@@ -487,11 +494,11 @@ export interface APIFollowedChannel {
/**
* Source channel id
*/
channel_id: string;
channel_id: Snowflake;
/**
* Created target webhook id
*/
webhook_id: string;
webhook_id: Snowflake;
}
/**
@@ -521,7 +528,7 @@ export interface APIOverwrite {
/**
* Role or user id
*/
id: string;
id: Snowflake;
/**
* Either 0 (role) or 1 (member)
*
@@ -535,7 +542,7 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* Permission bit set
*
@@ -543,10 +550,10 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
}
export const enum OverwriteType {
export enum OverwriteType {
Role,
Member,
}
@@ -639,7 +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
*/
@@ -815,7 +822,7 @@ export interface APIAttachment {
/**
* Attachment id
*/
id: string;
id: Snowflake;
/**
* Name of file attached
*/
@@ -849,11 +856,11 @@ export interface APIChannelMention {
/**
* ID of the channel
*/
id: string;
id: Snowflake;
/**
* ID of the guild containing the channel
*/
guild_id: string;
guild_id: Snowflake;
/**
* The type of channel
*
@@ -869,7 +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
*/
@@ -897,11 +904,11 @@ export interface APIAllowedMentions {
/**
* Array of role_ids to mention (Max size of 100)
*/
roles?: string[];
roles?: Snowflake[];
/**
* Array of user_ids to mention (Max size of 100)
*/
users?: string[];
users?: Snowflake[];
/**
* For replies, whether to mention the author of the message being replied to (default false)
*

View File

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

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APIEmoji } from './emoji.ts';
import type { APIUser } from './user.ts';
@@ -67,13 +68,11 @@ export interface GatewayPresenceUpdate {
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: Partial<APIUser> & {
id: string;
};
user: Partial<APIUser> & Pick<APIUser, 'id'>;
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Either "idle", "dnd", "online", or "offline"
*/
@@ -92,7 +91,7 @@ export interface GatewayPresenceUpdate {
client_status?: GatewayPresenceClientStatus;
}
export const enum PresenceUpdateStatus {
export enum PresenceUpdateStatus {
Online = 'online',
DoNotDisturb = 'dnd',
Idle = 'idle',
@@ -156,7 +155,7 @@ export interface GatewayActivity {
/**
* Application id for the game
*/
application_id?: string;
application_id?: Snowflake;
/**
* What the player is currently doing
*/
@@ -214,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}
*/
@@ -289,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,

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { Permissions, Snowflake } from '../../common/mod.ts';
import type { APIChannel } from './channel.ts';
import type { APIEmoji } from './emoji.ts';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts';
@@ -16,7 +17,7 @@ export interface APIUnavailableGuild {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* `true` if this guild is unavailable due to an outage
*/
@@ -100,7 +101,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* ID of owner
*/
owner_id: string;
owner_id: Snowflake;
/**
* Total permissions for the user in the guild (excludes overrides)
*
@@ -108,7 +109,7 @@ export interface APIGuild extends APIPartialGuild {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions?: string;
permissions?: Permissions;
/**
* Voice region id for the guild
*
@@ -118,7 +119,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* ID of afk channel
*/
afk_channel_id: string | null;
afk_channel_id: Snowflake | null;
/**
* afk timeout in seconds
*/
@@ -130,7 +131,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The channel id that the widget will generate an invite to, or `null` if set to no invite
*/
widget_channel_id?: string | null;
widget_channel_id?: Snowflake | null;
/**
* Verification level required for the guild
*
@@ -176,11 +177,11 @@ export interface APIGuild extends APIPartialGuild {
/**
* Application id of the guild creator if it is bot-created
*/
application_id: string | null;
application_id: Snowflake | null;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id: string | null;
system_channel_id: Snowflake | null;
/**
* System channel flags
*
@@ -190,7 +191,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: string | null;
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
@@ -282,7 +283,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id: string | null;
public_updates_channel_id: Snowflake | null;
/**
* The maximum amount of users in a video channel
*/
@@ -301,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,
}
@@ -309,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,
@@ -318,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,
}
@@ -326,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
*/
@@ -352,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,
@@ -362,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
*/
@@ -376,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
*/
@@ -447,7 +448,7 @@ export interface APIGuildPreview {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* Guild name (2-100 characters)
*/
@@ -507,7 +508,7 @@ export interface APIGuildWidgetSettings {
/**
* The widget channel id
*/
channel_id: string | null;
channel_id: Snowflake | null;
}
/**
@@ -531,7 +532,7 @@ export interface APIGuildMember {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles: string[];
roles: Snowflake[];
/**
* When the user joined the guild
*/
@@ -565,7 +566,7 @@ export interface APIGuildIntegration {
/**
* Integration id
*/
id: string;
id: Snowflake;
/**
* Integration name
*/
@@ -589,7 +590,7 @@ export interface APIGuildIntegration {
*
* **This field is not provided for `discord` bot integrations.**
*/
role_id?: string;
role_id?: Snowflake;
/**
* Whether emoticons should be synced for this integration (`twitch` only currently)
*
@@ -657,7 +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,
}
@@ -683,7 +684,7 @@ export interface APIGuildIntegrationApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -728,7 +729,7 @@ export interface APIBan {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidget {
id: string;
id: Snowflake;
name: string;
instant_invite: string | null;
channels: APIGuildWidgetChannel[];
@@ -740,7 +741,7 @@ export interface APIGuildWidget {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidgetChannel {
id: string;
id: Snowflake;
name: string;
position: number;
}
@@ -761,7 +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
*/
@@ -800,11 +801,11 @@ export interface APIGuildWelcomeScreenChannel {
/**
* The channel id that is suggested
*/
channel_id: string;
channel_id: Snowflake;
/**
* The emoji id of the emoji that is shown on the left of the channel
*/
emoji_id: string | null;
emoji_id: Snowflake | null;
/**
* The emoji name of the emoji that is shown on the left of the channel
*/
@@ -847,7 +848,7 @@ export interface APIGuildMembershipScreeningField {
required: boolean;
}
export const enum MembershipScreeningFieldType {
export enum MembershipScreeningFieldType {
/**
* Server Rules
*/

View File

@@ -0,0 +1,310 @@
import type { Permissions, Snowflake } from '../../common/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
*/
export interface APIApplicationCommand {
id: Snowflake;
application_id: Snowflake;
name: string;
description: string;
options?: APIApplicationCommandOption[];
}
interface APIApplicationCommandOptionBase {
type:
| ApplicationCommandOptionType.BOOLEAN
| ApplicationCommandOptionType.USER
| ApplicationCommandOptionType.CHANNEL
| ApplicationCommandOptionType.ROLE;
name: string;
description: string;
default?: boolean;
required?: boolean;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
*/
export type APIApplicationCommandOption =
| APIApplicationCommandArgumentOptions
| APIApplicationCommandSubCommandOptions
| APIApplicationCommandOptionBase;
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
*/
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.SUB_COMMAND | ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options?: APIApplicationCommandOption[];
}
/**
* This type is exported as a way to make it stricter for you when you're writing your commands
*
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
* but they can have a `choices` one
*/
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
type: ApplicationCommandOptionType.STRING | ApplicationCommandOptionType.INTEGER;
choices?: APIApplicationCommandOptionChoice[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
*/
export enum ApplicationCommandOptionType {
SUB_COMMAND = 1,
SUB_COMMAND_GROUP,
STRING,
INTEGER,
BOOLEAN,
USER,
CHANNEL,
ROLE,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
*/
export interface APIApplicationCommandOptionChoice {
name: string;
value: string | number;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIBaseInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* ID of the application this interaction is for
*/
application_id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The command data payload
*/
data?: APIApplicationCommandInteractionData;
/**
* The channel it was sent from
*/
channel_id?: Snowflake;
/**
* A continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always `1`
*/
version: 1;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIGuildInteraction extends APIBaseInteraction {
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 enum InteractionType {
Ping = 1,
ApplicationCommand,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: Snowflake;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
resolved?: {
users?: Record<string, APIUser>;
roles?: Record<string, APIRole>;
members?: Record<string, Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> & { permissions: Permissions }>;
channels?: Record<string, Required<APIPartialChannel> & { permissions: Permissions }>;
};
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
*/
export type APIApplicationCommandInteractionDataOption =
| ApplicationCommandInteractionDataOptionSubCommand
| ApplicationCommandInteractionDataOptionSubCommandGroup
| APIApplicationCommandInteractionDataOptionWithValues;
export interface ApplicationCommandInteractionDataOptionSubCommand {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND;
options: APIApplicationCommandInteractionDataOptionWithValues[];
}
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
name: string;
type: ApplicationCommandOptionType.SUB_COMMAND_GROUP;
options: ApplicationCommandInteractionDataOptionSubCommand[];
}
export type APIApplicationCommandInteractionDataOptionWithValues =
| ApplicationCommandInteractionDataOptionString
| ApplicationCommandInteractionDataOptionRole
| ApplicationCommandInteractionDataOptionChannel
| ApplicationCommandInteractionDataOptionUser
| ApplicationCommandInteractionDataOptionInteger
| ApplicationCommandInteractionDataOptionBoolean;
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
ApplicationCommandOptionType.STRING,
string
>;
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
ApplicationCommandOptionType.ROLE,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
ApplicationCommandOptionType.CHANNEL,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
ApplicationCommandOptionType.USER,
Snowflake
>;
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
ApplicationCommandOptionType.INTEGER,
number
>;
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
ApplicationCommandOptionType.BOOLEAN,
boolean
>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseChannelMessageWithSource
| APIInteractionResponseDeferredChannelMessageWithSource;
export interface APIInteractionResponsePong {
type: InteractionResponseType.Pong;
}
export interface APIInteractionResponseChannelMessageWithSource {
type: InteractionResponseType.ChannelMessageWithSource;
data: APIInteractionApplicationCommandCallbackData;
}
export interface APIInteractionResponseDeferredChannelMessageWithSource {
type: InteractionResponseType.DeferredChannelMessageWithSource;
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
*/
export enum InteractionResponseType {
/**
* ACK a `Ping`
*/
Pong = 1,
/**
* Respond to an interaction with a message
*/
ChannelMessageWithSource = 4,
/**
* ACK an interaction and edit to a response later, the user sees a loading state
*/
DeferredChannelMessageWithSource,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
*/
export type APIInteractionApplicationCommandCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };
/**
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
*/
export interface APIMessageInteraction {
/**
* ID of the interaction
*/
id: Snowflake;
/**
* The type of interaction
*/
type: InteractionType;
/**
* The name of the ApplicationCommand
*/
name: string;
/**
* The user who invoked the interaction
*/
user: APIUser;
}
/**
* @internal
*/
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
name: string;
type: T;
value: D;
}

View File

@@ -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,
}

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APITeam } from './teams.ts';
import type { APIUser } from './user.ts';
@@ -12,7 +13,7 @@ export interface APIApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -63,11 +64,11 @@ export interface APIApplication {
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: string;
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
@@ -79,10 +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
*/

View File

@@ -2,13 +2,14 @@
* Types extracted from https://discord.com/developers/docs/topics/permissions
*/
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,
@@ -42,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;
/**
@@ -57,7 +59,7 @@ export interface APIRole {
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Role name
*/
@@ -79,7 +81,7 @@ export interface APIRole {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions: string;
permissions: Permissions;
/**
* Whether this role is managed by an integration
*/
@@ -101,7 +103,7 @@ export interface APIRoleTags {
/**
* The id of the bot this role belongs to
*/
bot_id?: string;
bot_id?: Snowflake;
/**
* Whether this is the guild's premium subscriber role
*/
@@ -109,5 +111,5 @@ export interface APIRoleTags {
/**
* The id of the integration this role belongs to
*/
integration_id?: string;
integration_id?: Snowflake;
}

View File

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

View File

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

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/user
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APIGuildIntegration } from './guild.ts';
/**
@@ -11,7 +12,7 @@ export interface APIUser {
/**
* The user's id
*/
id: string;
id: Snowflake;
/**
* The user's username, not unique across the platform
*/
@@ -73,7 +74,7 @@ export interface APIUser {
/**
* https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
export const enum UserFlags {
export enum UserFlags {
None = 0,
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
@@ -93,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,
@@ -145,7 +146,7 @@ export interface APIConnection {
visibility: ConnectionVisibility;
}
export const enum ConnectionVisibility {
export enum ConnectionVisibility {
/**
* Invisible to everyone except the user themselves
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/voice
*/
import type { Snowflake } from '../../common/mod.ts';
import type { APIGuildMember } from './guild.ts';
/**
@@ -11,15 +12,15 @@ export interface GatewayVoiceState {
/**
* The guild id this voice state is for
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The channel id this user is connected to
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* The user id this voice state is for
*/
user_id: string;
user_id: Snowflake;
/**
* The guild member this voice state is for
*

View File

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

View File

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

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../common/mod.ts';
import type {
APIAllowedMentions,
APIChannel,
@@ -86,7 +87,7 @@ export interface RESTPatchAPIChannelJSONBody {
*
* Channel types: text, news, store, voice
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
}
/**
@@ -106,15 +107,15 @@ export interface RESTGetAPIChannelMessagesQuery {
/**
* Get messages around this message ID
*/
around?: string;
around?: Snowflake;
/**
* Get messages before this message ID
*/
before?: string;
before?: Snowflake;
/**
* Get messages after this message ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of messages to return (1-100)
*
@@ -133,7 +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
@@ -150,7 +162,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
/**
* `true` if this is a TTS message
*/
tts?: true;
tts?: boolean;
/**
* Embedded `rich` content
*
@@ -224,11 +236,11 @@ export interface RESTGetAPIChannelMessageReactionUsersQuery {
/**
* Get users before this user ID
*/
before?: string;
before?: Snowflake;
/**
* Get users after this user ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of users to return (1-100)
*
@@ -294,7 +306,7 @@ export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody {
/**
* An array of message ids to delete (2-100)
*/
messages: string[];
messages: Snowflake[];
}
/**
@@ -311,13 +323,13 @@ export interface RESTPutAPIChannelPermissionJSONBody {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* The bitwise value of all disallowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
/**
* `0` for a role or `1` for a member
*/
@@ -390,7 +402,7 @@ export interface RESTPostAPIChannelFollowersJSONBody {
/**
* ID of target channel
*/
webhook_channel_id: string;
webhook_channel_id: Snowflake;
}
/**

View File

@@ -1,3 +1,4 @@
import type { Snowflake } from '../../common/mod.ts';
import type { APIEmoji } from '../payloads/mod.ts';
/**
@@ -27,7 +28,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[];
roles?: Snowflake[];
}
/**
@@ -46,7 +47,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
}
/**

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../common/mod.ts';
import type {
APIBan,
APIChannel,
@@ -30,7 +31,7 @@ export type APIGuildCreatePartialChannel = Partial<
> & {
name: string;
id?: number | string;
parent_id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
@@ -105,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: number | string;
afk_channel_id?: number | Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -113,7 +114,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: number | string;
system_channel_id?: number | Snowflake | null;
/**
* System channel flags
*
@@ -184,7 +185,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: string | null;
afk_channel_id?: Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -198,7 +199,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* User id to transfer guild ownership to (must be owner)
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature)
*
@@ -216,7 +217,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: string | null;
system_channel_id?: Snowflake | null;
/**
* System channel flags
*
@@ -226,11 +227,11 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where Community guilds display rules and/or guidelines
*/
rules_channel_id?: string | null;
rules_channel_id?: Snowflake | null;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id?: string | null;
public_updates_channel_id?: Snowflake | null;
/**
* The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US"
*
@@ -281,7 +282,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the channel
*/
@@ -293,7 +294,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* The new parent id of this channel
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
}>;
/**
@@ -321,7 +322,7 @@ export interface RESTGetAPIGuildMembersQuery {
*
* @default 0
*/
after?: string;
after?: Snowflake;
}
/**
@@ -363,7 +364,7 @@ export interface RESTPutAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[];
roles?: Snowflake[];
/**
* Whether the user is muted in voice channels
*
@@ -395,7 +396,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
/**
* Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel
*
@@ -413,7 +414,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: string | null;
channel_id?: Snowflake | null;
}
/**
@@ -507,7 +508,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
*
* @default "default role permissions in guild"
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*
@@ -540,7 +541,7 @@ export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the role
*/
@@ -563,7 +564,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*/
@@ -635,7 +636,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
/**
* Role(s) to include
*/
include_roles?: string[];
include_roles?: Snowflake[];
}
/**
@@ -665,7 +666,7 @@ export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[];
*/
export interface RESTPostAPIGuildIntegrationJSONBody {
type: string;
id: string;
id: Snowflake;
}
export type RESTPostAPIGuildIntegrationResult = never;

View File

@@ -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
*/

View File

@@ -1,3 +1,5 @@
import type { Snowflake } from '../../common/mod.ts';
export * from './auditLog.ts';
export * from './channel.ts';
export * from './emoji.ts';
@@ -17,8 +19,8 @@ export const Routes = {
* Route for:
* - GET `/guilds/{guild.id}/audit-logs`
*/
guildAuditLog(guildID: string) {
return `/guilds/${guildID}/audit-logs`;
guildAuditLog(guildID: Snowflake) {
return `/guilds/${guildID}/audit-logs` as const;
},
/**
@@ -27,8 +29,8 @@ export const Routes = {
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelID: string) {
return `/channels/${channelID}`;
channel(channelID: Snowflake) {
return `/channels/${channelID}` as const;
},
/**
@@ -36,8 +38,8 @@ export const Routes = {
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelID: string) {
return `/channels/${channelID}/messages`;
channelMessages(channelID: Snowflake) {
return `/channels/${channelID}/messages` as const;
},
/**
@@ -46,16 +48,16 @@ export const Routes = {
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}`;
channelMessage(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelMessageCrosspost(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/crosspost`;
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
},
/**
@@ -65,8 +67,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`;
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
},
/**
@@ -75,8 +77,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`;
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
},
/**
@@ -86,24 +88,24 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions`;
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelID: string) {
return `/channels/${channelID}/messages/bulk-delete`;
channelBulkDelete(channelID: Snowflake) {
return `/channels/${channelID}/messages/bulk-delete` as const;
},
/**
@@ -111,8 +113,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermission(channelID: string, overwriteID: string) {
return `/channels/${channelID}/permissions/${overwriteID}`;
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
return `/channels/${channelID}/permissions/${overwriteID}` as const;
},
/**
@@ -120,32 +122,32 @@ export const Routes = {
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvites(channelID: string) {
return `/channels/${channelID}/invites`;
channelInvites(channelID: Snowflake) {
return `/channels/${channelID}/invites` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/followers`
*/
channelFollowers(channelID: string) {
return `/channels/${channelID}/followers`;
channelFollowers(channelID: Snowflake) {
return `/channels/${channelID}/followers` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/typing`
*/
channelTyping(channelID: string) {
return `/channels/${channelID}/typing`;
channelTyping(channelID: Snowflake) {
return `/channels/${channelID}/typing` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/pins`
*/
channelPins(channelID: string) {
return `/channels/${channelID}/pins`;
channelPins(channelID: Snowflake) {
return `/channels/${channelID}/pins` as const;
},
/**
@@ -153,8 +155,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelID: string, messageID: string) {
return `/channels/${channelID}/pins/${messageID}`;
channelPin(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/pins/${messageID}` as const;
},
/**
@@ -162,8 +164,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelID: string, userID: string) {
return `/channels/${channelID}/recipients/${userID}`;
channelRecipient(channelID: Snowflake, userID: Snowflake) {
return `/channels/${channelID}/recipients/${userID}` as const;
},
/**
@@ -171,8 +173,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildID: string) {
return `/guilds/${guildID}/emojis`;
guildEmojis(guildID: Snowflake) {
return `/guilds/${guildID}/emojis` as const;
},
/**
@@ -181,8 +183,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildID: string, emojiID: string) {
return `/guilds/${guildID}/emojis/${emojiID}`;
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
return `/guilds/${guildID}/emojis/${emojiID}` as const;
},
/**
@@ -190,7 +192,7 @@ export const Routes = {
* - POST `/guilds`
*/
guilds() {
return '/guilds';
return '/guilds' as const;
},
/**
@@ -199,16 +201,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildID: string) {
return `/guilds/${guildID}`;
guild(guildID: Snowflake) {
return `/guilds/${guildID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/preview`
*/
guildPreview(guildID: string) {
return `/guilds/${guildID}/preview`;
guildPreview(guildID: Snowflake) {
return `/guilds/${guildID}/preview` as const;
},
/**
@@ -217,8 +219,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildID: string) {
return `/guilds/${guildID}/channels`;
guildChannels(guildID: Snowflake) {
return `/guilds/${guildID}/channels` as const;
},
/**
@@ -228,32 +230,32 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildID: string, userID: string) {
return `/guilds/${guildID}/members/${userID}`;
guildMember(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/members/${userID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members`
*/
guildMembers(guildID: string) {
return `/guilds/${guildID}/members`;
guildMembers(guildID: Snowflake) {
return `/guilds/${guildID}/members` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/search`
*/
guildMembersSearch(guildID: string) {
return `/guilds/${guildID}/members/search`;
guildMembersSearch(guildID: Snowflake) {
return `/guilds/${guildID}/members/search` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/members/@me/nick`
*/
guildCurrentMemberNickname(guildID: string) {
return `/guilds/${guildID}/members/@me/nick`;
guildCurrentMemberNickname(guildID: Snowflake) {
return `/guilds/${guildID}/members/@me/nick` as const;
},
/**
@@ -261,16 +263,16 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
*/
guildMemberRole(guildID: string, memberID: string, roleID: string) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans`
*/
guildBans(guildID: string) {
return `/guilds/${guildID}/bans`;
guildBans(guildID: Snowflake) {
return `/guilds/${guildID}/bans` as const;
},
/**
@@ -279,8 +281,8 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildID: string, userID: string) {
return `/guilds/${guildID}/bans/${userID}`;
guildBan(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/bans/${userID}` as const;
},
/**
@@ -289,8 +291,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildID: string) {
return `/guilds/${guildID}/roles`;
guildRoles(guildID: Snowflake) {
return `/guilds/${guildID}/roles` as const;
},
/**
@@ -298,8 +300,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildID: string, roleID: string) {
return `/guilds/${guildID}/roles/${roleID}`;
guildRole(guildID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/roles/${roleID}` as const;
},
/**
@@ -307,24 +309,24 @@ export const Routes = {
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildID: string) {
return `/guilds/${guildID}/prune`;
guildPrune(guildID: Snowflake) {
return `/guilds/${guildID}/prune` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/regions`
*/
guildVoiceRegions(guildID: string) {
return `/guilds/${guildID}/regions`;
guildVoiceRegions(guildID: Snowflake) {
return `/guilds/${guildID}/regions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/invites`
*/
guildInvites(guildID: string) {
return `/guilds/${guildID}/invites`;
guildInvites(guildID: Snowflake) {
return `/guilds/${guildID}/invites` as const;
},
/**
@@ -332,8 +334,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/integrations`
* - POST `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildID: string) {
return `/guilds/${guildID}/integrations`;
guildIntegrations(guildID: Snowflake) {
return `/guilds/${guildID}/integrations` as const;
},
/**
@@ -341,16 +343,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/integrations/{integration.id}`
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}`;
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}` as const;
},
/**
* Route for:
* - POST `/guilds/{guild.id}/integrations/{integration.id}/sync`
*/
guildIntegrationSync(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}/sync`;
guildIntegrationSync(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}/sync` as const;
},
/**
@@ -358,32 +360,32 @@ export const Routes = {
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildID: string) {
return `/guilds/${guildID}/widget`;
guildWidgetSettings(guildID: Snowflake) {
return `/guilds/${guildID}/widget` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidgetJSON(guildID: string) {
return `/guilds/${guildID}/widget.json`;
guildWidgetJSON(guildID: Snowflake) {
return `/guilds/${guildID}/widget.json` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/vanity-url`
*/
guildVanityUrl(guildID: string) {
return `/guilds/${guildID}/vanity-url`;
guildVanityUrl(guildID: Snowflake) {
return `/guilds/${guildID}/vanity-url` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.png`
*/
guildWidgetImage(guildID: string) {
return `/guilds/${guildID}/widget.png`;
guildWidgetImage(guildID: Snowflake) {
return `/guilds/${guildID}/widget.png` as const;
},
/**
@@ -392,7 +394,7 @@ export const Routes = {
* - DELETE `/invites/{invite.code}`
*/
invite(code: string) {
return `/invites/${code}`;
return `/invites/${code}` as const;
},
/**
@@ -401,7 +403,7 @@ export const Routes = {
* - POST `/guilds/templates/{template.code}`
*/
template(code: string) {
return `/guilds/templates/${code}`;
return `/guilds/templates/${code}` as const;
},
/**
@@ -409,8 +411,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildID: string) {
return `/guilds/${guildID}/templates`;
guildTemplates(guildID: Snowflake) {
return `/guilds/${guildID}/templates` as const;
},
/**
@@ -419,8 +421,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildID: string, code: string) {
return `/guilds/${guildID}/templates/${code}`;
guildTemplate(guildID: Snowflake, code: string) {
return `/guilds/${guildID}/templates/${code}` as const;
},
/**
@@ -432,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;
},
/**
@@ -440,15 +442,15 @@ export const Routes = {
* - GET `/users/@me/guilds`
*/
userGuilds() {
return `/users/@me/guilds`;
return `/users/@me/guilds` as const;
},
/**
* Route for:
* - DELETE `/users/@me/guilds/{guild.id}`
*/
userGuild(guildID: string) {
return `/users/@me/guilds/${guildID}`;
userGuild(guildID: Snowflake) {
return `/users/@me/guilds/${guildID}` as const;
},
/**
@@ -456,7 +458,7 @@ export const Routes = {
* - POST `/users/@me/channels`
*/
userChannels() {
return `/users/@me/channels`;
return `/users/@me/channels` as const;
},
/**
@@ -464,7 +466,7 @@ export const Routes = {
* - GET `/users/@me/connections`
*/
userConnections() {
return `/users/@me/connections`;
return `/users/@me/connections` as const;
},
/**
@@ -472,7 +474,7 @@ export const Routes = {
* - GET `/voice/regions`
*/
voiceRegions() {
return `/voice/regions`;
return `/voice/regions` as const;
},
/**
@@ -480,16 +482,16 @@ export const Routes = {
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
*/
channelWebhooks(channelID: string) {
return `/channels/${channelID}/webhooks`;
channelWebhooks(channelID: Snowflake) {
return `/channels/${channelID}/webhooks` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/webhooks`
*/
guildWebhooks(guildID: string) {
return `/guilds/${guildID}/webhooks`;
guildWebhooks(guildID: Snowflake) {
return `/guilds/${guildID}/webhooks` as const;
},
/**
@@ -504,12 +506,12 @@ export const Routes = {
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookID: string, webhookToken?: string) {
webhook(webhookID: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookID];
if (webhookToken) parts.push(webhookToken);
return parts.join('/');
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
},
/**
@@ -525,8 +527,8 @@ export const Routes = {
*
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
},
/**
@@ -534,8 +536,8 @@ export const Routes = {
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
},
/**
@@ -543,7 +545,7 @@ export const Routes = {
* - GET `/gateway`
*/
gateway() {
return `/gateway`;
return `/gateway` as const;
},
/**
@@ -551,7 +553,7 @@ export const Routes = {
* - GET `/gateway/bot`
*/
gatewayBot() {
return `/gateway/bot`;
return `/gateway/bot` as const;
},
/**
@@ -559,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;
},
/**
@@ -567,17 +577,18 @@ export const Routes = {
* - GET `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationID: string) {
return `/applications/${applicationID}/commands`;
applicationCommands(applicationID: Snowflake) {
return `/applications/${applicationID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationID: string, commandID: string) {
return `/applications/${applicationID}/commands/${commandID}`;
applicationCommand(applicationID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/commands/${commandID}` as const;
},
/**
@@ -585,25 +596,26 @@ export const Routes = {
* - GET `/applications/{application.id}/guilds/{guild.id}/commands`
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
*/
applicationGuildCommands(applicationID: string, guildID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands`;
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
applicationGuildCommand(applicationID: string, guildID: string, commandID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`;
applicationGuildCommand(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionID: string, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback`;
interactionCallback(interactionID: Snowflake, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
},
/**
@@ -611,11 +623,25 @@ export const Routes = {
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildID: string) {
return `/guilds/${guildID}/member-verification`;
guildMemberVerification(guildID: Snowflake) {
return `/guilds/${guildID}/member-verification` as const;
},
};
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`,
@@ -626,7 +652,7 @@ export const OAuth2Routes = {
} as const;
/**
* Freeze route object
* Freeze OAuth2 route object
* @internal
*/
Object.freeze(OAuth2Routes);

View File

@@ -1,16 +1,39 @@
import type { APIApplication, APIGuild, APIWebhook, OAuth2Scopes } from '../payloads/mod.ts';
import type { Permissions, Snowflake } from '../../common/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
*/
export interface RESTOAuth2AuthorizationQuery {
response_type: 'code';
client_id: string;
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
@@ -29,7 +52,7 @@ export interface RESTOAuth2AuthorizationQueryResult {
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-redirect-url-example
*/
export interface RESTPostOAuth2AccessTokenURLEncodedData {
client_id: string;
client_id: Snowflake;
client_secret: string;
grant_type: 'authorization_code';
code: string;
@@ -52,7 +75,7 @@ export interface RESTPostOAuth2AccessTokenResult {
* https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example
*/
export interface RESTPostOAuth2RefreshTokenURLEncodedData {
client_id: string;
client_id: Snowflake;
client_secret: string;
grant_type: 'refresh_token';
refresh_token: string;
@@ -67,7 +90,7 @@ export type RESTPostOAuth2RefreshTokenResult = RESTPostOAuth2AccessTokenResult;
*/
export interface RESTOAuth2ImplicitAuthorizationQuery {
response_type: 'token';
client_id: string;
client_id: Snowflake;
scope: string;
redirect_uri?: string;
state?: string;
@@ -96,7 +119,7 @@ export interface RESTOAuth2BotAuthorizationQuery {
/**
* Your app's client id
*/
client_id: string;
client_id: Snowflake;
/**
* Needs to include bot for the bot flow
*/
@@ -110,11 +133,11 @@ export interface RESTOAuth2BotAuthorizationQuery {
*
* See https://discord.com/developers/docs/topics/permissions
*/
permissions?: string;
permissions?: Permissions;
/**
* Pre-fills the dropdown picker with a guild for the user
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* `true` or `false`disallows the user from changing the guild dropdown
*/
@@ -125,7 +148,7 @@ export interface RESTOAuth2BotAuthorizationQuery {
* https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization
*/
export interface RESTOAuth2AdvancedBotAuthorizationQuery {
client_id: string;
client_id: Snowflake;
/**
* This assumes you include the `bot` scope alongside others (like `identify` for example)
*/
@@ -137,8 +160,8 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
/**
* The required permissions bitfield, stringified
*/
permissions?: string;
guild_id?: string;
permissions?: Permissions;
guild_id?: Snowflake;
disable_guild_select?: boolean;
response_type: string;
redirect_uri?: string;
@@ -147,8 +170,8 @@ export interface RESTOAuth2AdvancedBotAuthorizationQuery {
export interface RESTOAuth2AdvancedBotAuthorizationQueryResult {
code: string;
state?: string;
guild_id: string;
permissions: string;
guild_id: Snowflake;
permissions: Permissions;
}
/**

View File

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

View File

@@ -1,3 +1,4 @@
import type { Snowflake } from '../../common/mod.ts';
import type { APIAllowedMentions, APIEmbed, APIMessage, APIWebhook } from '../payloads/mod.ts';
/**
@@ -58,7 +59,7 @@ export interface RESTPatchAPIWebhookJSONBody {
/**
* The new channel id this webhook should be moved to
*/
channel_id?: string;
channel_id?: Snowflake;
}
/**
@@ -206,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

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
{
"name": "discord-api-types",
"version": "0.12.0",
"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",
@@ -47,27 +47,28 @@
"common/*",
"!**/*.ts",
"**/*.d.ts",
"!\\.deno/*"
"!deno/*"
],
"engines": {
"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"
}
},

View File

@@ -1,22 +1,15 @@
/* 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);
const denoPath = new URL('deno/', baseDirectory);
// Remove existing deno built files
try {
await rm(denoPath, { recursive: true });
} catch {}
// Create .deno folder
// Create deno folder
await mkdir(denoPath);
/**
@@ -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/', //

View File

@@ -4,5 +4,5 @@
"allowJs": true,
"checkJs": true
},
"include": ["common", "default", "v6", "v8", "scripts"]
"include": ["common", "default", "v6", "v8", "scripts", "deno"]
}

View File

@@ -2,7 +2,11 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../common/index';
import type {
APIApplication,
APIApplicationCommand,
APIApplicationCommandInteraction,
APIChannel,
APIEmoji,
APIGuild,
@@ -16,8 +20,6 @@ import type {
GatewayVoiceState,
InviteTargetUserType,
PresenceUpdateStatus,
APIApplicationCommandInteraction,
APIApplication,
} from '../payloads/index';
export const GatewayVersion = '8';
@@ -31,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,
/**
@@ -288,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',
}
@@ -344,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
*/
@@ -550,11 +607,11 @@ export interface GatewayChannelPinsUpdateDispatchData {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The time at which the most recent pinned message was pinned
*/
@@ -623,7 +680,7 @@ export interface GatewayGuildBanModifyDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The banned user
*
@@ -667,7 +724,7 @@ export interface GatewayGuildEmojisUpdateDispatchData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Array of emojis
*
@@ -691,7 +748,7 @@ export interface GatewayGuildIntegrationsUpdateDispatchData {
/**
* ID of the guild whose integrations were updated
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -709,7 +766,7 @@ export interface GatewayGuildMemberAddDispatchData extends APIGuildMember {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
}
/**
@@ -727,7 +784,7 @@ export interface GatewayGuildMemberRemoveDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The user who was removed
*
@@ -751,7 +808,7 @@ export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' |
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
};
/**
@@ -769,7 +826,7 @@ export interface GatewayGuildMembersChunkDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Set of guild members
*
@@ -819,7 +876,7 @@ export interface GatewayGuildRoleModifyDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The role created or updated
*
@@ -863,11 +920,11 @@ export interface GatewayGuildRoleDeleteDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the role
*/
role_id: string;
role_id: Snowflake;
}
/**
@@ -898,7 +955,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The channel the invite is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The unique invite code
*
@@ -912,7 +969,7 @@ export interface GatewayInviteCreateDispatchData {
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The user that created the invite
*
@@ -964,11 +1021,11 @@ export interface GatewayInviteDeleteDispatchData {
/**
* The channel of the invite
*/
channel_id: string;
channel_id: Snowflake;
/**
* The guild of the invite
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The unique invite code
*
@@ -1002,8 +1059,8 @@ export type GatewayMessageUpdateDispatch = DataPayload<
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatchData = {
id: string;
channel_id: string;
id: Snowflake;
channel_id: Snowflake;
} & Partial<APIMessage>;
/**
@@ -1021,15 +1078,15 @@ export interface GatewayMessageDeleteDispatchData {
/**
* The id of the message
*/
id: string;
id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1047,15 +1104,15 @@ export interface GatewayMessageDeleteBulkDispatchData {
/**
* The ids of the messages
*/
ids: string[];
ids: Snowflake[];
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -1134,15 +1191,15 @@ export interface GatewayTypingStartDispatchData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* Unix time (in seconds) of when the user started typing
*/
@@ -1197,7 +1254,7 @@ export interface GatewayVoiceServerUpdateDispatchData {
/**
* The guild this voice server update is for
*/
guild_id: string;
guild_id: Snowflake;
/**
* The voice server host
*/
@@ -1219,11 +1276,11 @@ export interface GatewayWebhooksUpdateDispatchData {
/**
* The id of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
}
// #endregion Dispatch Payloads
@@ -1364,7 +1421,7 @@ export interface GatewayRequestGuildMembersData {
/**
* ID of the guild to get members for
*/
guild_id: string | string[];
guild_id: Snowflake;
/**
* String that username starts with, or an empty string to return all members
*/
@@ -1381,7 +1438,7 @@ export interface GatewayRequestGuildMembersData {
/**
* Used to specify which users you wish to fetch
*/
user_ids?: string | string[];
user_ids?: Snowflake | Snowflake[];
/**
* Nonce to identify the Guild Members Chunk response
*
@@ -1405,11 +1462,11 @@ export interface GatewayVoiceStateUpdateData {
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* ID of the voice channel client wants to join (`null` if disconnecting)
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* Is the client muted
*/
@@ -1496,19 +1553,19 @@ type ReactionData<E extends GatewayDispatchEvents, O extends string = never> = D
/**
* The id of the user
*/
user_id: string;
user_id: Snowflake;
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The member who reacted if this happened in a guild
*
@@ -1530,14 +1587,14 @@ interface MessageReactionRemoveData {
/**
* The id of the channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* The id of the message
*/
message_id: string;
message_id: Snowflake;
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
// #endregion Shared

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/audit-log
*/
import type { Snowflake } from '../../common/index';
import type { APIOverwrite, ChannelType } from './channel';
import type {
APIGuildIntegration,
@@ -65,11 +66,11 @@ export interface APIAuditLogEntry {
* *Against all odds, this can be `null` in some cases (webhooks deleting themselves
* by using their own token, for example)*
*/
user_id: string | null;
user_id: Snowflake | null;
/**
* ID of the entry
*/
id: string;
id: Snowflake;
/**
* Type of action that occurred
*
@@ -165,7 +166,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_UNPIN
* - MESSAGE_DELETE
*/
channel_id?: string;
channel_id?: Snowflake;
/**
* ID of the message that was targeted
@@ -174,7 +175,7 @@ export interface APIAuditLogOptions {
* - MESSAGE_PIN
* - MESSAGE_UNPIN
*/
message_id?: string;
message_id?: Snowflake;
/**
* Number of entities that were targeted
@@ -195,7 +196,7 @@ export interface APIAuditLogOptions {
* - CHANNEL_OVERWRITE_UPDATE
* - CHANNEL_OVERWRITE_DELETE
*/
id?: string;
id?: Snowflake;
/**
* Type of overwritten entity - "0" for "role" or "1" for "member"
@@ -232,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
@@ -277,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
*/
@@ -295,25 +308,50 @@ export type APIAuditLogChangeKeyIconHash = AuditLogChangeData<'icon_hash', strin
export type APIAuditLogChangeKeySplashHash = AuditLogChangeData<'splash_hash', string>;
/**
* Returned when a guild's owner ID is changed
* Returned when a guild's discovery splash is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', string>;
export type APIAuditLogChangeKeyDiscoverySplashHash = AuditLogChangeData<'discovery_splash_hash', string>;
/**
* Returned when a guild's banner hash is changed
*/
export type APIAuditLogChangeKeyBannerHash = AuditLogChangeData<'banner_hash', string>;
/**
* Returned when a guild's owner_id is changed
*/
export type APIAuditLogChangeKeyOwnerID = AuditLogChangeData<'owner_id', Snowflake>;
/**
* Returned when a guild's region is changed
*/
export type APIAuditLogChangeKeyRegion = AuditLogChangeData<'region', string>;
/**
* Returned when a guild's preferred_locale is changed
*/
export type APIAuditLogChangeKeyPreferredLocale = AuditLogChangeData<'preferred_locale', string>;
/**
* Returned when a guild's afk_channel_id is changed
*/
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', string>;
export type APIAuditLogChangeKeyAFKChannelID = AuditLogChangeData<'afk_channel_id', Snowflake>;
/**
* Returned when a guild's afk_timeout is changed
*/
export type APIAuditLogChangeKeyAFKTimeout = AuditLogChangeData<'afk_timeout', number>;
/**
* Returned when a guild's rules_channel_id is changed
*/
export type APIAuditLogChangeKeyRulesChannelID = AuditLogChangeData<'rules_channel_id', string>;
/**
* Returned when a guild's public_updates_channel_id is changed
*/
export type APIAuditLogChangeKeyPublicUpdatesChannelID = AuditLogChangeData<'public_updates_channel_id', string>;
/**
* Returned when a guild's mfa_level is changed
*/
@@ -368,12 +406,12 @@ export type APIAuditLogChangeKeyWidgetEnabled = AuditLogChangeData<'widget_enabl
/**
* Returned when a guild's widget_channel_id is changed
*/
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', string>;
export type APIAuditLogChangeKeyWidgetChannelID = AuditLogChangeData<'widget_channel_id', Snowflake>;
/**
* Returned when a guild's system_channel_id is changed
*/
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', string>;
export type APIAuditLogChangeKeySystemChannelID = AuditLogChangeData<'system_channel_id', Snowflake>;
/**
* Returned when a channel's position is changed
@@ -403,7 +441,7 @@ export type APIAuditLogChangeKeyNSFW = AuditLogChangeData<'nsfw', boolean>;
/**
* The application ID of the added or removed Webhook or Bot
*/
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', string>;
export type APIAuditLogChangeKeyApplicationID = AuditLogChangeData<'application_id', Snowflake>;
/**
* Returned when a channel's amount of seconds a user has to wait before sending another message
@@ -449,12 +487,12 @@ export type APIAuditLogChangeKeyCode = AuditLogChangeData<'code', string>;
/**
* Returned when an invite's channel_id is changed
*/
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', string>;
export type APIAuditLogChangeKeyChannelID = AuditLogChangeData<'channel_id', Snowflake>;
/**
* Returned when an invite's inviter_id is changed
*/
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', string>;
export type APIAuditLogChangeKeyInviterID = AuditLogChangeData<'inviter_id', Snowflake>;
/**
* Returned when an invite's max_uses is changed
@@ -499,7 +537,7 @@ export type APIAuditLogChangeKeyAvatarHash = AuditLogChangeData<'avatar_hash', s
/**
* The ID of the changed entity - sometimes used in conjunction with other keys
*/
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', string>;
export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>;
/**
* The type of entity created
@@ -522,10 +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;
}

View File

@@ -2,8 +2,11 @@
* Types extracted from https://discord.com/developers/docs/resources/channel
*/
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';
/**
@@ -13,7 +16,7 @@ export interface APIPartialChannel {
/**
* The id of the channel
*/
id: string;
id: Snowflake;
/**
* The type of the channel
*
@@ -33,7 +36,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* The id of the guild
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* Sorting position of the channel
*/
@@ -55,7 +58,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: string | null;
last_message_id?: Snowflake | null;
/**
* The bitrate (in bits) of the voice channel
*/
@@ -82,15 +85,15 @@ export interface APIChannel extends APIPartialChannel {
/**
* ID of the DM creator
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* Application id of the group DM creator if it is bot-created
*/
application_id?: string;
application_id?: Snowflake;
/**
* ID of the parent category for a channel (each parent category can contain up to 50 channels)
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
/**
* When the last pinned message was pinned.
* This may be `null` in events such as `GUILD_CREATE` when a message is not pinned
@@ -145,15 +148,15 @@ export interface APIMessage {
/**
* ID of the message
*/
id: string;
id: Snowflake;
/**
* ID of the channel the message was sent in
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the guild the message was sent in
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The author of this message (only a valid user in the case where the message is generated by a user or bot user)
*
@@ -207,7 +210,7 @@ export interface APIMessage {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
mention_roles: string[];
mention_roles: APIRole['id'][];
/**
* Channels specifically mentioned in this message
*
@@ -252,7 +255,7 @@ export interface APIMessage {
/**
* If the message is generated by a webhook, this is the webhook's id
*/
webhook_id?: string;
webhook_id?: Snowflake;
/**
* Type of message
*
@@ -305,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;
}
/**
@@ -357,7 +364,7 @@ export interface APIMessageApplication {
/**
* ID of the application
*/
id: string;
id: Snowflake;
/**
* ID of the embed's image asset
*/
@@ -383,15 +390,15 @@ export interface APIMessageReference {
/**
* ID of the originating message
*/
message_id?: string;
message_id?: Snowflake;
/**
* ID of the originating message's channel
*/
channel_id: string;
channel_id: Snowflake;
/**
* ID of the originating message's guild
*/
guild_id?: string;
guild_id?: Snowflake;
}
/**
@@ -438,11 +445,11 @@ export interface APISticker {
/**
* ID of the sticker
*/
id: string;
id: Snowflake;
/**
* ID of the pack the sticker is from
*/
pack_id: string;
pack_id: Snowflake;
/**
* Name of the sticker
*/
@@ -487,11 +494,11 @@ export interface APIFollowedChannel {
/**
* Source channel id
*/
channel_id: string;
channel_id: Snowflake;
/**
* Created target webhook id
*/
webhook_id: string;
webhook_id: Snowflake;
}
/**
@@ -521,7 +528,7 @@ export interface APIOverwrite {
/**
* Role or user id
*/
id: string;
id: Snowflake;
/**
* Either 0 (role) or 1 (member)
*
@@ -535,7 +542,7 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* Permission bit set
*
@@ -543,7 +550,7 @@ export interface APIOverwrite {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
}
export const enum OverwriteType {
@@ -815,7 +822,7 @@ export interface APIAttachment {
/**
* Attachment id
*/
id: string;
id: Snowflake;
/**
* Name of file attached
*/
@@ -849,11 +856,11 @@ export interface APIChannelMention {
/**
* ID of the channel
*/
id: string;
id: Snowflake;
/**
* ID of the guild containing the channel
*/
guild_id: string;
guild_id: Snowflake;
/**
* The type of channel
*
@@ -897,11 +904,11 @@ export interface APIAllowedMentions {
/**
* Array of role_ids to mention (Max size of 100)
*/
roles?: string[];
roles?: Snowflake[];
/**
* Array of user_ids to mention (Max size of 100)
*/
users?: string[];
users?: Snowflake[];
/**
* For replies, whether to mention the author of the message being replied to (default false)
*

View File

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

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/gateway
*/
import type { Snowflake } from '../../common/index';
import type { APIEmoji } from './emoji';
import type { APIUser } from './user';
@@ -67,13 +68,11 @@ export interface GatewayPresenceUpdate {
*
* See https://discord.com/developers/docs/resources/user#user-object
*/
user: Partial<APIUser> & {
id: string;
};
user: Partial<APIUser> & Pick<APIUser, 'id'>;
/**
* ID of the guild
*/
guild_id: string;
guild_id: Snowflake;
/**
* Either "idle", "dnd", "online", or "offline"
*/
@@ -156,7 +155,7 @@ export interface GatewayActivity {
/**
* Application id for the game
*/
application_id?: string;
application_id?: Snowflake;
/**
* What the player is currently doing
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/guild
*/
import type { Permissions, Snowflake } from '../../common/index';
import type { APIChannel } from './channel';
import type { APIEmoji } from './emoji';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway';
@@ -16,7 +17,7 @@ export interface APIUnavailableGuild {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* `true` if this guild is unavailable due to an outage
*/
@@ -100,7 +101,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* ID of owner
*/
owner_id: string;
owner_id: Snowflake;
/**
* Total permissions for the user in the guild (excludes overrides)
*
@@ -108,7 +109,7 @@ export interface APIGuild extends APIPartialGuild {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions?: string;
permissions?: Permissions;
/**
* Voice region id for the guild
*
@@ -118,7 +119,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* ID of afk channel
*/
afk_channel_id: string | null;
afk_channel_id: Snowflake | null;
/**
* afk timeout in seconds
*/
@@ -130,7 +131,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The channel id that the widget will generate an invite to, or `null` if set to no invite
*/
widget_channel_id?: string | null;
widget_channel_id?: Snowflake | null;
/**
* Verification level required for the guild
*
@@ -176,11 +177,11 @@ export interface APIGuild extends APIPartialGuild {
/**
* Application id of the guild creator if it is bot-created
*/
application_id: string | null;
application_id: Snowflake | null;
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id: string | null;
system_channel_id: Snowflake | null;
/**
* System channel flags
*
@@ -190,7 +191,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where Community guilds can display rules and/or guidelines
*/
rules_channel_id: string | null;
rules_channel_id: Snowflake | null;
/**
* When this guild was joined at
*
@@ -282,7 +283,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id: string | null;
public_updates_channel_id: Snowflake | null;
/**
* The maximum amount of users in a video channel
*/
@@ -447,7 +448,7 @@ export interface APIGuildPreview {
/**
* Guild id
*/
id: string;
id: Snowflake;
/**
* Guild name (2-100 characters)
*/
@@ -507,7 +508,7 @@ export interface APIGuildWidgetSettings {
/**
* The widget channel id
*/
channel_id: string | null;
channel_id: Snowflake | null;
}
/**
@@ -531,7 +532,7 @@ export interface APIGuildMember {
*
* See https://discord.com/developers/docs/topics/permissions#role-object
*/
roles: string[];
roles: Snowflake[];
/**
* When the user joined the guild
*/
@@ -565,7 +566,7 @@ export interface APIGuildIntegration {
/**
* Integration id
*/
id: string;
id: Snowflake;
/**
* Integration name
*/
@@ -589,7 +590,7 @@ export interface APIGuildIntegration {
*
* **This field is not provided for `discord` bot integrations.**
*/
role_id?: string;
role_id?: Snowflake;
/**
* Whether emoticons should be synced for this integration (`twitch` only currently)
*
@@ -683,7 +684,7 @@ export interface APIGuildIntegrationApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -728,7 +729,7 @@ export interface APIBan {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidget {
id: string;
id: Snowflake;
name: string;
instant_invite: string | null;
channels: APIGuildWidgetChannel[];
@@ -740,7 +741,7 @@ export interface APIGuildWidget {
* https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget
*/
export interface APIGuildWidgetChannel {
id: string;
id: Snowflake;
name: string;
position: number;
}
@@ -800,11 +801,11 @@ export interface APIGuildWelcomeScreenChannel {
/**
* The channel id that is suggested
*/
channel_id: string;
channel_id: Snowflake;
/**
* The emoji id of the emoji that is shown on the left of the channel
*/
emoji_id: string | null;
emoji_id: Snowflake | null;
/**
* The emoji name of the emoji that is shown on the left of the channel
*/

View File

@@ -1,12 +1,13 @@
import type { APIGuildMember, APIUser, MessageFlags } from './index';
import type { Permissions, Snowflake } from '../../common/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
*/
export interface APIApplicationCommand {
id: string;
application_id: string;
id: Snowflake;
application_id: Snowflake;
name: string;
description: string;
options?: APIApplicationCommandOption[];
@@ -45,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'> {
@@ -78,19 +79,73 @@ export interface APIApplicationCommandOptionChoice {
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction
*/
export interface APIInteraction {
id: string;
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: string;
channel_id: string;
member: APIGuildMember & { permissions: string; 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>;
@@ -106,75 +161,150 @@ export const enum InteractionType {
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: string;
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;
}

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/oauth2
*/
import type { Snowflake } from '../../common/index';
import type { APITeam } from './teams';
import type { APIUser } from './user';
@@ -12,7 +13,7 @@ export interface APIApplication {
/**
* The id of the app
*/
id: string;
id: Snowflake;
/**
* The name of the app
*/
@@ -63,11 +64,11 @@ export interface APIApplication {
/**
* If this application is a game sold on Discord, this field will be the guild to which it has been linked
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
*/
primary_sku_id?: string;
primary_sku_id?: Snowflake;
/**
* If this application is a game sold on Discord, this field will be the URL slug that links to the store page
*/
@@ -79,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 {

View File

@@ -2,13 +2,14 @@
* Types extracted from https://discord.com/developers/docs/topics/permissions
*/
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,
@@ -42,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;
/**
@@ -57,7 +59,7 @@ export interface APIRole {
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Role name
*/
@@ -79,7 +81,7 @@ export interface APIRole {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
permissions: string;
permissions: Permissions;
/**
* Whether this role is managed by an integration
*/
@@ -101,7 +103,7 @@ export interface APIRoleTags {
/**
* The id of the bot this role belongs to
*/
bot_id?: string;
bot_id?: Snowflake;
/**
* Whether this is the guild's premium subscriber role
*/
@@ -109,5 +111,5 @@ export interface APIRoleTags {
/**
* The id of the integration this role belongs to
*/
integration_id?: string;
integration_id?: Snowflake;
}

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/topics/teams
*/
import type { Snowflake } from '../../common/index';
import type { APIUser } from './user';
/**
@@ -15,7 +16,7 @@ export interface APITeam {
/**
* The unique id of the team
*/
id: string;
id: Snowflake;
/**
* The members of the team
*/
@@ -23,7 +24,7 @@ export interface APITeam {
/**
* The user id of the current team owner
*/
owner_user_id: string;
owner_user_id: Snowflake;
}
/**
@@ -43,7 +44,7 @@ export interface APITeamMember {
/**
* The id of the parent team of which they are a member
*/
team_id: string;
team_id: Snowflake;
/**
* The avatar, discriminator, id, and username of the user
*

View File

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

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/user
*/
import type { Snowflake } from '../../common/index';
import type { APIGuildIntegration } from './guild';
/**
@@ -11,7 +12,7 @@ export interface APIUser {
/**
* The user's id
*/
id: string;
id: Snowflake;
/**
* The user's username, not unique across the platform
*/

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/voice
*/
import type { Snowflake } from '../../common/index';
import type { APIGuildMember } from './guild';
/**
@@ -11,15 +12,15 @@ export interface GatewayVoiceState {
/**
* The guild id this voice state is for
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The channel id this user is connected to
*/
channel_id: string | null;
channel_id: Snowflake | null;
/**
* The user id this voice state is for
*/
user_id: string;
user_id: Snowflake;
/**
* The guild member this voice state is for
*

View File

@@ -2,6 +2,7 @@
* Types extracted from https://discord.com/developers/docs/resources/webhook
*/
import type { Snowflake } from '../../common/index';
import type { APIPartialChannel, APIPartialGuild, APIUser } from './index';
/**
@@ -11,7 +12,7 @@ export interface APIWebhook {
/**
* The id of the webhook
*/
id: string;
id: Snowflake;
/**
* The type of the webhook
*
@@ -21,11 +22,11 @@ export interface APIWebhook {
/**
* The guild id this webhook is for
*/
guild_id?: string;
guild_id?: Snowflake;
/**
* The channel id this webhook is for
*/
channel_id: string;
channel_id: Snowflake;
/**
* The user this webhook was created by (not returned when getting a webhook with its token)
*
@@ -47,7 +48,7 @@ export interface APIWebhook {
/**
* The bot/OAuth2 application that created this webhook
*/
application_id: string | null;
application_id: Snowflake | null;
source_guild?: APIPartialGuild;
source_channel?: APIPartialChannel;
}

View File

@@ -1,3 +1,4 @@
import type { Snowflake } from '../../common/index';
import type { APIAuditLog, AuditLogEvent } from '../payloads/auditLog';
/**
@@ -7,7 +8,7 @@ export interface RESTGetAPIAuditLogQuery {
/**
* Filter the log for actions made by a user
*/
user_id?: string;
user_id?: Snowflake;
/**
* The type of audit log events
*/
@@ -15,7 +16,7 @@ export interface RESTGetAPIAuditLogQuery {
/**
* Filter the log before a certain entry ID
*/
before?: string;
before?: Snowflake;
/**
* How many entries are returned (default 50, minimum 1, maximum 100)
*

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../common/index';
import type {
APIAllowedMentions,
APIChannel,
@@ -86,7 +87,7 @@ export interface RESTPatchAPIChannelJSONBody {
*
* Channel types: text, news, store, voice
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
}
/**
@@ -106,15 +107,15 @@ export interface RESTGetAPIChannelMessagesQuery {
/**
* Get messages around this message ID
*/
around?: string;
around?: Snowflake;
/**
* Get messages before this message ID
*/
before?: string;
before?: Snowflake;
/**
* Get messages after this message ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of messages to return (1-100)
*
@@ -133,7 +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
@@ -150,7 +162,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
/**
* `true` if this is a TTS message
*/
tts?: true;
tts?: boolean;
/**
* Embedded `rich` content
*
@@ -224,11 +236,11 @@ export interface RESTGetAPIChannelMessageReactionUsersQuery {
/**
* Get users before this user ID
*/
before?: string;
before?: Snowflake;
/**
* Get users after this user ID
*/
after?: string;
after?: Snowflake;
/**
* Max number of users to return (1-100)
*
@@ -294,7 +306,7 @@ export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody {
/**
* An array of message ids to delete (2-100)
*/
messages: string[];
messages: Snowflake[];
}
/**
@@ -311,13 +323,13 @@ export interface RESTPutAPIChannelPermissionJSONBody {
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
allow: string;
allow: Permissions;
/**
* The bitwise value of all disallowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*/
deny: string;
deny: Permissions;
/**
* `0` for a role or `1` for a member
*/
@@ -390,7 +402,7 @@ export interface RESTPostAPIChannelFollowersJSONBody {
/**
* ID of target channel
*/
webhook_channel_id: string;
webhook_channel_id: Snowflake;
}
/**

View File

@@ -1,3 +1,4 @@
import type { Snowflake } from '../../common/index';
import type { APIEmoji } from '../payloads/index';
/**
@@ -27,7 +28,7 @@ export interface RESTPostAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[];
roles?: Snowflake[];
}
/**
@@ -46,7 +47,7 @@ export interface RESTPatchAPIGuildEmojiJSONBody {
/**
* Roles for which this emoji will be whitelisted
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
}
/**

View File

@@ -1,3 +1,4 @@
import type { Permissions, Snowflake } from '../../common/index';
import type {
APIBan,
APIChannel,
@@ -30,7 +31,7 @@ export type APIGuildCreatePartialChannel = Partial<
> & {
name: string;
id?: number | string;
parent_id?: number | string;
parent_id?: number | string | null;
permission_overwrites?: APIGuildCreateOverwrite[];
};
@@ -105,7 +106,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: number | string;
afk_channel_id?: number | Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -113,7 +114,7 @@ export interface RESTPostAPIGuildsJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: number | string;
system_channel_id?: number | Snowflake | null;
/**
* System channel flags
*
@@ -184,7 +185,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* ID for afk channel
*/
afk_channel_id?: string | null;
afk_channel_id?: Snowflake | null;
/**
* AFK timeout in seconds
*/
@@ -198,7 +199,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* User id to transfer guild ownership to (must be owner)
*/
owner_id?: string;
owner_id?: Snowflake;
/**
* base64 16:9 png/jpeg image for the guild splash (when the guild has `INVITE_SPLASH` feature)
*
@@ -216,7 +217,7 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where guild notices such as welcome messages and boost events are posted
*/
system_channel_id?: string | null;
system_channel_id?: Snowflake | null;
/**
* System channel flags
*
@@ -226,11 +227,11 @@ export interface RESTPatchAPIGuildJSONBody {
/**
* The id of the channel where Community guilds display rules and/or guidelines
*/
rules_channel_id?: string | null;
rules_channel_id?: Snowflake | null;
/**
* The id of the channel where admins and moderators of Community guilds receive notices from Discord
*/
public_updates_channel_id?: string | null;
public_updates_channel_id?: Snowflake | null;
/**
* The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US"
*
@@ -281,7 +282,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* Channel id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the channel
*/
@@ -293,7 +294,7 @@ export type RESTPatchAPIGuildChannelPositionsJSONBody = Array<{
/**
* The new parent id of this channel
*/
parent_id?: string | null;
parent_id?: Snowflake | null;
}>;
/**
@@ -321,7 +322,7 @@ export interface RESTGetAPIGuildMembersQuery {
*
* @default 0
*/
after?: string;
after?: Snowflake;
}
/**
@@ -363,7 +364,7 @@ export interface RESTPutAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[];
roles?: Snowflake[];
/**
* Whether the user is muted in voice channels
*
@@ -395,7 +396,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MANAGE_ROLES` permission
*/
roles?: string[] | null;
roles?: Snowflake[] | null;
/**
* Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel
*
@@ -413,7 +414,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
*
* Requires `MOVE_MEMBERS` permission
*/
channel_id?: string | null;
channel_id?: Snowflake | null;
}
/**
@@ -507,7 +508,7 @@ export interface RESTPostAPIGuildRoleJSONBody {
*
* @default "default role permissions in guild"
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*
@@ -540,7 +541,7 @@ export type RESTPatchAPIGuildRolePositionsJSONBody = Array<{
/**
* Role id
*/
id: string;
id: Snowflake;
/**
* Sorting position of the role
*/
@@ -563,7 +564,7 @@ export interface RESTPatchAPIGuildRoleJSONBody {
/**
* Bitwise value of the enabled/disabled permissions
*/
permissions?: string | null;
permissions?: Permissions | null;
/**
* RGB color value
*/
@@ -635,7 +636,7 @@ export interface RESTPostAPIGuildPruneJSONBody {
/**
* Role(s) to include
*/
include_roles?: string[];
include_roles?: Snowflake[];
}
/**
@@ -665,7 +666,7 @@ export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[];
*/
export interface RESTPostAPIGuildIntegrationJSONBody {
type: string;
id: string;
id: Snowflake;
}
export type RESTPostAPIGuildIntegrationResult = never;

View File

@@ -1,3 +1,5 @@
import type { Snowflake } from '../../common/index';
export * from './auditLog';
export * from './channel';
export * from './emoji';
@@ -17,8 +19,8 @@ export const Routes = {
* Route for:
* - GET `/guilds/{guild.id}/audit-logs`
*/
guildAuditLog(guildID: string) {
return `/guilds/${guildID}/audit-logs`;
guildAuditLog(guildID: Snowflake) {
return `/guilds/${guildID}/audit-logs` as const;
},
/**
@@ -27,8 +29,8 @@ export const Routes = {
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelID: string) {
return `/channels/${channelID}`;
channel(channelID: Snowflake) {
return `/channels/${channelID}` as const;
},
/**
@@ -36,8 +38,8 @@ export const Routes = {
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelID: string) {
return `/channels/${channelID}/messages`;
channelMessages(channelID: Snowflake) {
return `/channels/${channelID}/messages` as const;
},
/**
@@ -46,16 +48,16 @@ export const Routes = {
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}`;
channelMessage(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelMessageCrosspost(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/crosspost`;
channelMessageCrosspost(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/crosspost` as const;
},
/**
@@ -65,8 +67,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageOwnReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me`;
channelMessageOwnReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/@me` as const;
},
/**
@@ -75,8 +77,8 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageUserReaction(channelID: string, messageID: string, emoji: string, userID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}`;
channelMessageUserReaction(channelID: Snowflake, messageID: Snowflake, emoji: string, userID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}/${userID}` as const;
},
/**
@@ -86,24 +88,24 @@ export const Routes = {
*
* **Note**: You need to URL encode the emoji yourself
*/
channelMessageReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
channelMessageReaction(channelID: Snowflake, messageID: Snowflake, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}` as const;
},
/**
* Route for:
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/reactions`;
channelMessageAllReactions(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/messages/${messageID}/reactions` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelID: string) {
return `/channels/${channelID}/messages/bulk-delete`;
channelBulkDelete(channelID: Snowflake) {
return `/channels/${channelID}/messages/bulk-delete` as const;
},
/**
@@ -111,8 +113,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermission(channelID: string, overwriteID: string) {
return `/channels/${channelID}/permissions/${overwriteID}`;
channelPermission(channelID: Snowflake, overwriteID: Snowflake) {
return `/channels/${channelID}/permissions/${overwriteID}` as const;
},
/**
@@ -120,32 +122,32 @@ export const Routes = {
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvites(channelID: string) {
return `/channels/${channelID}/invites`;
channelInvites(channelID: Snowflake) {
return `/channels/${channelID}/invites` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/followers`
*/
channelFollowers(channelID: string) {
return `/channels/${channelID}/followers`;
channelFollowers(channelID: Snowflake) {
return `/channels/${channelID}/followers` as const;
},
/**
* Route for:
* - POST `/channels/{channel.id}/typing`
*/
channelTyping(channelID: string) {
return `/channels/${channelID}/typing`;
channelTyping(channelID: Snowflake) {
return `/channels/${channelID}/typing` as const;
},
/**
* Route for:
* - GET `/channels/{channel.id}/pins`
*/
channelPins(channelID: string) {
return `/channels/${channelID}/pins`;
channelPins(channelID: Snowflake) {
return `/channels/${channelID}/pins` as const;
},
/**
@@ -153,8 +155,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelID: string, messageID: string) {
return `/channels/${channelID}/pins/${messageID}`;
channelPin(channelID: Snowflake, messageID: Snowflake) {
return `/channels/${channelID}/pins/${messageID}` as const;
},
/**
@@ -162,8 +164,8 @@ export const Routes = {
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelID: string, userID: string) {
return `/channels/${channelID}/recipients/${userID}`;
channelRecipient(channelID: Snowflake, userID: Snowflake) {
return `/channels/${channelID}/recipients/${userID}` as const;
},
/**
@@ -171,8 +173,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildID: string) {
return `/guilds/${guildID}/emojis`;
guildEmojis(guildID: Snowflake) {
return `/guilds/${guildID}/emojis` as const;
},
/**
@@ -181,8 +183,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildID: string, emojiID: string) {
return `/guilds/${guildID}/emojis/${emojiID}`;
guildEmoji(guildID: Snowflake, emojiID: Snowflake) {
return `/guilds/${guildID}/emojis/${emojiID}` as const;
},
/**
@@ -190,7 +192,7 @@ export const Routes = {
* - POST `/guilds`
*/
guilds() {
return '/guilds';
return '/guilds' as const;
},
/**
@@ -199,16 +201,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildID: string) {
return `/guilds/${guildID}`;
guild(guildID: Snowflake) {
return `/guilds/${guildID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/preview`
*/
guildPreview(guildID: string) {
return `/guilds/${guildID}/preview`;
guildPreview(guildID: Snowflake) {
return `/guilds/${guildID}/preview` as const;
},
/**
@@ -217,8 +219,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildID: string) {
return `/guilds/${guildID}/channels`;
guildChannels(guildID: Snowflake) {
return `/guilds/${guildID}/channels` as const;
},
/**
@@ -228,32 +230,32 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildID: string, userID: string) {
return `/guilds/${guildID}/members/${userID}`;
guildMember(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/members/${userID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members`
*/
guildMembers(guildID: string) {
return `/guilds/${guildID}/members`;
guildMembers(guildID: Snowflake) {
return `/guilds/${guildID}/members` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/members/search`
*/
guildMembersSearch(guildID: string) {
return `/guilds/${guildID}/members/search`;
guildMembersSearch(guildID: Snowflake) {
return `/guilds/${guildID}/members/search` as const;
},
/**
* Route for:
* - PATCH `/guilds/{guild.id}/members/@me/nick`
*/
guildCurrentMemberNickname(guildID: string) {
return `/guilds/${guildID}/members/@me/nick`;
guildCurrentMemberNickname(guildID: Snowflake) {
return `/guilds/${guildID}/members/@me/nick` as const;
},
/**
@@ -261,16 +263,16 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
*/
guildMemberRole(guildID: string, memberID: string, roleID: string) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
guildMemberRole(guildID: Snowflake, memberID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/members/${memberID}/roles/${roleID}` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/bans`
*/
guildBans(guildID: string) {
return `/guilds/${guildID}/bans`;
guildBans(guildID: Snowflake) {
return `/guilds/${guildID}/bans` as const;
},
/**
@@ -279,8 +281,8 @@ export const Routes = {
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildID: string, userID: string) {
return `/guilds/${guildID}/bans/${userID}`;
guildBan(guildID: Snowflake, userID: Snowflake) {
return `/guilds/${guildID}/bans/${userID}` as const;
},
/**
@@ -289,8 +291,8 @@ export const Routes = {
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildID: string) {
return `/guilds/${guildID}/roles`;
guildRoles(guildID: Snowflake) {
return `/guilds/${guildID}/roles` as const;
},
/**
@@ -298,8 +300,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildID: string, roleID: string) {
return `/guilds/${guildID}/roles/${roleID}`;
guildRole(guildID: Snowflake, roleID: Snowflake) {
return `/guilds/${guildID}/roles/${roleID}` as const;
},
/**
@@ -307,24 +309,24 @@ export const Routes = {
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildID: string) {
return `/guilds/${guildID}/prune`;
guildPrune(guildID: Snowflake) {
return `/guilds/${guildID}/prune` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/regions`
*/
guildVoiceRegions(guildID: string) {
return `/guilds/${guildID}/regions`;
guildVoiceRegions(guildID: Snowflake) {
return `/guilds/${guildID}/regions` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/invites`
*/
guildInvites(guildID: string) {
return `/guilds/${guildID}/invites`;
guildInvites(guildID: Snowflake) {
return `/guilds/${guildID}/invites` as const;
},
/**
@@ -332,8 +334,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/integrations`
* - POST `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildID: string) {
return `/guilds/${guildID}/integrations`;
guildIntegrations(guildID: Snowflake) {
return `/guilds/${guildID}/integrations` as const;
},
/**
@@ -341,16 +343,16 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/integrations/{integration.id}`
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}`;
guildIntegration(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}` as const;
},
/**
* Route for:
* - POST `/guilds/{guild.id}/integrations/{integration.id}/sync`
*/
guildIntegrationSync(guildID: string, integrationID: string) {
return `/guilds/${guildID}/integrations/${integrationID}/sync`;
guildIntegrationSync(guildID: Snowflake, integrationID: Snowflake) {
return `/guilds/${guildID}/integrations/${integrationID}/sync` as const;
},
/**
@@ -358,32 +360,32 @@ export const Routes = {
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildID: string) {
return `/guilds/${guildID}/widget`;
guildWidgetSettings(guildID: Snowflake) {
return `/guilds/${guildID}/widget` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidgetJSON(guildID: string) {
return `/guilds/${guildID}/widget.json`;
guildWidgetJSON(guildID: Snowflake) {
return `/guilds/${guildID}/widget.json` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/vanity-url`
*/
guildVanityUrl(guildID: string) {
return `/guilds/${guildID}/vanity-url`;
guildVanityUrl(guildID: Snowflake) {
return `/guilds/${guildID}/vanity-url` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/widget.png`
*/
guildWidgetImage(guildID: string) {
return `/guilds/${guildID}/widget.png`;
guildWidgetImage(guildID: Snowflake) {
return `/guilds/${guildID}/widget.png` as const;
},
/**
@@ -392,7 +394,7 @@ export const Routes = {
* - DELETE `/invites/{invite.code}`
*/
invite(code: string) {
return `/invites/${code}`;
return `/invites/${code}` as const;
},
/**
@@ -401,7 +403,7 @@ export const Routes = {
* - POST `/guilds/templates/{template.code}`
*/
template(code: string) {
return `/guilds/templates/${code}`;
return `/guilds/templates/${code}` as const;
},
/**
@@ -409,8 +411,8 @@ export const Routes = {
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildID: string) {
return `/guilds/${guildID}/templates`;
guildTemplates(guildID: Snowflake) {
return `/guilds/${guildID}/templates` as const;
},
/**
@@ -419,8 +421,8 @@ export const Routes = {
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildID: string, code: string) {
return `/guilds/${guildID}/templates/${code}`;
guildTemplate(guildID: Snowflake, code: string) {
return `/guilds/${guildID}/templates/${code}` as const;
},
/**
@@ -432,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;
},
/**
@@ -440,15 +442,15 @@ export const Routes = {
* - GET `/users/@me/guilds`
*/
userGuilds() {
return `/users/@me/guilds`;
return `/users/@me/guilds` as const;
},
/**
* Route for:
* - DELETE `/users/@me/guilds/{guild.id}`
*/
userGuild(guildID: string) {
return `/users/@me/guilds/${guildID}`;
userGuild(guildID: Snowflake) {
return `/users/@me/guilds/${guildID}` as const;
},
/**
@@ -456,7 +458,7 @@ export const Routes = {
* - POST `/users/@me/channels`
*/
userChannels() {
return `/users/@me/channels`;
return `/users/@me/channels` as const;
},
/**
@@ -464,7 +466,7 @@ export const Routes = {
* - GET `/users/@me/connections`
*/
userConnections() {
return `/users/@me/connections`;
return `/users/@me/connections` as const;
},
/**
@@ -472,7 +474,7 @@ export const Routes = {
* - GET `/voice/regions`
*/
voiceRegions() {
return `/voice/regions`;
return `/voice/regions` as const;
},
/**
@@ -480,16 +482,16 @@ export const Routes = {
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
*/
channelWebhooks(channelID: string) {
return `/channels/${channelID}/webhooks`;
channelWebhooks(channelID: Snowflake) {
return `/channels/${channelID}/webhooks` as const;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/webhooks`
*/
guildWebhooks(guildID: string) {
return `/guilds/${guildID}/webhooks`;
guildWebhooks(guildID: Snowflake) {
return `/guilds/${guildID}/webhooks` as const;
},
/**
@@ -504,12 +506,12 @@ export const Routes = {
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookID: string, webhookToken?: string) {
webhook(webhookID: Snowflake, webhookToken?: string) {
const parts = ['', 'webhooks', webhookID];
if (webhookToken) parts.push(webhookToken);
return parts.join('/');
return parts.join('/') as `/webhooks/${Snowflake}` | `/webhooks/${Snowflake}/${string}`;
},
/**
@@ -525,8 +527,8 @@ export const Routes = {
*
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
webhookMessage(webhookID: Snowflake, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}` as const;
},
/**
@@ -534,8 +536,8 @@ export const Routes = {
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
webhookPlatform(webhookID: Snowflake, webhookToken: string, platform: 'github' | 'slack') {
return `/webhooks/${webhookID}/${webhookToken}/${platform}` as const;
},
/**
@@ -543,7 +545,7 @@ export const Routes = {
* - GET `/gateway`
*/
gateway() {
return `/gateway`;
return `/gateway` as const;
},
/**
@@ -551,7 +553,7 @@ export const Routes = {
* - GET `/gateway/bot`
*/
gatewayBot() {
return `/gateway/bot`;
return `/gateway/bot` as const;
},
/**
@@ -559,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;
},
/**
@@ -567,17 +577,18 @@ export const Routes = {
* - GET `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationID: string) {
return `/applications/${applicationID}/commands`;
applicationCommands(applicationID: Snowflake) {
return `/applications/${applicationID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationID: string, commandID: string) {
return `/applications/${applicationID}/commands/${commandID}`;
applicationCommand(applicationID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/commands/${commandID}` as const;
},
/**
@@ -585,25 +596,26 @@ export const Routes = {
* - GET `/applications/{application.id}/guilds/{guild.id}/commands`
* - POST `/applications/{application.id}/guilds/{guild.id}/commands`
*/
applicationGuildCommands(applicationID: string, guildID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands`;
applicationGuildCommands(applicationID: Snowflake, guildID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands` as const;
},
/**
* Route for:
* - GET `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
applicationGuildCommand(applicationID: string, guildID: string, commandID: string) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}`;
applicationGuildCommand(applicationID: Snowflake, guildID: Snowflake, commandID: Snowflake) {
return `/applications/${applicationID}/guilds/${guildID}/commands/${commandID}` as const;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionID: string, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback`;
interactionCallback(interactionID: Snowflake, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback` as const;
},
/**
@@ -611,11 +623,25 @@ export const Routes = {
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildID: string) {
return `/guilds/${guildID}/member-verification`;
guildMemberVerification(guildID: Snowflake) {
return `/guilds/${guildID}/member-verification` as const;
},
};
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`,
@@ -626,7 +652,7 @@ export const OAuth2Routes = {
} as const;
/**
* Freeze route object
* Freeze OAuth2 route object
* @internal
*/
Object.freeze(OAuth2Routes);

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