Compare commits

...

28 Commits

Author SHA1 Message Date
didinele
c28ef6c3d9 chore: RESTPatchAPIGuildJSONBody system_channel_flags is optional; release 0.11.2 (#55) 2020-12-20 18:48:52 +02:00
Vlad Frangu
8c43eae001 chore: release 0.11.1 (#54) 2020-12-19 17:51:44 +02:00
didinele
ba4c0d78f4 fix(RESTPostAPIGuildsJSONBody): system_channel_flags is optional (#53) 2020-12-19 16:29:52 +02:00
didinele
2b89beb52b fix(APIAuditLogEntry): user_id is not nullable (#52) 2020-12-19 16:00:08 +02:00
Vlad Frangu
ec9002fc56 chore: release 0.11.0 (#51) 2020-12-19 15:25:29 +02:00
Vlad Frangu
5d0f885d25 chore: separate gateway payload data into separate exported types (#50) 2020-12-19 14:52:50 +02:00
Vlad Frangu
91cf0d31d7 chore: Slash Commands typings (#44)
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
2020-12-19 01:03:22 +02:00
Vlad Frangu
c2f0deeebd fix(APIGuildMember): drop nullability of pending prop (#49) 2020-12-18 21:51:04 +02:00
didinele
018fc4f8ea fix(RESTPatchAPIGuildJSONBody): multiple properties are actually nullable (#48) 2020-12-18 15:37:27 +02:00
Vlad Frangu
b832b24603 chore: add pending property to GuildMember (#47)
ref: https://github.com/discord/discord-api-docs/pull/2345
2020-12-17 10:17:31 +02:00
TTtie
8d77142ca5 types(GatewayChannelPinsUpdateDispatch): make last_pin_timestamp nullable (#46)
Ref: 14460930d8

Ref: discord/ discord-api-docs #2215
2020-12-13 13:00:51 +02:00
Vlad Frangu
6296ac9e4f chore: fix routes which were wrong; release 0.10.0 (#43) 2020-12-09 13:11:56 +02:00
Advaith
7d873f73c7 feat: server templates (#25)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2020-11-23 13:39:55 +02:00
Vlad Frangu
60c38fd32c chore: add missing voice op code; release 0.9.1 (#42) 2020-11-22 21:18:12 +02:00
Vlad Frangu
e196e65254 chore: release 0.9.0 (#41) 2020-11-22 20:42:55 +02:00
Advaith
21b9ae4aaf feat(Message): reply updates (#34)
* feat(allowedmentions): replied_user

* feat(message): message_reference channel_id is now optional

* fix: make message_id required when sending

* chore: export APIMessageReferenceSend
2020-11-21 16:22:32 +02:00
Advaith
39ea1f4429 feat(Message): Stickers (#32)
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2020-11-21 16:19:13 +02:00
Vlad Frangu
fde45f9235 chore: rename INLINE_REPLY to REPLY (#40) 2020-11-17 13:37:25 +02:00
Vlad Frangu
2ee557a598 chore: remove RESTGetAPIGuildIntegrationQuery (per Discord) (#38) 2020-11-04 11:38:45 +02:00
Vlad Frangu
fed4749dd4 chore: release 0.8.0 (#37) 2020-11-03 18:55:27 +02:00
Souji
666a0c7152 fix: webhookPlatform route (#36) 2020-11-03 18:29:18 +02:00
Souji
e40530599e chore: update API import to use v8 in readme (#35) 2020-11-03 16:48:42 +02:00
Vlad Frangu
7992fab135 chore: fix mistypes (literally) for inline replies (#33) 2020-10-19 11:08:43 +03:00
Jan
61db1eee25 fix(GatewayPresence): correct type for sent activity objects (#30) 2020-10-18 23:46:29 +03:00
Vlad Frangu
363d914934 chore: release 0.7.0 (#29) 2020-10-18 14:43:42 +03:00
Jan
91c63f05ca fix(GatewayIdentify): use correct presence interface (#28) 2020-10-18 14:31:20 +03:00
Advaith
f058ed6aa1 feat(APIGuildWidgetMember): add activity and use proper status type (#24) 2020-10-18 14:20:58 +03:00
didinele
0982610731 fix(GatewayHeartbeat): d is nullable (#26) 2020-10-18 14:14:08 +03:00
25 changed files with 1471 additions and 703 deletions

2
.github/FUNDING.yml vendored
View File

@@ -1,6 +1,6 @@
# These are supported funding model platforms
github: []
github: [vladfrangu]
patreon: vladfrangu
open_collective: # Replace with a single Open Collective username
ko_fi: wolfgalvlad

View File

@@ -61,10 +61,10 @@ import { APIUser } from 'discord-api-types';
You should instead consider adding the API version you want to target by appending `/v*`, where the `*` represents the API version.
```js
const { APIUser } = require('discord-api-types/v6');
const { APIUser } = require('discord-api-types/v8');
```
```ts
// TypeScript/ES Module support
import { APIUser } from 'discord-api-types/v6';
import { APIUser } from '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 enum RESTJSONErrorCodes {
export const enum RESTJSONErrorCodes {
GeneralError,
UnknownAccount = 10001,
@@ -52,6 +52,8 @@ export enum RESTJSONErrorCodes {
MaximumNumberOfAttachmentsInAMessageReached = 30015,
MaximumNumberOfInvitesReached,
GuildAlreadyHasTemplate = 30031,
Unauthorized = 40001,
VerifyYourAccount,
@@ -59,6 +61,8 @@ export enum RESTJSONErrorCodes {
FeatureTemporarilyDisabledServerSide,
UserBannedFromThisGuild,
ThisMessageWasAlreadyCrossposted = 40033,
MissingAccess = 50001,
InvalidAccountType,
CannotExecuteActionOnDMChannel,
@@ -92,6 +96,8 @@ export enum RESTJSONErrorCodes {
CannotDeleteChannelRequiredForCommunityGuilds = 50074,
InvalidStickerSent = 50081,
TwoFactorAuthenticationIsRequired = 60003,
ReactionWasBlocked = 90001,
@@ -102,7 +108,7 @@ export enum RESTJSONErrorCodes {
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-error-codes
*/
export enum RPCErrorCodes {
export const enum RPCErrorCodes {
UnknownError = 1000,
InvalidPayload = 4000,
@@ -127,7 +133,7 @@ export enum RPCErrorCodes {
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc-rpc-close-event-codes
*/
export enum RPCCloseEventCodes {
export const enum RPCCloseEventCodes {
InvalidClientID = 4000,
InvalidOrigin,
RateLimited,

915
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "discord-api-types",
"version": "0.6.0",
"version": "0.11.2",
"description": "Discord API typings that are kept up to date for use in bot library creation.",
"main": "default/index.js",
"scripts": {
@@ -29,18 +29,18 @@
"node": ">=12"
},
"devDependencies": {
"@commitlint/cli": "^9.1.2",
"@commitlint/config-angular": "^9.1.2",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"eslint": "^7.8.1",
"@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": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lint-staged": "^10.3.0",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.3.0",
"husky": "^4.3.6",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
},
"repository": {
"type": "git",

View File

@@ -12,7 +12,8 @@
"removeComments": false,
"target": "ES2020",
"importsNotUsedAsValues": "error",
"strictNullChecks": true
"strictNullChecks": true,
"preserveConstEnums": true
},
"exclude": [
"node_modules",

View File

@@ -16,6 +16,8 @@ import type {
GatewayVoiceState,
InviteTargetUserType,
PresenceUpdateStatus,
APIApplicationCommandInteraction,
APIApplication,
} from '../payloads';
export const GatewayVersion = '8';
@@ -23,7 +25,7 @@ export const GatewayVersion = '8';
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
*/
export enum GatewayOPCodes {
export const enum GatewayOPCodes {
Dispatch,
Heartbeat,
Identify,
@@ -41,7 +43,7 @@ export enum GatewayOPCodes {
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
*/
export enum GatewayCloseCodes {
export const enum GatewayCloseCodes {
UnknownError = 4000,
UnknownOpCode,
DecodeError,
@@ -62,7 +64,7 @@ export enum GatewayCloseCodes {
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes
*/
export enum VoiceOPCodes {
export const enum VoiceOPCodes {
Identify,
SelectProtocol,
Ready,
@@ -74,13 +76,14 @@ export enum VoiceOPCodes {
Hello,
Resumed,
ClientDisconnect = 13,
ClientConnect = 12,
ClientDisconnect,
}
/**
* https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
*/
export enum VoiceCloseCodes {
export const enum VoiceCloseCodes {
UnknownOpCode = 4001,
NotAuthenticated = 4003,
@@ -101,7 +104,7 @@ export enum VoiceCloseCodes {
/**
* https://discord.com/developers/docs/topics/gateway#list-of-intents
*/
export enum GatewayIntentBits {
export const enum GatewayIntentBits {
GUILDS = 1 << 0,
GUILD_MEMBERS = 1 << 1,
GUILD_BANS = 1 << 2,
@@ -122,7 +125,7 @@ export enum GatewayIntentBits {
/**
* https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events
*/
export enum GatewayDispatchEvents {
export const enum GatewayDispatchEvents {
Ready = 'READY',
Resumed = 'RESUMED',
ChannelCreate = 'CHANNEL_CREATE',
@@ -143,6 +146,7 @@ export enum GatewayDispatchEvents {
GuildRoleCreate = 'GUILD_ROLE_CREATE',
GuildRoleUpdate = 'GUILD_ROLE_UPDATE',
GuildRoleDelete = 'GUILD_ROLE_DELETE',
InteractionCreate = 'INTERACTION_CREATE',
InviteCreate = 'INVITE_CREATE',
InviteDelete = 'INVITE_DELETE',
MessageCreate = 'MESSAGE_CREATE',
@@ -193,6 +197,7 @@ export type GatewayDispatchPayload =
| GatewayGuildMembersChunkDispatch
| GatewayGuildRoleModifyDispatch
| GatewayGuildRoleDeleteDispatch
| GatewayInteractionCreateDispatch
| GatewayInviteCreateDispatch
| GatewayInviteDeleteDispatch
| GatewayMessageCreateDispatch
@@ -211,14 +216,20 @@ export type GatewayDispatchPayload =
| GatewayWebhooksUpdateDispatch;
// #region Dispatch Payloads
/**
* https://discord.com/developers/docs/topics/gateway#hello
*/
export interface GatewayHello extends NonDispatchPayload {
op: GatewayOPCodes.Hello;
d: {
heartbeat_interval: number;
};
d: GatewayHelloData;
}
/**
* https://discord.com/developers/docs/topics/gateway#hello
*/
export interface GatewayHelloData {
heartbeat_interval: number;
}
/**
@@ -242,9 +253,14 @@ export interface GatewayHeartbeatAck extends NonDispatchPayload {
*/
export interface GatewayInvalidSession extends NonDispatchPayload {
op: GatewayOPCodes.InvalidSession;
d: boolean;
d: GatewayInvalidSessionData;
}
/**
* https://discord.com/developers/docs/topics/gateway#invalid-session
*/
export type GatewayInvalidSessionData = boolean;
/**
* https://discord.com/developers/docs/topics/gateway#reconnect
*/
@@ -256,24 +272,26 @@ export interface GatewayReconnect extends NonDispatchPayload {
/**
* https://discord.com/developers/docs/topics/gateway#ready
*/
export type GatewayReadyDispatch = DataPayload<
GatewayDispatchEvents.Ready,
{
v: number;
user: APIUser;
session_id: string;
private_channels: [];
guilds: APIUnavailableGuild[];
shard?: [shardID: number, shardCount: number];
}
>;
export type GatewayReadyDispatch = DataPayload<GatewayDispatchEvents.Ready, GatewayReadyDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#ready
*/
export interface GatewayReadyDispatchData {
v: number;
user: APIUser;
session_id: string;
private_channels: [];
guilds: APIUnavailableGuild[];
shard?: [shardID: number, shardCount: number];
application: Pick<APIApplication, 'id' | 'flags'>;
}
/**
* https://discord.com/developers/docs/topics/gateway#resumed
*/
export type GatewayResumedDispatch = DataPayload<GatewayDispatchEvents.Resumed, never>;
/* eslint-disable @typescript-eslint/indent */
/**
* https://discord.com/developers/docs/topics/gateway#channel-create
* https://discord.com/developers/docs/topics/gateway#channel-update
@@ -281,42 +299,72 @@ export type GatewayResumedDispatch = DataPayload<GatewayDispatchEvents.Resumed,
*/
export type GatewayChannelModifyDispatch = DataPayload<
GatewayDispatchEvents.ChannelCreate | GatewayDispatchEvents.ChannelDelete | GatewayDispatchEvents.ChannelUpdate,
APIChannel
GatewayChannelModifyDispatchData
>;
/* eslint-enable @typescript-eslint/indent */
/**
* https://discord.com/developers/docs/topics/gateway#channel-create
* https://discord.com/developers/docs/topics/gateway#channel-update
* https://discord.com/developers/docs/topics/gateway#channel-delete
*/
export type GatewayChannelModifyDispatchData = APIChannel;
export type GatewayChannelCreateDispatch = GatewayChannelModifyDispatch;
export type GatewayChannelCreateDispatchData = GatewayChannelModifyDispatchData;
export type GatewayChannelUpdateDispatch = GatewayChannelModifyDispatch;
export type GatewayChannelUpdateDispatchData = GatewayChannelModifyDispatchData;
export type GatewayChannelDeleteDispatch = GatewayChannelModifyDispatch;
export type GatewayChannelDeleteDispatchData = GatewayChannelModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#channel-pins-update
*/
export type GatewayChannelPinsUpdateDispatch = DataPayload<
GatewayDispatchEvents.ChannelPinsUpdate,
{
guild_id?: string;
channel_id: string;
last_pin_timestamp?: string;
}
GatewayChannelPinsUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#channel-pins-update
*/
export interface GatewayChannelPinsUpdateDispatchData {
guild_id?: string;
channel_id: string;
last_pin_timestamp?: string | null;
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildCreate | GatewayDispatchEvents.GuildUpdate,
APIGuild
GatewayGuildModifyDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-create
* https://discord.com/developers/docs/topics/gateway#guild-update
*/
export type GatewayGuildModifyDispatchData = APIGuild;
export type GatewayGuildCreateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildCreateDispatchData = GatewayGuildModifyDispatchData;
export type GatewayGuildUpdateDispatch = GatewayGuildModifyDispatch;
export type GatewayGuildUpdateDispatchData = GatewayGuildModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#guild-delete
*/
export type GatewayGuildDeleteDispatch = DataPayload<GatewayDispatchEvents.GuildDelete, APIUnavailableGuild>;
export type GatewayGuildDeleteDispatch = DataPayload<GatewayDispatchEvents.GuildDelete, GatewayGuildDeleteDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-delete
*/
export type GatewayGuildDeleteDispatchData = APIUnavailableGuild;
/**
* https://discord.com/developers/docs/topics/gateway#guild-ban-add
@@ -324,254 +372,413 @@ export type GatewayGuildDeleteDispatch = DataPayload<GatewayDispatchEvents.Guild
*/
export type GatewayGuildBanModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildBanAdd | GatewayDispatchEvents.GuildBanRemove,
{
guild_id: string;
user: APIUser;
}
GatewayGuildBanModifyDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-ban-add
* https://discord.com/developers/docs/topics/gateway#guild-ban-remove
*/
export interface GatewayGuildBanModifyDispatchData {
guild_id: string;
user: APIUser;
}
export type GatewayGuildBanAddDispatch = GatewayGuildBanModifyDispatch;
export type GatewayGuildBanAddDispatchData = GatewayGuildBanModifyDispatchData;
export type GatewayGuildBanRemoveDispatch = GatewayGuildBanModifyDispatch;
export type GatewayGuildBanRemoveDispatchData = GatewayGuildBanModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#guild-emojis-update
*/
export type GatewayGuildEmojisUpdateDispatch = DataPayload<
GatewayDispatchEvents.GuildEmojisUpdate,
{
guild_id: string;
emojis: APIEmoji[];
}
GatewayGuildEmojisUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-emojis-update
*/
export interface GatewayGuildEmojisUpdateDispatchData {
guild_id: string;
emojis: APIEmoji[];
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-integrations-update
*/
export type GatewayGuildIntegrationsUpdateDispatch = DataPayload<
GatewayDispatchEvents.GuildIntegrationsUpdate,
{ guild_id: string }
GatewayGuildIntegrationsUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-integrations-update
*/
export interface GatewayGuildIntegrationsUpdateDispatchData {
guild_id: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-add
*/
export type GatewayGuildMemberAddDispatch = DataPayload<
GatewayDispatchEvents.GuildMemberAdd,
APIGuildMember & { guild_id: string }
GatewayGuildMemberAddDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-add
*/
export interface GatewayGuildMemberAddDispatchData extends APIGuildMember {
guild_id: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-remove
*/
export type GatewayGuildMemberRemoveDispatch = DataPayload<
GatewayDispatchEvents.GuildMemberRemove,
{
guild_id: string;
user: APIUser;
}
GatewayGuildMemberRemoveDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-remove
*/
export interface GatewayGuildMemberRemoveDispatchData {
guild_id: string;
user: APIUser;
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatch = DataPayload<
GatewayDispatchEvents.GuildMemberUpdate,
Omit<APIGuildMember, 'deaf' | 'mute'> & {
guild_id: string;
}
GatewayGuildMemberUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-member-update
*/
export type GatewayGuildMemberUpdateDispatchData = Omit<APIGuildMember, 'deaf' | 'mute'> & {
guild_id: string;
};
/**
* https://discord.com/developers/docs/topics/gateway#guild-members-chunk
*/
export type GatewayGuildMembersChunkDispatch = DataPayload<
GatewayDispatchEvents.GuildMembersChunk,
{
guild_id: string;
members: APIGuildMember[];
chunk_index?: number;
chunk_count?: number;
not_found?: unknown[];
presences?: RawGatewayPresenceUpdate[];
nonce?: string;
}
GatewayGuildMembersChunkDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-members-chunk
*/
export interface GatewayGuildMembersChunkDispatchData {
guild_id: string;
members: APIGuildMember[];
chunk_index?: number;
chunk_count?: number;
not_found?: unknown[];
presences?: RawGatewayPresenceUpdate[];
nonce?: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#guild-role-create
* https://discord.com/developers/docs/topics/gateway#guild-role-update
*/
export type GatewayGuildRoleModifyDispatch = DataPayload<
GatewayDispatchEvents.GuildRoleCreate | GatewayDispatchEvents.GuildRoleUpdate,
{
guild_id: string;
role: APIRole;
}
GatewayGuildRoleModifyDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-role-create
* https://discord.com/developers/docs/topics/gateway#guild-role-update
*/
export interface GatewayGuildRoleModifyDispatchData {
guild_id: string;
role: APIRole;
}
export type GatewayGuildRoleCreateDispatch = GatewayGuildRoleModifyDispatch;
export type GatewayGuildRoleCreateDispatchData = GatewayGuildRoleModifyDispatchData;
export type GatewayGuildRoleUpdateDispatch = GatewayGuildRoleModifyDispatch;
export type GatewayGuildRoleUpdateDispatchData = GatewayGuildRoleModifyDispatchData;
/**
* https://discord.com/developers/docs/topics/gateway#guild-role-delete
*/
export type GatewayGuildRoleDeleteDispatch = DataPayload<
GatewayDispatchEvents.GuildRoleDelete,
{
guild_id: string;
role_id: string;
}
GatewayGuildRoleDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#guild-role-delete
*/
export interface GatewayGuildRoleDeleteDispatchData {
guild_id: string;
role_id: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#interaction-create
*/
export type GatewayInteractionCreateDispatch = DataPayload<
GatewayDispatchEvents.InteractionCreate,
GatewayInteractionCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#interaction-create
*/
export type GatewayInteractionCreateDispatchData = APIApplicationCommandInteraction;
/**
* https://discord.com/developers/docs/topics/gateway#invite-create
*/
export type GatewayInviteCreateDispatch = DataPayload<
GatewayDispatchEvents.InviteCreate,
{
channel_id: string;
code: string;
created_at: number;
guild_id?: string;
inviter?: APIUser;
max_age: number;
max_uses: number;
target_user?: APIUser;
target_user_type?: InviteTargetUserType;
temporary: boolean;
uses: 0;
}
GatewayInviteCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#invite-create
*/
export interface GatewayInviteCreateDispatchData {
channel_id: string;
code: string;
created_at: number;
guild_id?: string;
inviter?: APIUser;
max_age: number;
max_uses: number;
target_user?: APIUser;
target_user_type?: InviteTargetUserType;
temporary: boolean;
uses: 0;
}
/**
* https://discord.com/developers/docs/topics/gateway#invite-delete
*/
export type GatewayInviteDeleteDispatch = DataPayload<
GatewayDispatchEvents.InviteDelete,
{
channel_id: string;
guild_id?: string;
code: string;
}
GatewayInviteDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#invite-delete
*/
export interface GatewayInviteDeleteDispatchData {
channel_id: string;
guild_id?: string;
code: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#message-create
*/
export type GatewayMessageCreateDispatch = DataPayload<
GatewayDispatchEvents.MessageCreate,
GatewayMessageCreateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-create
*/
export type GatewayMessageCreateDispatch = DataPayload<GatewayDispatchEvents.MessageCreate, APIMessage>;
export type GatewayMessageCreateDispatchData = APIMessage;
/**
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatch = DataPayload<
GatewayDispatchEvents.MessageUpdate,
{ id: string; channel_id: string } & Partial<APIMessage>
GatewayMessageUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-update
*/
export type GatewayMessageUpdateDispatchData = {
id: string;
channel_id: string;
} & Partial<APIMessage>;
/**
* https://discord.com/developers/docs/topics/gateway#message-delete
*/
export type GatewayMessageDeleteDispatch = DataPayload<
GatewayDispatchEvents.MessageDelete,
{
id: string;
channel_id: string;
guild_id?: string;
}
GatewayMessageDeleteDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-delete
*/
export interface GatewayMessageDeleteDispatchData {
id: string;
channel_id: string;
guild_id?: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#message-delete-bulk
*/
export type GatewayMessageDeleteBulkDispatch = DataPayload<
GatewayDispatchEvents.MessageDeleteBulk,
{
ids: string[];
channel_id: string;
guild_id?: string;
}
GatewayMessageDeleteBulkDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-delete-bulk
*/
export interface GatewayMessageDeleteBulkDispatchData {
ids: string[];
channel_id: string;
guild_id?: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-add
*/
export type GatewayMessageReactionAddDispatch = ReactionData<GatewayDispatchEvents.MessageReactionAdd>;
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-add
*/
export type GatewayMessageReactionAddDispatchData = GatewayMessageReactionAddDispatch['d'];
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove
*/
export type GatewayMessageReactionRemoveDispatch = ReactionData<GatewayDispatchEvents.MessageReactionRemove, 'member'>;
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove
*/
export type GatewayMessageReactionRemoveDispatchData = GatewayMessageReactionRemoveDispatch['d'];
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all
*/
export type GatewayMessageReactionRemoveAllDispatch = DataPayload<
GatewayDispatchEvents.MessageReactionRemoveAll,
MessageReactionRemoveData
GatewayMessageReactionRemoveAllDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all
*/
export type GatewayMessageReactionRemoveAllDispatchData = MessageReactionRemoveData;
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji
*/
export type GatewayMessageReactionRemoveEmojiDispatch = DataPayload<
GatewayDispatchEvents.MessageReactionRemoveEmoji,
MessageReactionRemoveData & {
emoji: APIEmoji;
}
GatewayMessageReactionRemoveEmojiDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji
*/
export interface GatewayMessageReactionRemoveEmojiDispatchData extends MessageReactionRemoveData {
emoji: APIEmoji;
}
/**
* https://discord.com/developers/docs/topics/gateway#presence-update
*/
export type GatewayPresenceUpdateDispatch = DataPayload<
GatewayDispatchEvents.PresenceUpdate,
GatewayPresenceUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#presence-update
*/
export type GatewayPresenceUpdateDispatch = DataPayload<GatewayDispatchEvents.PresenceUpdate, RawGatewayPresenceUpdate>;
export type GatewayPresenceUpdateDispatchData = RawGatewayPresenceUpdate;
/**
* https://discord.com/developers/docs/topics/gateway#typing-start
*/
export type GatewayTypingStartDispatch = DataPayload<
GatewayDispatchEvents.TypingStart,
{
channel_id: string;
guild_id?: string;
user_id: string;
timestamp: number;
member?: APIGuildMember;
}
>;
export type GatewayTypingStartDispatch = DataPayload<GatewayDispatchEvents.TypingStart, GatewayTypingStartDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#typing-start
*/
export interface GatewayTypingStartDispatchData {
channel_id: string;
guild_id?: string;
user_id: string;
timestamp: number;
member?: APIGuildMember;
}
/**
* https://discord.com/developers/docs/topics/gateway#user-update
*/
export type GatewayUserUpdateDispatch = DataPayload<GatewayDispatchEvents.UserUpdate, APIUser>;
export type GatewayUserUpdateDispatch = DataPayload<GatewayDispatchEvents.UserUpdate, GatewayUserUpdateDispatchData>;
/**
* https://discord.com/developers/docs/topics/gateway#user-update
*/
export type GatewayUserUpdateDispatchData = APIUser;
/**
* https://discord.com/developers/docs/topics/gateway#voice-state-update
*/
export type GatewayVoiceStateUpdateDispatch = DataPayload<GatewayDispatchEvents.VoiceStateUpdate, GatewayVoiceState>;
export type GatewayVoiceStateUpdateDispatch = DataPayload<
GatewayDispatchEvents.VoiceStateUpdate,
GatewayVoiceStateUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#voice-state-update
*/
export type GatewayVoiceStateUpdateDispatchData = GatewayVoiceState;
/**
* https://discord.com/developers/docs/topics/gateway#voice-server-update
*/
export type GatewayVoiceServerUpdateDispatch = DataPayload<
GatewayDispatchEvents.VoiceServerUpdate,
{
token: string;
guild_id: string;
endpoint: string;
}
GatewayVoiceServerUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#voice-server-update
*/
export interface GatewayVoiceServerUpdateDispatchData {
token: string;
guild_id: string;
endpoint: string;
}
/**
* https://discord.com/developers/docs/topics/gateway#webhooks-update
*/
export type GatewayWebhooksUpdateDispatch = DataPayload<
GatewayDispatchEvents.WebhooksUpdate,
{
guild_id: string;
channel_id: string;
}
GatewayWebhooksUpdateDispatchData
>;
/**
* https://discord.com/developers/docs/topics/gateway#webhooks-update
*/
export interface GatewayWebhooksUpdateDispatchData {
guild_id: string;
channel_id: string;
}
// #endregion Dispatch Payloads
// #region Sendable Payloads
@@ -581,9 +788,14 @@ export type GatewayWebhooksUpdateDispatch = DataPayload<
*/
export interface GatewayHeartbeat {
op: GatewayOPCodes.Heartbeat;
d: number;
d: GatewayHeartbeatData;
}
/**
* https://discord.com/developers/docs/topics/gateway#heartbeating
*/
export type GatewayHeartbeatData = number | null;
/**
* https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
*/
@@ -598,17 +810,22 @@ export interface GatewayIdentifyProperties {
*/
export interface GatewayIdentify {
op: GatewayOPCodes.Identify;
d: {
token: string;
properties: GatewayIdentifyProperties;
compress?: boolean;
large_threshold?: number;
// eslint-disable-next-line prettier/prettier
shard?: [shard_id: number, shard_count: number];
presence?: RawGatewayPresenceUpdate;
guild_subscriptions?: boolean;
intents: number;
};
d: GatewayIdentifyData;
}
/**
* https://discord.com/developers/docs/topics/gateway#identify
*/
export interface GatewayIdentifyData {
token: string;
properties: GatewayIdentifyProperties;
compress?: boolean;
large_threshold?: number;
// eslint-disable-next-line prettier/prettier
shard?: [shard_id: number, shard_count: number];
presence?: GatewayPresenceUpdateData;
guild_subscriptions?: boolean;
intents: number;
}
/**
@@ -616,11 +833,16 @@ export interface GatewayIdentify {
*/
export interface GatewayResume {
op: GatewayOPCodes.Resume;
d: {
token: string;
session_id: string;
seq: number;
};
d: GatewayResumeData;
}
/**
* https://discord.com/developers/docs/topics/gateway#resume
*/
export interface GatewayResumeData {
token: string;
session_id: string;
seq: number;
}
/**
@@ -628,14 +850,19 @@ export interface GatewayResume {
*/
export interface GatewayRequestGuildMembers {
op: GatewayOPCodes.RequestGuildMembers;
d: {
guild_id: string | string[];
query?: string;
limit: number;
presences?: boolean;
user_ids?: string | string[];
nonce?: string;
};
d: GatewayRequestGuildMembersData;
}
/**
* https://discord.com/developers/docs/topics/gateway#request-guild-members
*/
export interface GatewayRequestGuildMembersData {
guild_id: string | string[];
query?: string;
limit: number;
presences?: boolean;
user_ids?: string | string[];
nonce?: string;
}
/**
@@ -643,12 +870,17 @@ export interface GatewayRequestGuildMembers {
*/
export interface GatewayVoiceStateUpdate {
op: GatewayOPCodes.VoiceStateUpdate;
d: {
guild_id: string;
channel_id: string | null;
self_mute: boolean;
self_deaf: boolean;
};
d: GatewayVoiceStateUpdateData;
}
/**
* https://discord.com/developers/docs/topics/gateway#update-voice-state
*/
export interface GatewayVoiceStateUpdateData {
guild_id: string;
channel_id: string | null;
self_mute: boolean;
self_deaf: boolean;
}
/**
@@ -664,11 +896,16 @@ export interface GatewayUpdatePresence {
*/
export interface GatewayPresenceUpdateData {
since: number | null;
activities: GatewayActivity[] | null;
activities: GatewayActivityUpdateData[] | null;
status: PresenceUpdateStatus;
afk: boolean;
}
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
*/
export type GatewayActivityUpdateData = Pick<GatewayActivity, 'name' | 'type' | 'url'>;
// #endregion Sendable Payloads
// #region Shared

View File

@@ -31,7 +31,7 @@ export interface APIAuditLog {
export interface APIAuditLogEntry {
target_id: string | null;
changes?: APIAuditLogChange[];
user_id: string | null;
user_id: string;
id: string;
action_type: AuditLogEvent;
options?: APIAuditLogOptions;
@@ -41,7 +41,7 @@ export interface APIAuditLogEntry {
/**
* https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
*/
export enum AuditLogEvent {
export const enum AuditLogEvent {
GUILD_UPDATE = 1,
CHANNEL_CREATE = 10,
@@ -154,7 +154,7 @@ export interface APIAuditLogOptions {
role_name?: string;
}
export enum AuditLogOptionsType {
export const enum AuditLogOptionsType {
Role = '0',
Member = '1',
}

View File

@@ -40,7 +40,7 @@ export interface APIChannel extends APIPartialChannel {
/**
* https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*/
export enum ChannelType {
export const enum ChannelType {
GUILD_TEXT = 0,
DM,
GUILD_VOICE,
@@ -79,12 +79,13 @@ export interface APIMessage {
message_reference?: APIMessageReference;
flags?: MessageFlags;
referenced_message?: APIMessage | null;
stickers?: APISticker[];
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-types
*/
export enum MessageType {
export const enum MessageType {
DEFAULT,
RECIPIENT_ADD,
RECIPIENT_REMOVE,
@@ -102,7 +103,7 @@ export enum MessageType {
GUILD_DISCOVERY_REQUALIFIED,
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING,
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING,
INLINE_REPLY,
REPLY = 19,
}
/**
@@ -129,14 +130,14 @@ export interface APIMessageApplication {
*/
export interface APIMessageReference {
message_id?: string;
channel_id: string;
channel_id?: string;
guild_id?: string;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
*/
export enum MessageActivityType {
export const enum MessageActivityType {
JOIN = 1,
SPECTATE,
LISTEN,
@@ -146,12 +147,36 @@ export enum MessageActivityType {
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-flags
*/
export enum MessageFlags {
export const enum MessageFlags {
CROSSPOSTED = 1 << 0,
IS_CROSSPOST = 1 << 1,
SUPPRESS_EMBEDS = 1 << 2,
SOURCE_MESSAGE_DELETED = 1 << 3,
URGENT = 1 << 4,
EPHEMERAL = 1 << 6,
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure
*/
export interface APISticker {
id: string;
pack_id: string;
name: string;
description: string;
tags?: string;
asset: string;
preview_asset: string | null;
format_type: StickerFormatType;
}
/**
* https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types
*/
export const enum StickerFormatType {
PNG = 1,
APNG,
LOTTIE,
}
/**
@@ -173,7 +198,7 @@ export interface APIOverwrite {
deny: string;
}
export enum OverwriteType {
export const enum OverwriteType {
Role,
Member,
}
@@ -204,7 +229,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 enum EmbedType {
export const enum EmbedType {
Rich = 'rich',
Image = 'image',
Video = 'video',

View File

@@ -42,7 +42,7 @@ export interface GatewayPresenceUpdate {
client_status?: GatewayPresenceClientStatus;
}
export enum PresenceUpdateStatus {
export const enum PresenceUpdateStatus {
DoNotDisturb = 'dnd',
Idle = 'idle',
Invisible = 'invisible',
@@ -56,7 +56,7 @@ export enum PresenceUpdateStatus {
export type GatewayPresenceClientStatus = Partial<Record<'desktop' | 'mobile' | 'web', PresenceUpdateStatus>>;
/**
* https://discord.com/developers/docs/topics/gateway#activity-object
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure
*/
export interface GatewayActivity {
name: string;
@@ -78,7 +78,7 @@ export interface GatewayActivity {
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
*/
export enum ActivityType {
export const enum ActivityType {
Game,
Streaming,
Listening,
@@ -124,7 +124,7 @@ export type GatewayActivitySecrets = Partial<Record<'join' | 'spectate' | 'match
/**
* https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags
*/
export enum ActivityFlags {
export const enum ActivityFlags {
INSTANCE = 1 << 0,
JOIN = 1 << 1,
SPECTATE = 1 << 2,

View File

@@ -4,7 +4,7 @@
import type { APIChannel } from './channel';
import type { APIEmoji } from './emoji';
import type { GatewayPresenceUpdate } from './gateway';
import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway';
import type { APIRole } from './permissions';
import type { APIUser } from './user';
import type { GatewayVoiceState } from './voice';
@@ -17,6 +17,9 @@ export interface APIUnavailableGuild {
unavailable: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
*/
export interface APIPartialGuild extends Omit<APIUnavailableGuild, 'unavailable'>, Pick<APIGuild, 'welcome_screen'> {
name: string;
icon: string | null;
@@ -29,7 +32,11 @@ export interface APIPartialGuild extends Omit<APIUnavailableGuild, 'unavailable'
unavailable?: boolean;
}
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
*/
export interface APIGuild extends APIPartialGuild {
icon_hash?: string | null;
discovery_splash: string | null;
owner?: boolean;
owner_id: string;
@@ -81,7 +88,7 @@ export interface APIGuild extends APIPartialGuild {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
*/
export enum GuildDefaultMessageNotifications {
export const enum GuildDefaultMessageNotifications {
ALL_MESSAGES,
ONLY_MENTIONS,
}
@@ -89,7 +96,7 @@ export enum GuildDefaultMessageNotifications {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
*/
export enum GuildExplicitContentFilter {
export const enum GuildExplicitContentFilter {
DISABLED,
MEMBERS_WITHOUT_ROLES,
ALL_MEMBERS,
@@ -98,7 +105,7 @@ export enum GuildExplicitContentFilter {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
*/
export enum GuildMFALevel {
export const enum GuildMFALevel {
NONE,
ELEVATED,
}
@@ -106,7 +113,7 @@ export enum GuildMFALevel {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-verification-level
*/
export enum GuildVerificationLevel {
export const enum GuildVerificationLevel {
NONE,
LOW,
MEDIUM,
@@ -117,7 +124,7 @@ export enum GuildVerificationLevel {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
*/
export enum GuildPremiumTier {
export const enum GuildPremiumTier {
NONE,
TIER_1,
TIER_2,
@@ -127,7 +134,7 @@ export enum GuildPremiumTier {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
*/
export enum GuildSystemChannelFlags {
export const enum GuildSystemChannelFlags {
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0,
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1,
}
@@ -135,7 +142,7 @@ export enum GuildSystemChannelFlags {
/**
* https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
export enum GuildFeature {
export const enum GuildFeature {
ANIMATED_ICON = 'ANIMATED_ICON',
BANNER = 'BANNER',
COMMERCE = 'COMMERCE',
@@ -204,7 +211,8 @@ export interface APIGuildWidgetMember {
username: string;
discriminator: string;
avatar: string | null;
status: string;
status: PresenceUpdateStatus;
activity?: { name: string };
avatar_url: string;
}
@@ -219,6 +227,7 @@ export interface APIGuildMember {
premium_since?: string | null;
deaf: boolean;
mute: boolean;
pending?: boolean;
}
/**
@@ -245,7 +254,7 @@ export interface APIGuildIntegration {
/**
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
*/
export enum IntegrationExpireBehavior {
export const enum IntegrationExpireBehavior {
RemoveRole,
Kick,
}
@@ -281,7 +290,7 @@ export interface APIBan {
/**
* https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options
*/
export enum GuildWidgetStyle {
export const enum GuildWidgetStyle {
Banner1 = 'banner1',
Banner2 = 'banner2',
Banner3 = 'banner3',

View File

@@ -3,10 +3,12 @@ export * from './channel';
export * from './emoji';
export * from './gateway';
export * from './guild';
export * from './interactions';
export * from './invite';
export * from './oauth2';
export * from './permissions';
export * from './teams';
export * from './template';
export * from './user';
export * from './voice';
export * from './webhook';

180
v8/payloads/interactions.ts Normal file
View File

@@ -0,0 +1,180 @@
import type { APIGuildMember, APIUser, MessageFlags } from './';
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../rest';
/**
* 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 & { user: APIUser };
token: string;
version: 1;
}
/**
* Like {@see APIInteraction}, only with the `data` property always present
*/
export type APIApplicationCommandInteraction = Required<APIInteraction>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
*/
export const enum InteractionType {
Ping = 1,
ApplicationCommand,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
*/
export interface APIApplicationCommandInteractionData {
id: string;
name: string;
options?: APIApplicationCommandInteractionDataOption[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
*/
export interface APIApplicationCommandInteractionDataOption {
name: string;
/**
* The value returned here depends on the `ApplicationCommandOptionType` type of the option with the name
* that matches this interface's `name`.
*
* You will need to manually cast this to the appropriate type based on the returned data.
*/
value?: unknown;
options?: APIApplicationCommandInteractionDataOption[];
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interaction-response
*/
export type APIInteractionResponse =
| APIInteractionResponsePong
| APIInteractionResponseAcknowledge
| APIInteractionResponseAcknowledgeWithSource
| APIInteractionResponseChannelMessage
| APIInteractionResponseChannelMessageWithSource;
export type APIInteractionResponsePong = InteractionResponsePayload<APIInteractionResponseType.Pong>;
export type APIInteractionResponseAcknowledge = InteractionResponsePayload<APIInteractionResponseType.Acknowledge>;
export type APIInteractionResponseAcknowledgeWithSource = InteractionResponsePayload<APIInteractionResponseType.AcknowledgeWithSource>;
export type APIInteractionResponseChannelMessage = InteractionResponsePayload<
APIInteractionResponseType.ChannelMessage,
true
>;
export type APIInteractionResponseChannelMessageWithSource = InteractionResponsePayload<
APIInteractionResponseType.ChannelMessageWithSource,
true
>;
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionresponsetype
*/
export const enum APIInteractionResponseType {
Pong = 1,
Acknowledge,
ChannelMessage,
ChannelMessageWithSource,
AcknowledgeWithSource,
}
/**
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionapplicationcommandcallbackdata
*/
export type APIInteractionApplicationCommandCallbackData = Omit<
RESTPostAPIWebhookWithTokenJSONBody,
'username' | 'avatar_url'
> & { flags?: MessageFlags };
/**
* @internal
*/
interface InteractionResponsePayload<T extends APIInteractionResponseType, D = false> {
type: T;
data?: D extends true ? APIInteractionApplicationCommandCallbackData : never;
}

View File

@@ -23,7 +23,7 @@ export interface APIInvite {
/**
* https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
*/
export enum InviteTargetUserType {
export const enum InviteTargetUserType {
STREAM = 1,
}

View File

@@ -24,4 +24,5 @@ export interface APIApplication {
primary_sku_id?: string;
slug?: string;
cover_image?: string;
flags?: number;
}

View File

@@ -27,7 +27,7 @@ export interface APITeamMember {
/**
* https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum
*/
export enum TeamMemberMembershipState {
export const enum TeamMemberMembershipState {
INVITED = 1,
ACCEPTED,
}

29
v8/payloads/template.ts Normal file
View File

@@ -0,0 +1,29 @@
/**
* Types extracted from https://discord.com/developers/docs/resources/template
*/
import type { APIUser } from './user';
import type { RESTPostAPIGuildsJSONBody } from '../rest';
/**
* https://discord.com/developers/docs/resources/template#template-object
*/
export interface APITemplate {
code: string;
name: string;
description: string | null;
usage_count: number;
creator_id: string;
creator: APIUser;
created_at: string;
updated_at: string;
source_guild_id: string;
serialized_source_guild: APITemplateSerializedSourceGuild;
is_dirty: boolean | null;
}
export interface APITemplateSerializedSourceGuild extends Omit<RESTPostAPIGuildsJSONBody, 'icon'> {
description: string | null;
preferred_locale: string;
icon_hash: string | null;
}

View File

@@ -26,7 +26,7 @@ export interface APIUser {
/**
* https://discord.com/developers/docs/resources/user#user-object-user-flags
*/
export enum UserFlags {
export const enum UserFlags {
None = 0,
DiscordEmployee = 1 << 0,
PartneredServerOwner = 1 << 1,
@@ -46,7 +46,7 @@ export enum UserFlags {
/**
* https://discord.com/developers/docs/resources/user#user-object-premium-types
*/
export enum UserPremiumType {
export const enum UserPremiumType {
None,
NitroClassic,
Nitro,
@@ -67,7 +67,7 @@ export interface APIConnection {
visibility: ConnectionVisibility;
}
export enum ConnectionVisibility {
export const enum ConnectionVisibility {
None,
Everyone,
}

View File

@@ -23,7 +23,7 @@ export interface APIWebhook {
application_id: string | null;
}
export enum WebhookType {
export const enum WebhookType {
Incoming = 1,
ChannelFollower,
}

View File

@@ -18,7 +18,7 @@ import type {
/**
* https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types
*/
export enum AllowedMentionsTypes {
export const enum AllowedMentionsTypes {
Everyone = 'everyone',
Role = 'roles',
User = 'users',
@@ -31,6 +31,7 @@ export interface APIAllowedMentionsSend {
parse?: AllowedMentionsTypes[];
roles?: string[];
users?: string[];
replied_user?: boolean;
}
// #endregion TypeDefs
@@ -66,6 +67,8 @@ export interface RESTGetAPIChannelMessagesQuery {
export type RESTGetAPIChannelMessagesResult = APIMessage[];
export type APIMessageReferenceSend = APIMessageReference & Required<Pick<APIMessageReference, 'message_id'>>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
@@ -75,7 +78,7 @@ export interface RESTPostAPIChannelMessageJSONBody {
tts?: boolean;
embed?: APIEmbed;
allowed_mentions?: APIAllowedMentionsSend;
message_reference?: APIMessageReference;
message_reference?: APIMessageReferenceSend;
}
/**
@@ -98,7 +101,7 @@ export type RESTPostAPIChannelMessageFormDataBody =
tts?: boolean;
embed?: APIEmbed;
allowed_mentions?: APIAllowedMentionsSend;
message_reference?: APIMessageReference;
message_reference?: APIMessageReferenceSend;
/**
* The file contents
*/
@@ -197,12 +200,19 @@ export interface RESTPutAPIChannelRecipientJSONBody {
export type RESTPutAPIChannelRecipientResult = unknown;
export type RESTDeleteAPIChannelRecipientResult = unknown;
// TODO: Docs updated once https://github.com/discord/discord-api-docs/pull/1692/files is merged
/**
* https://discord.com/developers/docs/resources/channel#crosspost-message
*/
export type RESTPostAPIChannelMessageCrosspostResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export interface RESTPostAPIChannelFollowersJSONBody {
webhook_channel_id: string;
}
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export type RESTPostAPIChannelFollowersResult = APIFollowedChannel;

View File

@@ -13,6 +13,7 @@ import type {
GuildDefaultMessageNotifications,
GuildExplicitContentFilter,
GuildFeature,
GuildSystemChannelFlags,
GuildVerificationLevel,
GuildWidgetStyle,
IntegrationExpireBehavior,
@@ -51,6 +52,7 @@ export interface RESTPostAPIGuildsJSONBody {
afk_channel_id?: number | string;
afk_timeout?: number;
system_channel_id?: number | string;
system_channel_flags?: GuildSystemChannelFlags;
}
export type RESTPostAPIGuildsResult = APIGuild;
@@ -74,10 +76,10 @@ export type RESTGetAPIGuildPreviewResult = APIGuildPreview;
*/
export interface RESTPatchAPIGuildJSONBody {
name?: string;
region?: string;
verification_level?: GuildVerificationLevel;
default_message_notifications?: GuildDefaultMessageNotifications;
explicit_content_filter?: GuildExplicitContentFilter;
region?: string | null;
verification_level?: GuildVerificationLevel | null;
default_message_notifications?: GuildDefaultMessageNotifications | null;
explicit_content_filter?: GuildExplicitContentFilter | null;
afk_channel_id?: string | null;
afk_timeout?: number;
icon?: string | null;
@@ -86,9 +88,10 @@ export interface RESTPatchAPIGuildJSONBody {
discovery_splash?: string | null;
banner?: string | null;
system_channel_id?: string | null;
system_channel_flags?: GuildSystemChannelFlags;
rules_channel_id?: string | null;
public_updates_channel_id?: string | null;
preferred_locale?: string;
preferred_locale?: string | null;
features?: GuildFeature[];
description?: string | null;
}
@@ -170,7 +173,7 @@ export interface RESTPatchAPIGuildMemberJSONBody {
channel_id?: string | null;
}
export type RESTPatchAPIGuildMemberResult = never;
export type RESTPatchAPIGuildMemberResult = APIGuildMember;
/**
* https://discord.com/developers/docs/resources/guild#modify-current-user-nick
@@ -308,13 +311,6 @@ export type RESTGetAPIGuildVoiceRegionsResult = APIVoiceRegion[];
*/
export type RESTGetAPIGuildInvitesResult = APIInvite[];
/**
* https://discord.com/developers/docs/resources/guild#get-guild-integrations
*/
export interface RESTGetAPIGuildIntegrationsQuery {
include_applications?: boolean;
}
export type RESTGetAPIGuildIntegrationsResult = APIGuildIntegration[];
/**

View File

@@ -3,8 +3,10 @@ export * from './channel';
export * from './emoji';
export * from './gateway';
export * from './guild';
export * from './interactions';
export * from './invite';
export * from './oauth2';
export * from './template';
export * from './user';
export * from './voice';
export * from './webhook';
@@ -21,8 +23,8 @@ export const Routes = {
/**
* Route for:
* - GET `/channels/{channel.id}`
* - PATCH `/channels/{channel.id}`
* - GET `/channels/{channel.id}`
* - PATCH `/channels/{channel.id}`
* - DELETE `/channels/{channel.id}`
*/
channel(channelID: string) {
@@ -31,7 +33,7 @@ export const Routes = {
/**
* Route for:
* - GET `/channels/{channel.id}/messages`
* - GET `/channels/{channel.id}/messages`
* - POST `/channels/{channel.id}/messages`
*/
channelMessages(channelID: string) {
@@ -40,8 +42,8 @@ export const Routes = {
/**
* Route for:
* - GET `/channels/{channel.id}/messages/{message.id}`
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - GET `/channels/{channel.id}/messages/{message.id}`
* - PATCH `/channels/{channel.id}/messages/{message.id}`
* - DELETE `/channels/{channel.id}/messages/{message.id}`
*/
channelMessage(channelID: string, messageID: string) {
@@ -52,13 +54,13 @@ export const Routes = {
* Route for:
* - POST `/channels/{channel.id}/messages/{message.id}/crosspost`
*/
channelCrosspost(channelID: string, messageID: string) {
return `/channels/${channelID}/message/${messageID}/crosspost`;
channelMessageCrosspost(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}/crosspost`;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me`
* - PUT `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me`
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me`
*
* **Note**: You need to URL encode the emoji yourself.
@@ -79,12 +81,12 @@ export const Routes = {
/**
* Route for:
* - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}`
* - GET `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}`
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions/{emoji}`
*
* **Note**: You need to URL encode the emoji yourself.
*/
channelMessageSpecificReaction(channelID: string, messageID: string, emoji: string) {
channelMessageReaction(channelID: string, messageID: string, emoji: string) {
return `/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
},
@@ -93,7 +95,7 @@ export const Routes = {
* - DELETE `/channels/{channel.id}/messages/{message.id}/reactions`
*/
channelMessageAllReactions(channelID: string, messageID: string) {
return `/channels/${channelID}/messages/${messageID}`;
return `/channels/${channelID}/messages/${messageID}/reactions`;
},
/**
@@ -101,25 +103,25 @@ export const Routes = {
* - POST `/channels/{channel.id}/messages/bulk-delete`
*/
channelBulkDelete(channelID: string) {
return `/channels/${channelID}/bulk-delete`;
return `/channels/${channelID}/messages/bulk-delete`;
},
/**
* Route for:
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - PUT `/channels/{channel.id}/permissions/{overwrite.id}`
* - DELETE `/channels/{channel.id}/permissions/{overwrite.id}`
*/
channelPermissions(channelID: string, overwriteID: string) {
channelPermission(channelID: string, overwriteID: string) {
return `/channels/${channelID}/permissions/${overwriteID}`;
},
/**
* Route for:
* - GET `/channels/{channel.id}/invites`
* - GET `/channels/{channel.id}/invites`
* - POST `/channels/{channel.id}/invites`
*/
channelInvite(channelID: string) {
return `/channels/${channelID}`;
channelInvites(channelID: string) {
return `/channels/${channelID}/invites`;
},
/**
@@ -148,7 +150,7 @@ export const Routes = {
/**
* Route for:
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - PUT `/channels/{channel.id}/pins/{message.id}`
* - DELETE `/channels/{channel.id}/pins/{message.id}`
*/
channelPin(channelID: string, messageID: string) {
@@ -157,7 +159,7 @@ export const Routes = {
/**
* Route for:
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - PUT `/channels/{channel.id}/recipients/{user.id}`
* - DELETE `/channels/{channel.id}/recipients/{user.id}`
*/
channelRecipient(channelID: string, userID: string) {
@@ -166,7 +168,7 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/emojis`
* - GET `/guilds/{guild.id}/emojis`
* - POST `/guilds/{guild.id}/emojis`
*/
guildEmojis(guildID: string) {
@@ -175,8 +177,8 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/emojis/{emoji.id}`
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - GET `/guilds/{guild.id}/emojis/{emoji.id}`
* - PATCH `/guilds/{guild.id}/emojis/{emoji.id}`
* - DELETE `/guilds/{guild.id}/emojis/{emoji.id}`
*/
guildEmoji(guildID: string, emojiID: string) {
@@ -193,8 +195,8 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}`
* - PATCH `/guilds/{guild.id}`
* - GET `/guilds/{guild.id}`
* - PATCH `/guilds/{guild.id}`
* - DELETE `/guilds/{guild.id}`
*/
guild(guildID: string) {
@@ -211,8 +213,8 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/channels`
* - POST `/guilds/{guild.id}/channels`
* - GET `/guilds/{guild.id}/channels`
* - POST `/guilds/{guild.id}/channels`
* - PATCH `/guilds/{guild.id}/channels`
*/
guildChannels(guildID: string) {
@@ -221,9 +223,9 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/members/{user.id}`
* - PUT `/guilds/{guild.id}/members/{user.id}`
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - GET `/guilds/{guild.id}/members/{user.id}`
* - PUT `/guilds/{guild.id}/members/{user.id}`
* - PATCH `/guilds/{guild.id}/members/{user.id}`
* - DELETE `/guilds/{guild.id}/members/{user.id}`
*/
guildMember(guildID: string, userID: string) {
@@ -256,7 +258,7 @@ export const Routes = {
/**
* Route for:
* - PUT `/guilds/{guild.id}/members/{user.id}/roles/{role.id}`
* - 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) {
@@ -273,8 +275,8 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/bans/{user.id}`
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - GET `/guilds/{guild.id}/bans/{user.id}`
* - PUT `/guilds/{guild.id}/bans/{user.id}`
* - DELETE `/guilds/{guild.id}/bans/{user.id}`
*/
guildBan(guildID: string, userID: string) {
@@ -283,8 +285,8 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/roles`
* - POST `/guilds/{guild.id}/roles`
* - GET `/guilds/{guild.id}/roles`
* - POST `/guilds/{guild.id}/roles`
* - PATCH `/guilds/{guild.id}/roles`
*/
guildRoles(guildID: string) {
@@ -293,7 +295,7 @@ export const Routes = {
/**
* Route for:
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - PATCH `/guilds/{guild.id}/roles/{role.id}`
* - DELETE `/guilds/{guild.id}/roles/{role.id}`
*/
guildRole(guildID: string, roleID: string) {
@@ -302,7 +304,7 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/prune`
* - GET `/guilds/{guild.id}/prune`
* - POST `/guilds/{guild.id}/prune`
*/
guildPrune(guildID: string) {
@@ -327,7 +329,7 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/integrations`
* - GET `/guilds/{guild.id}/integrations`
* - POST `/guilds/{guild.id}/integrations`
*/
guildIntegrations(guildID: string) {
@@ -336,7 +338,7 @@ export const Routes = {
/**
* Route for:
* - PATCH `/guilds/{guild.id}/integrations/{integration.id}`
* - PATCH `/guilds/{guild.id}/integrations/{integration.id}`
* - DELETE `/guilds/{guild.id}/integrations/{integration.id}`
*/
guildIntegration(guildID: string, integrationID: string) {
@@ -353,7 +355,7 @@ export const Routes = {
/**
* Route for:
* - GET `/guilds/{guild.id}/widget`
* - GET `/guilds/{guild.id}/widget`
* - PATCH `/guilds/{guild.id}/widget`
*/
guildWidgetSettings(guildID: string) {
@@ -364,7 +366,7 @@ export const Routes = {
* Route for:
* - GET `/guilds/{guild.id}/widget.json`
*/
guildWidget(guildID: string) {
guildWidgetJSON(guildID: string) {
return `/guilds/${guildID}/widget.json`;
},
@@ -386,7 +388,7 @@ export const Routes = {
/**
* Route for:
* - GET `/invites/{invite.code}`
* - GET `/invites/{invite.code}`
* - DELETE `/invites/{invite.code}`
*/
invite(code: string) {
@@ -395,9 +397,39 @@ export const Routes = {
/**
* Route for:
* - GET `/users/@me`
* - GET `/users/{user.id}`
* - GET `/guilds/templates/{template.code}`
* - POST `/guilds/templates/{template.code}`
*/
template(code: string) {
return `/guilds/templates/${code}`;
},
/**
* Route for:
* - GET `/guilds/{guild.id}/templates`
* - POST `/guilds/{guild.id}/templates`
*/
guildTemplates(guildID: string) {
return `/guilds/${guildID}/templates`;
},
/**
* Route for:
* - PUT `/guilds/{guild.id}/templates/{template.code}`
* - PATCH `/guilds/{guild.id}/templates/{template.code}`
* - DELETE `/guilds/{guild.id}/templates/{template.code}`
*/
guildTemplate(guildID: string, code: string) {
return `/guilds/${guildID}/templates/${code}`;
},
/**
* Route for:
* - GET `/users/@me`
* - GET `/users/{user.id}`
* - PATCH `/users/@me`
*
* @param [userID='@me'] The user ID, defaulted to `@me`
*/
user(userID = '@me') {
return `/users/${userID}`;
@@ -445,10 +477,10 @@ export const Routes = {
/**
* Route for:
* - GET `/channels/{channel.id}/webhooks`
* - POST `/channels/{channel.id}/webhooks`
* - GET `/channels/{channel.id}/webhooks`
*/
channelWebhook(channelID: string) {
channelWebhooks(channelID: string) {
return `/channels/${channelID}/webhooks`;
},
@@ -462,13 +494,15 @@ export const Routes = {
/**
* Route for:
* - GET `/webhooks/{webhook.id}`
* - GET `/webhooks/{webhook.id}/{webhook.token}`
* - PATCH `/webhooks/{webhook.id}`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}`
* - GET `/webhooks/{webhook.id}`
* - GET `/webhooks/{webhook.id}/{webhook.token}`
* - PATCH `/webhooks/{webhook.id}`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}`
* - DELETE `/webhooks/{webhook.id}`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}`
* - POST `/webhooks/{webhook.id}/{webhook.token}`
* - POST `/webhooks/{webhook.id}/{webhook.token}`
*
* - POST `/webhooks/{application.id}/{interaction.token}`
*/
webhook(webhookID: string, webhookToken?: string) {
const parts = ['', 'webhooks', webhookID];
@@ -480,11 +514,28 @@ export const Routes = {
/**
* Route for:
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - PATCH `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/@original`
* - DELETE `/webhooks/{webhook.id}/{webhook.token}/messages/{message.id}`
*
* - PATCH `/webhooks/{application.id}/{interaction.token}/messages/@original`
* - PATCH `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
* - DELETE `/webhooks/{application.id}/{interaction.token}/messages/{message.id}`
*
* @param [messageID='@original'] The message ID to change, defaulted to `@original`
*/
webhookMessage(webhookID: string, webhookToken: string, messageID = '@original') {
return `/webhooks/${webhookID}/${webhookToken}/messages/${messageID}`;
},
/**
* Route for:
* - POST `/webhooks/{webhook.id}/{webhook.token}/github`
* - POST `/webhooks/{webhook.id}/{webhook.token}/slack`
*/
webhookPlatform(webhookID: string, webhookToken: string, platform: 'github' | 'slack') {
return `/${webhookID}/${webhookToken}/${platform}`;
return `/webhooks/${webhookID}/${webhookToken}/${platform}`;
},
/**
@@ -510,4 +561,46 @@ export const Routes = {
oauth2CurrentApplication() {
return `/oauth2/applications/@me`;
},
/**
* Route for:
* - GET `/applications/{application.id}/commands`
* - POST `/applications/{application.id}/commands`
*/
applicationCommands(applicationID: string) {
return `/applications/${applicationID}/commands`;
},
/**
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
applicationCommand(applicationID: string, commandID: string) {
return `/applications/${applicationID}/commands/${commandID}`;
},
/**
* Route for:
* - 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`;
},
/**
* - 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}`;
},
/**
* Route for:
* - POST `/interactions/{interaction.id}/{interaction.token}/callback`
*/
interactionCallback(interactionID: string, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback`;
},
};

77
v8/rest/interactions.ts Normal file
View File

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

33
v8/rest/template.ts Normal file
View File

@@ -0,0 +1,33 @@
import type { APIGuild, APITemplate } from '../payloads';
/**
* https://discord.com/developers/docs/resources/template#get-template
*/
export type RESTGetAPITemplateResult = APITemplate;
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export interface RESTPostAPITemplateCreateGuildJSONBody {
name: string;
icon?: string;
}
/**
* https://discord.com/developers/docs/resources/template#create-guild-from-template
*/
export type RESTPostAPITemplateCreateGuildResult = APIGuild;
export type RESTGetAPIGuildTemplatesResult = APITemplate[];
export interface RESTPostAPIGuildTemplatesJSONBody {
name: string;
description?: string | null;
}
export type RESTPostAPIGuildTemplatesResult = APITemplate;
export type RESTPutAPIGuildTemplateSyncResult = APITemplate;
export type RESTPatchAPIGuildTemplateJSONBody = Partial<RESTPostAPIGuildTemplatesJSONBody>;
export type RESTPatchAPIGuildTemplateResult = APITemplate;
export type RESTDeleteAPIGuildTemplateResult = APITemplate;

View File

@@ -114,3 +114,13 @@ export type RESTPostAPIWebhookWithTokenSlackQuery = RESTPostAPIWebhookWithTokenQ
* https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook-querystring-params
*/
export type RESTPostAPIWebhookWithTokenGitHubQuery = RESTPostAPIWebhookWithTokenQuery;
export type RESTPatchAPIWebhookWithTokenMessageJSONBody = RESTPostAPIWebhookWithTokenJSONBody;
export type RESTPatchAPIWebhookWithTokenMessageFormDataBody =
| {
payload_json: string;
}
| RESTPatchAPIWebhookWithTokenMessageJSONBody;
export type RESTDeleteAPIWebhookWithTokenMessageResult = never;