@satorijs/adapter-discord 4.1.3 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -2
- package/lib/utils.d.ts +1 -1
- package/package.json +4 -3
- package/src/bot.ts +221 -0
- package/src/index.ts +27 -0
- package/src/message.ts +446 -0
- package/src/types/.eslintrc.yml +2 -0
- package/src/types/application-role-connection.ts +61 -0
- package/src/types/application.ts +120 -0
- package/src/types/audit-log.ts +219 -0
- package/src/types/auto-moderation.ts +189 -0
- package/src/types/ban.ts +92 -0
- package/src/types/channel.ts +501 -0
- package/src/types/command.ts +320 -0
- package/src/types/component.ts +125 -0
- package/src/types/device.ts +44 -0
- package/src/types/emoji.ts +96 -0
- package/src/types/gateway.ts +334 -0
- package/src/types/guild-member.ts +260 -0
- package/src/types/guild-template.ts +109 -0
- package/src/types/guild.ts +476 -0
- package/src/types/index.ts +49 -0
- package/src/types/integration.ts +130 -0
- package/src/types/interaction.ts +283 -0
- package/src/types/internal.ts +44 -0
- package/src/types/invite.ts +192 -0
- package/src/types/message.ts +470 -0
- package/src/types/presence.ts +163 -0
- package/src/types/reaction.ts +139 -0
- package/src/types/role.ts +252 -0
- package/src/types/scheduled-event.ts +200 -0
- package/src/types/stage-instance.ts +98 -0
- package/src/types/sticker.ts +179 -0
- package/src/types/team.ts +33 -0
- package/src/types/thread.ts +298 -0
- package/src/types/user.ts +154 -0
- package/src/types/voice.ts +124 -0
- package/src/types/webhook.ts +246 -0
- package/src/utils.ts +391 -0
- package/src/ws.ts +124 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { integer, Internal, snowflake, timestamp, User } from '.'
|
|
2
|
+
|
|
3
|
+
/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */
|
|
4
|
+
export interface Integration {
|
|
5
|
+
/** integration id */
|
|
6
|
+
id: snowflake
|
|
7
|
+
/** integration name */
|
|
8
|
+
name: string
|
|
9
|
+
/** integration type (twitch, youtube, or discord) */
|
|
10
|
+
type: string
|
|
11
|
+
/** is this integration enabled */
|
|
12
|
+
enabled: boolean
|
|
13
|
+
/** is this integration syncing */
|
|
14
|
+
syncing?: boolean
|
|
15
|
+
/** id that this integration uses for "subscribers" */
|
|
16
|
+
role_id?: snowflake
|
|
17
|
+
/** whether emoticons should be synced for this integration (twitch only currently) */
|
|
18
|
+
enable_emoticons?: boolean
|
|
19
|
+
/** the behavior of expiring subscribers */
|
|
20
|
+
expire_behavior?: IntegrationExpireBehavior
|
|
21
|
+
/** the grace period (in days) before expiring subscribers */
|
|
22
|
+
expire_grace_period?: integer
|
|
23
|
+
/** user for this integration */
|
|
24
|
+
user?: User
|
|
25
|
+
/** integration account information */
|
|
26
|
+
account: IntegrationAccount
|
|
27
|
+
/** when this integration was last synced */
|
|
28
|
+
synced_at?: timestamp
|
|
29
|
+
/** how many subscribers this integration has */
|
|
30
|
+
subscriber_count?: integer
|
|
31
|
+
/** has this integration been revoked */
|
|
32
|
+
revoked?: boolean
|
|
33
|
+
/** The bot/OAuth2 application for discord integrations */
|
|
34
|
+
application?: IntegrationApplication
|
|
35
|
+
/** the scopes the application has been authorized for */
|
|
36
|
+
scopes?: string[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors */
|
|
40
|
+
export enum IntegrationExpireBehavior {
|
|
41
|
+
REMOVE_ROLE = 0,
|
|
42
|
+
KICK = 1,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure */
|
|
46
|
+
export interface IntegrationAccount {
|
|
47
|
+
/** id of the account */
|
|
48
|
+
id: string
|
|
49
|
+
/** name of the account */
|
|
50
|
+
name: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** https://discord.com/developers/docs/resources/guild#integration-application-object-integration-application-structure */
|
|
54
|
+
export interface IntegrationApplication {
|
|
55
|
+
/** the id of the app */
|
|
56
|
+
id: snowflake
|
|
57
|
+
/** the name of the app */
|
|
58
|
+
name: string
|
|
59
|
+
/** the icon hash of the app */
|
|
60
|
+
icon?: string
|
|
61
|
+
/** the description of the app */
|
|
62
|
+
description: string
|
|
63
|
+
/** the bot associated with this application */
|
|
64
|
+
bot?: User
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** https://discord.com/developers/docs/topics/gateway-events#guild-integrations-update-guild-integrations-update-event-fields */
|
|
68
|
+
export interface GuildIntegrationsUpdateEvent {
|
|
69
|
+
/** id of the guild whose integrations were updated */
|
|
70
|
+
guild_id: snowflake
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** https://discord.com/developers/docs/topics/gateway-events#integration-create-integration-create-event-additional-fields */
|
|
74
|
+
export interface IntegrationCreateEvent extends Integration {
|
|
75
|
+
/** id of the guild */
|
|
76
|
+
guild_id: snowflake
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** https://discord.com/developers/docs/topics/gateway-events#integration-update-integration-update-event-additional-fields */
|
|
80
|
+
export interface IntegrationUpdateEvent extends Integration {
|
|
81
|
+
/** id of the guild */
|
|
82
|
+
guild_id: snowflake
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** https://discord.com/developers/docs/topics/gateway-events#integration-delete-integration-delete-event-fields */
|
|
86
|
+
export interface IntegrationDeleteEvent {
|
|
87
|
+
/** integration id */
|
|
88
|
+
id: snowflake
|
|
89
|
+
/** id of the guild */
|
|
90
|
+
guild_id: snowflake
|
|
91
|
+
/** id of the bot/OAuth2 application for this discord integration */
|
|
92
|
+
application_id?: snowflake
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare module './gateway' {
|
|
96
|
+
interface GatewayEvents {
|
|
97
|
+
/** guild integration was updated */
|
|
98
|
+
GUILD_INTEGRATIONS_UPDATE: GuildIntegrationsUpdateEvent
|
|
99
|
+
/** guild integration was created */
|
|
100
|
+
INTEGRATION_CREATE: IntegrationCreateEvent
|
|
101
|
+
/** guild integration was updated */
|
|
102
|
+
INTEGRATION_UPDATE: IntegrationUpdateEvent
|
|
103
|
+
/** guild integration was deleted */
|
|
104
|
+
INTEGRATION_DELETE: IntegrationDeleteEvent
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare module './internal' {
|
|
109
|
+
interface Internal {
|
|
110
|
+
/**
|
|
111
|
+
* Returns a list of integration objects for the guild. Requires the MANAGE_GUILD permission.
|
|
112
|
+
* @see https://discord.com/developers/docs/resources/guild#get-guild-integrations
|
|
113
|
+
*/
|
|
114
|
+
getGuildIntegrations(guild_id: snowflake): Promise<Integration[]>
|
|
115
|
+
/**
|
|
116
|
+
* Delete the attached integration object for the guild. Deletes any associated webhooks and kicks the associated bot if there is one. Requires the MANAGE_GUILD permission. Returns a 204 empty response on success. Fires a Guild Integrations Update Gateway event.
|
|
117
|
+
* @see https://discord.com/developers/docs/resources/guild#delete-guild-integration
|
|
118
|
+
*/
|
|
119
|
+
deleteGuildIntegration(guild_id: snowflake, integration_id: snowflake): Promise<void>
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
Internal.define({
|
|
124
|
+
'/guilds/{guild.id}/integrations': {
|
|
125
|
+
GET: 'getGuildIntegrations',
|
|
126
|
+
},
|
|
127
|
+
'/guilds/{guild.id}/integrations/{integration.id}': {
|
|
128
|
+
DELETE: 'deleteGuildIntegration',
|
|
129
|
+
},
|
|
130
|
+
})
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { AllowedMentions, ApplicationCommand, Attachment, Channel, Component, ComponentType, Embed, GuildMember, integer, Internal, Message, Role, snowflake, User } from '.'
|
|
2
|
+
import * as Discord from '.'
|
|
3
|
+
|
|
4
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-structure */
|
|
5
|
+
export interface Interaction {
|
|
6
|
+
/** id of the interaction */
|
|
7
|
+
id: snowflake
|
|
8
|
+
/** id of the application this interaction is for */
|
|
9
|
+
application_id: snowflake
|
|
10
|
+
/** the type of interaction */
|
|
11
|
+
type: Interaction.Type
|
|
12
|
+
/** the command data payload */
|
|
13
|
+
data?: InteractionData
|
|
14
|
+
/** the guild it was sent from */
|
|
15
|
+
guild_id?: snowflake
|
|
16
|
+
/** the channel it was sent from */
|
|
17
|
+
channel_id?: snowflake
|
|
18
|
+
/** guild member data for the invoking user, including permissions */
|
|
19
|
+
member?: GuildMember
|
|
20
|
+
/** user object for the invoking user, if invoked in a DM */
|
|
21
|
+
user?: User
|
|
22
|
+
/** a continuation token for responding to the interaction */
|
|
23
|
+
token: string
|
|
24
|
+
/** read-only property, always 1 */
|
|
25
|
+
version: integer
|
|
26
|
+
/** for components, the message they were attached to */
|
|
27
|
+
message?: Message
|
|
28
|
+
/** bitwise set of permissions the app or bot has within the channel the interaction was sent from */
|
|
29
|
+
app_permissions?: string
|
|
30
|
+
/** selected language of the invoking user */
|
|
31
|
+
locale?: string
|
|
32
|
+
/** guild's preferred locale, if invoked in a guild */
|
|
33
|
+
guild_locale?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type InteractionData =
|
|
37
|
+
| InteractionData.ApplicationCommand
|
|
38
|
+
| InteractionData.MessageComponent
|
|
39
|
+
| InteractionData.ModalSubmit
|
|
40
|
+
|
|
41
|
+
export namespace InteractionData {
|
|
42
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-application-command-data-structure */
|
|
43
|
+
export interface ApplicationCommand {
|
|
44
|
+
/** the ID of the invoked command */
|
|
45
|
+
id: snowflake
|
|
46
|
+
/** the name of the invoked command */
|
|
47
|
+
name: string
|
|
48
|
+
/** the type of the invoked command */
|
|
49
|
+
type: integer
|
|
50
|
+
/** converted users + roles + channels */
|
|
51
|
+
resolved?: ResolvedData
|
|
52
|
+
/** the params + values from the user */
|
|
53
|
+
options?: ApplicationCommand.Option[]
|
|
54
|
+
/** the id of the guild the command is registered to */
|
|
55
|
+
guild_id?: snowflake
|
|
56
|
+
/** id of the user or message targeted by a user or message command */
|
|
57
|
+
target_id?: snowflake
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export namespace ApplicationCommand {
|
|
61
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-application-command-interaction-data-option-structure */
|
|
62
|
+
export interface Option {
|
|
63
|
+
/** the name of the parameter */
|
|
64
|
+
name: string
|
|
65
|
+
/** value of application command option type */
|
|
66
|
+
type: Discord.ApplicationCommand.OptionType
|
|
67
|
+
/** the value of the pair */
|
|
68
|
+
value?: any
|
|
69
|
+
/** present if this option is a group or subcommand */
|
|
70
|
+
options?: Option[]
|
|
71
|
+
/** true if this option is the currently focused option for autocomplete */
|
|
72
|
+
focused?: boolean
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-message-component-data-structure */
|
|
77
|
+
export interface MessageComponent {
|
|
78
|
+
/** the custom_id of the component */
|
|
79
|
+
custom_id: string
|
|
80
|
+
/** the type of the component */
|
|
81
|
+
component_type: ComponentType
|
|
82
|
+
/** values the user selected in a select menu component */
|
|
83
|
+
values?: string[]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure */
|
|
87
|
+
export interface ModalSubmit {
|
|
88
|
+
custom_id: string
|
|
89
|
+
components: Component[]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export namespace Interaction {
|
|
94
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type */
|
|
95
|
+
export enum Type {
|
|
96
|
+
PING = 1,
|
|
97
|
+
APPLICATION_COMMAND = 2,
|
|
98
|
+
MESSAGE_COMPONENT = 3,
|
|
99
|
+
APPLICATION_COMMAND_AUTOCOMPLETE = 4,
|
|
100
|
+
MODAL_SUBMIT = 5,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure */
|
|
105
|
+
export interface ResolvedData {
|
|
106
|
+
/** the ids and User objects */
|
|
107
|
+
users?: Record<snowflake, User>
|
|
108
|
+
/** the ids and partial Member objects */
|
|
109
|
+
members?: Record<snowflake, Partial<GuildMember>>
|
|
110
|
+
/** the ids and Role objects */
|
|
111
|
+
roles?: Record<snowflake, Role>
|
|
112
|
+
/** the ids and partial Channel objects */
|
|
113
|
+
channels?: Record<snowflake, Partial<Channel>>
|
|
114
|
+
/** the ids and partial Message objects */
|
|
115
|
+
messages?: Record<snowflake, Partial<Message>>
|
|
116
|
+
/** the ids and attachment objects */
|
|
117
|
+
attachments?: Record<snowflake, Attachment>
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure */
|
|
121
|
+
export interface MessageInteraction {
|
|
122
|
+
/** id of the interaction */
|
|
123
|
+
id: snowflake
|
|
124
|
+
/** the type of interaction */
|
|
125
|
+
type: Interaction.Type
|
|
126
|
+
/** the name of the application command */
|
|
127
|
+
name: string
|
|
128
|
+
/** the user who invoked the interaction */
|
|
129
|
+
user: User
|
|
130
|
+
/** member who invoked the interaction in the guild */
|
|
131
|
+
member?: Partial<GuildMember>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export namespace Interaction {
|
|
135
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-response-structure */
|
|
136
|
+
export interface Response {
|
|
137
|
+
/** the type of response */
|
|
138
|
+
type: CallbackType
|
|
139
|
+
/** an optional response message */
|
|
140
|
+
data?: CallbackData
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */
|
|
144
|
+
export enum CallbackType {
|
|
145
|
+
/** ACK a Ping */
|
|
146
|
+
PONG = 1,
|
|
147
|
+
/** respond to an interaction with a message */
|
|
148
|
+
CHANNEL_MESSAGE_WITH_SOURCE = 4,
|
|
149
|
+
/** ACK an interaction and edit a response later, the user sees a loading state */
|
|
150
|
+
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5,
|
|
151
|
+
/**
|
|
152
|
+
* for components, ACK an interaction and edit the original message later; the user does not see a loading state
|
|
153
|
+
* (only valid for [component-based](https://discord.com/developers/docs/interactions/message-components) interactions)
|
|
154
|
+
*/
|
|
155
|
+
DEFERRED_UPDATE_MESSAGE = 6,
|
|
156
|
+
/**
|
|
157
|
+
* for components, edit the message the component was attached to
|
|
158
|
+
* (only valid for [component-based](https://discord.com/developers/docs/interactions/message-components) interactions)
|
|
159
|
+
*/
|
|
160
|
+
UPDATE_MESSAGE = 7,
|
|
161
|
+
/** respond to an autocomplete interaction with suggested choices */
|
|
162
|
+
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8,
|
|
163
|
+
/**
|
|
164
|
+
* respond to an interaction with a popup modal
|
|
165
|
+
* (not available for `MODAL_SUBMIT` and `PING` interactions)
|
|
166
|
+
*/
|
|
167
|
+
MODAL = 9,
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type CallbackData =
|
|
171
|
+
| CallbackData.Messages
|
|
172
|
+
| CallbackData.Autocomplete
|
|
173
|
+
| CallbackData.Modal
|
|
174
|
+
|
|
175
|
+
export namespace CallbackData {
|
|
176
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-messages */
|
|
177
|
+
export interface Messages {
|
|
178
|
+
/** is the response TTS */
|
|
179
|
+
tts?: boolean
|
|
180
|
+
/** message content */
|
|
181
|
+
content?: string
|
|
182
|
+
/** supports up to 10 embeds */
|
|
183
|
+
embeds?: Embed[]
|
|
184
|
+
/** allowed mentions object */
|
|
185
|
+
allowed_mentions?: AllowedMentions
|
|
186
|
+
/** interaction callback data flags */
|
|
187
|
+
flags?: integer
|
|
188
|
+
/** message components */
|
|
189
|
+
components?: Component[]
|
|
190
|
+
/** attachment objects with filename and description */
|
|
191
|
+
attachments?: Partial<Attachment>[]
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-autocomplete */
|
|
195
|
+
export interface Autocomplete {
|
|
196
|
+
/** autocomplete choices (max of 25 choices) */
|
|
197
|
+
choices: ApplicationCommand.OptionChoice[]
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-modal */
|
|
201
|
+
export interface Modal {
|
|
202
|
+
/** a developer-defined identifier for the modal, max 100 characters */
|
|
203
|
+
custom_id: string
|
|
204
|
+
/** the title of the popup modal, max 45 characters */
|
|
205
|
+
title: string
|
|
206
|
+
/** between 1 and 5 (inclusive) components that make up the modal */
|
|
207
|
+
components: Component[]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface InteractionCreateEvent extends Interaction { }
|
|
213
|
+
|
|
214
|
+
declare module './gateway' {
|
|
215
|
+
interface GatewayEvents {
|
|
216
|
+
/** user used an interaction, such as an Application Command */
|
|
217
|
+
INTERACTION_CREATE: InteractionCreateEvent
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare module './internal' {
|
|
222
|
+
interface Internal {
|
|
223
|
+
/**
|
|
224
|
+
* Create a response to an Interaction from the gateway. Takes an interaction response. This endpoint also supports file attachments similar to the webhook endpoints. Refer to Uploading Files for details on uploading files and multipart/form-data requests.
|
|
225
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
|
|
226
|
+
*/
|
|
227
|
+
createInteractionResponse(interaction_id: snowflake, token: string, params: Interaction.Response): Promise<void>
|
|
228
|
+
/**
|
|
229
|
+
* Returns the initial Interaction response. Functions the same as Get Webhook Message.
|
|
230
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response
|
|
231
|
+
*/
|
|
232
|
+
getOriginalInteractionResponse(application_id: snowflake, token: string): Promise<Interaction.Response>
|
|
233
|
+
/**
|
|
234
|
+
* Edits the initial Interaction response. Functions the same as Edit Webhook Message.
|
|
235
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response
|
|
236
|
+
*/
|
|
237
|
+
editOriginalInteractionResponse(application_id: snowflake, token: string): Promise<Interaction.Response>
|
|
238
|
+
/**
|
|
239
|
+
* Deletes the initial Interaction response. Returns 204 No Content on success.
|
|
240
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response
|
|
241
|
+
*/
|
|
242
|
+
deleteOriginalInteractionResponse(application_id: snowflake, token: string): Promise<void>
|
|
243
|
+
/**
|
|
244
|
+
* Create a followup message for an Interaction. Functions the same as Execute Webhook, but wait is always true, and flags can be set to 64 in the body to send an ephemeral message. The thread_id, avatar_url, and username parameters are not supported when using this endpoint for interaction followups.
|
|
245
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message
|
|
246
|
+
*/
|
|
247
|
+
createFollowupMessage(application_id: snowflake, token: string): Promise<any>
|
|
248
|
+
/**
|
|
249
|
+
* Returns a followup message for an Interaction. Functions the same as Get Webhook Message. Does not support ephemeral followups.
|
|
250
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message
|
|
251
|
+
*/
|
|
252
|
+
getFollowupMessage(application_id: snowflake, token: string, message_id: snowflake): Promise<any>
|
|
253
|
+
/**
|
|
254
|
+
* Edits a followup message for an Interaction. Functions the same as Edit Webhook Message. Does not support ephemeral followups.
|
|
255
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message
|
|
256
|
+
*/
|
|
257
|
+
editFollowupMessage(application_id: snowflake, token: string, message_id: snowflake): Promise<any>
|
|
258
|
+
/**
|
|
259
|
+
* Deletes a followup message for an Interaction. Returns 204 No Content on success. Does not support ephemeral followups.
|
|
260
|
+
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message
|
|
261
|
+
*/
|
|
262
|
+
deleteFollowupMessage(application_id: snowflake, token: string, message_id: snowflake): Promise<void>
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
Internal.define({
|
|
267
|
+
'/interactions/{interaction.id}/{interaction.token}/callback': {
|
|
268
|
+
POST: 'createInteractionResponse',
|
|
269
|
+
},
|
|
270
|
+
'/webhooks/{application.id}/{interaction.token}/messages/@original': {
|
|
271
|
+
GET: 'getOriginalInteractionResponse',
|
|
272
|
+
PATCH: 'editOriginalInteractionResponse',
|
|
273
|
+
DELETE: 'deleteOriginalInteractionResponse',
|
|
274
|
+
},
|
|
275
|
+
'/webhooks/{application.id}/{interaction.token}': {
|
|
276
|
+
POST: 'createFollowupMessage',
|
|
277
|
+
},
|
|
278
|
+
'/webhooks/{application.id}/{interaction.token}/messages/{message.id}': {
|
|
279
|
+
GET: 'getFollowupMessage',
|
|
280
|
+
PATCH: 'editFollowupMessage',
|
|
281
|
+
DELETE: 'deleteFollowupMessage',
|
|
282
|
+
},
|
|
283
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Dict, Logger, makeArray, Quester } from '@satorijs/satori'
|
|
2
|
+
|
|
3
|
+
const logger = new Logger('discord')
|
|
4
|
+
|
|
5
|
+
export class Internal {
|
|
6
|
+
constructor(private http: Quester) {}
|
|
7
|
+
|
|
8
|
+
static define(routes: Dict<Partial<Record<Quester.Method, string | string[]>>>) {
|
|
9
|
+
for (const path in routes) {
|
|
10
|
+
for (const key in routes[path]) {
|
|
11
|
+
const method = key as Quester.Method
|
|
12
|
+
for (const name of makeArray(routes[path][method])) {
|
|
13
|
+
Internal.prototype[name] = async function (this: Internal, ...args: any[]) {
|
|
14
|
+
const raw = args.join(', ')
|
|
15
|
+
const url = path.replace(/\{([^}]+)\}/g, () => {
|
|
16
|
+
if (!args.length) throw new Error(`too few arguments for ${path}, received ${raw}`)
|
|
17
|
+
return args.shift()
|
|
18
|
+
})
|
|
19
|
+
const config: Quester.AxiosRequestConfig = {}
|
|
20
|
+
if (args.length === 1) {
|
|
21
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
22
|
+
config.params = args[0]
|
|
23
|
+
} else {
|
|
24
|
+
config.data = args[0]
|
|
25
|
+
}
|
|
26
|
+
} else if (args.length === 2 && method !== 'GET' && method !== 'DELETE') {
|
|
27
|
+
config.data = args[0]
|
|
28
|
+
config.params = args[1]
|
|
29
|
+
} else if (args.length > 1) {
|
|
30
|
+
throw new Error(`too many arguments for ${path}, received ${raw}`)
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
logger.debug(`${method} ${url}`, config)
|
|
34
|
+
return await this.http(method, url, config)
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!Quester.isAxiosError(error) || !error.response) throw error
|
|
37
|
+
throw new Error(`[${error.response.status}] ${JSON.stringify(error.response.data)}`)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Application, Channel, Guild, GuildMember, GuildScheduledEvent, integer, Internal, snowflake, timestamp, User } from '.'
|
|
2
|
+
|
|
3
|
+
/** https://discord.com/developers/docs/resources/invite#invite-object-invite-structure */
|
|
4
|
+
export interface Invite {
|
|
5
|
+
/** the invite code (unique ID) */
|
|
6
|
+
code: string
|
|
7
|
+
/** the guild this invite is for */
|
|
8
|
+
guild?: Partial<Guild>
|
|
9
|
+
/** the channel this invite is for */
|
|
10
|
+
channel: Partial<Channel>
|
|
11
|
+
/** the user who created the invite */
|
|
12
|
+
inviter?: User
|
|
13
|
+
/** the type of target for this voice channel invite */
|
|
14
|
+
target_type?: Invite.TargetType
|
|
15
|
+
/** the user whose stream to display for this voice channel stream invite */
|
|
16
|
+
target_user?: User
|
|
17
|
+
/** the embedded application to open for this voice channel embedded application invite */
|
|
18
|
+
target_application?: Partial<Application>
|
|
19
|
+
/** approximate count of online members, returned from the GET /invites/<code> endpoint when with_counts is true */
|
|
20
|
+
approximate_presence_count?: integer
|
|
21
|
+
/** approximate count of total members, returned from the GET /invites/<code> endpoint when with_counts is true */
|
|
22
|
+
approximate_member_count?: integer
|
|
23
|
+
/** the expiration date of this invite, returned from the GET /invites/<code> endpoint when with_expiration is true */
|
|
24
|
+
expires_at?: timestamp
|
|
25
|
+
/** stage instance data if there is a public Stage instance in the Stage channel this invite is for */
|
|
26
|
+
stage_instance?: Invite.StageInstance
|
|
27
|
+
/** guild scheduled event data, only included if guild_scheduled_event_id contains a valid guild scheduled event id */
|
|
28
|
+
guild_scheduled_event?: GuildScheduledEvent
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export namespace Invite {
|
|
32
|
+
/** https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types */
|
|
33
|
+
export enum TargetType {
|
|
34
|
+
STREAM = 1,
|
|
35
|
+
EMBEDDED_APPLICATION = 2,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** https://discord.com/developers/docs/resources/invite#invite-metadata-object-invite-metadata-structure */
|
|
39
|
+
export interface Metadata extends Invite {
|
|
40
|
+
/** number of times this invite has been used */
|
|
41
|
+
uses: integer
|
|
42
|
+
/** max number of times this invite can be used */
|
|
43
|
+
max_uses: integer
|
|
44
|
+
/** duration (in seconds) after which the invite expires */
|
|
45
|
+
max_age: integer
|
|
46
|
+
/** whether this invite only grants temporary membership */
|
|
47
|
+
temporary: boolean
|
|
48
|
+
/** when this invite was created */
|
|
49
|
+
created_at: timestamp
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** https://discord.com/developers/docs/resources/invite#invite-stage-instance-object-invite-stage-instance-structure */
|
|
53
|
+
export interface StageInstance {
|
|
54
|
+
/** the members speaking in the Stage */
|
|
55
|
+
members: Partial<GuildMember>[]
|
|
56
|
+
/** the number of users in the Stage */
|
|
57
|
+
participant_count: integer
|
|
58
|
+
/** the number of users speaking in the Stage */
|
|
59
|
+
speaker_count: integer
|
|
60
|
+
/** the topic of the Stage instance (1-120 characters) */
|
|
61
|
+
topic: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export namespace Event {
|
|
65
|
+
/** https://discord.com/developers/docs/topics/gateway-events#invite-create-invite-create-event-fields */
|
|
66
|
+
export interface Create {
|
|
67
|
+
/** the channel the invite is for */
|
|
68
|
+
channel_id: snowflake
|
|
69
|
+
/** the unique invite code */
|
|
70
|
+
code: string
|
|
71
|
+
/** the time at which the invite was created */
|
|
72
|
+
created_at: timestamp
|
|
73
|
+
/** the guild of the invite */
|
|
74
|
+
guild_id?: snowflake
|
|
75
|
+
/** the user that created the invite */
|
|
76
|
+
inviter?: User
|
|
77
|
+
/** how long the invite is valid for (in seconds) */
|
|
78
|
+
max_age: integer
|
|
79
|
+
/** the maximum number of times the invite can be used */
|
|
80
|
+
max_uses: integer
|
|
81
|
+
/** the type of target for this voice channel invite */
|
|
82
|
+
target_type?: integer
|
|
83
|
+
/** the user whose stream to display for this voice channel stream invite */
|
|
84
|
+
target_user?: User
|
|
85
|
+
/** the embedded application to open for this voice channel embedded application invite */
|
|
86
|
+
target_application?: Partial<Application>
|
|
87
|
+
/** whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */
|
|
88
|
+
temporary: boolean
|
|
89
|
+
/** how many times the invite has been used (always will be 0) */
|
|
90
|
+
uses: integer
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** https://discord.com/developers/docs/topics/gateway-events#invite-delete-invite-delete-event-fields */
|
|
94
|
+
export interface Delete {
|
|
95
|
+
/** the channel of the invite */
|
|
96
|
+
channel_id: snowflake
|
|
97
|
+
/** the guild of the invite */
|
|
98
|
+
guild_id?: snowflake
|
|
99
|
+
/** the unique invite code */
|
|
100
|
+
code: string
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** https://discord.com/developers/docs/resources/invite#get-invite-query-string-params */
|
|
105
|
+
export interface GetOptions {
|
|
106
|
+
/** whether to include invite metadata */
|
|
107
|
+
with_counts?: boolean
|
|
108
|
+
/** whether to include invite expiration date */
|
|
109
|
+
with_expiration?: boolean
|
|
110
|
+
/** the guild scheduled event to include with the invite */
|
|
111
|
+
guild_scheduled_event_id?: snowflake
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params */
|
|
115
|
+
export interface CreateParams {
|
|
116
|
+
/** duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days) */
|
|
117
|
+
max_age: integer
|
|
118
|
+
/** max number of uses or 0 for unlimited. between 0 and 100 */
|
|
119
|
+
max_uses: integer
|
|
120
|
+
/** whether this invite only grants temporary membership */
|
|
121
|
+
temporary: boolean
|
|
122
|
+
/** if true, don't try to reuse a similar invite (useful for creating many unique one time use invites) */
|
|
123
|
+
unique: boolean
|
|
124
|
+
/** the type of target for this voice channel invite */
|
|
125
|
+
target_type: integer
|
|
126
|
+
/** the id of the user whose stream to display for this invite, required if target_type is 1, the user must be streaming in the channel */
|
|
127
|
+
target_user_id: snowflake
|
|
128
|
+
/** the id of the embedded application to open for this invite, required if target_type is 2, the application must have the EMBEDDED flag */
|
|
129
|
+
target_application_id: snowflake
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
declare module './gateway' {
|
|
134
|
+
interface GatewayEvents {
|
|
135
|
+
/** invite to a channel was created */
|
|
136
|
+
INVITE_CREATE: Invite.Event.Create
|
|
137
|
+
/** invite to a channel was deleted */
|
|
138
|
+
INVITE_DELETE: Invite.Event.Delete
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare module './internal' {
|
|
143
|
+
interface Internal {
|
|
144
|
+
/**
|
|
145
|
+
* Returns an invite object for the given code.
|
|
146
|
+
* @see https://discord.com/developers/docs/resources/invite#get-invite
|
|
147
|
+
*/
|
|
148
|
+
getInvite(code: string, params?: Invite.GetOptions): Promise<Invite>
|
|
149
|
+
/**
|
|
150
|
+
* Delete an invite. Requires the MANAGE_CHANNELS permission on the channel this invite belongs to, or MANAGE_GUILD to remove any invite across the guild. Returns an invite object on success. Fires a Invite Delete Gateway event.
|
|
151
|
+
* @see https://discord.com/developers/docs/resources/invite#delete-invite
|
|
152
|
+
*/
|
|
153
|
+
deleteInvite(code: string): Promise<Invite>
|
|
154
|
+
/**
|
|
155
|
+
* Returns a list of invite objects (with invite metadata) for the guild. Requires the MANAGE_GUILD permission.
|
|
156
|
+
* @see https://discord.com/developers/docs/resources/guild#get-guild-invites
|
|
157
|
+
*/
|
|
158
|
+
getGuildInvites(guild_id: snowflake): Promise<Invite.Metadata[]>
|
|
159
|
+
/**
|
|
160
|
+
* Returns a partial invite object for guilds with that feature enabled. Requires the MANAGE_GUILD permission. code will be null if a vanity url for the guild is not set.
|
|
161
|
+
* @see https://discord.com/developers/docs/resources/guild#get-guild-vanity-url
|
|
162
|
+
*/
|
|
163
|
+
getGuildVanityURL(guild_id: snowflake): Promise<Partial<Invite>>
|
|
164
|
+
/**
|
|
165
|
+
* Returns a list of invite objects (with invite metadata) for the channel. Only usable for guild channels. Requires the MANAGE_CHANNELS permission.
|
|
166
|
+
* @see https://discord.com/developers/docs/resources/channel#get-channel-invites
|
|
167
|
+
*/
|
|
168
|
+
getChannelInvites(channel_id: string): Promise<Invite.Metadata[]>
|
|
169
|
+
/**
|
|
170
|
+
* Create a new invite object for the channel. Only usable for guild channels. Requires the CREATE_INSTANT_INVITE permission. All JSON parameters for this route are optional, however the request body is not. If you are not sending any fields, you still have to send an empty JSON object ({}). Returns an invite object. Fires an Invite Create Gateway event.
|
|
171
|
+
* @see https://discord.com/developers/docs/resources/channel#create-channel-invite
|
|
172
|
+
*/
|
|
173
|
+
createChannelInvite(channel_id: string, params: Invite.CreateParams): Promise<void>
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Internal.define({
|
|
178
|
+
'/invites/{invite.code}': {
|
|
179
|
+
GET: 'getInvite',
|
|
180
|
+
DELETE: 'deleteInvite',
|
|
181
|
+
},
|
|
182
|
+
'/guilds/{guild.id}/invites': {
|
|
183
|
+
GET: 'getGuildInvites',
|
|
184
|
+
},
|
|
185
|
+
'/guilds/{guild.id}/vanity-url': {
|
|
186
|
+
GET: 'getGuildVanityURL',
|
|
187
|
+
},
|
|
188
|
+
'/channels/{channel.id}/invites': {
|
|
189
|
+
GET: 'getChannelInvites',
|
|
190
|
+
POST: 'createChannelInvite',
|
|
191
|
+
},
|
|
192
|
+
})
|