@satorijs/adapter-discord 4.1.3 → 4.1.5
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 +15 -21
- package/lib/index.js.map +2 -3
- package/lib/types/internal.d.ts +3 -2
- package/lib/utils.d.ts +1 -1
- package/package.json +5 -4
- package/src/bot.ts +218 -0
- package/src/index.ts +27 -0
- package/src/message.ts +444 -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 +43 -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 +122 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { Activity, integer, Internal, snowflake, StatusType } from '.'
|
|
2
|
+
|
|
3
|
+
export namespace Gateway {
|
|
4
|
+
/** https://discord.com/developers/docs/topics/gateway-events#payload-structure */
|
|
5
|
+
export interface PayloadStructure<O extends Opcode, T extends keyof GatewayEvents, D> {
|
|
6
|
+
/** opcode for the payload */
|
|
7
|
+
op: O
|
|
8
|
+
/** event data */
|
|
9
|
+
d?: D
|
|
10
|
+
/** the event name for this payload */
|
|
11
|
+
t?: T
|
|
12
|
+
/** sequence number, used for resuming sessions and heartbeats */
|
|
13
|
+
s?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Payload = {
|
|
17
|
+
[O in Opcode]: O extends Opcode.DISPATCH
|
|
18
|
+
? {
|
|
19
|
+
[T in keyof GatewayEvents]: PayloadStructure<Opcode.DISPATCH, T, GatewayEvents[T]>
|
|
20
|
+
}[keyof GatewayEvents]
|
|
21
|
+
: PayloadStructure<O, never, O extends keyof Params ? Params[O] : never>
|
|
22
|
+
}[Opcode]
|
|
23
|
+
|
|
24
|
+
/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes */
|
|
25
|
+
export enum Opcode {
|
|
26
|
+
/** An event was dispatched. */
|
|
27
|
+
DISPATCH = 0,
|
|
28
|
+
/** Fired periodically by the client to keep the connection alive. */
|
|
29
|
+
HEARTBEAT = 1,
|
|
30
|
+
/** Starts a new session during the initial handshake. */
|
|
31
|
+
IDENTIFY = 2,
|
|
32
|
+
/** Update the client's presence. */
|
|
33
|
+
PRESENCE_UPDATE = 3,
|
|
34
|
+
/** Used to join/leave or move between voice channels. */
|
|
35
|
+
VOICE_STATE_UPDATE = 4,
|
|
36
|
+
/** Resume a previous session that was disconnected. */
|
|
37
|
+
RESUME = 6,
|
|
38
|
+
/** You should attempt to reconnect and resume immediately. */
|
|
39
|
+
RECONNECT = 7,
|
|
40
|
+
/** Request information about offline guild members in a large guild. */
|
|
41
|
+
REQUEST_GUILD_MEMBERS = 8,
|
|
42
|
+
/** The session has been invalidated. You should reconnect and identify/resume accordingly. */
|
|
43
|
+
INVALID_SESSION = 9,
|
|
44
|
+
/** Sent immediately after connecting, contains the `heartbeat_interval` to use. */
|
|
45
|
+
HELLO = 10,
|
|
46
|
+
/** Sent in response to receiving a heartbeat to acknowledge that it has been received. */
|
|
47
|
+
HEARTBEAT_ACK = 11,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** https://discord.com/developers/docs/topics/gateway#gateway-intents */
|
|
51
|
+
export enum Intent {
|
|
52
|
+
/**
|
|
53
|
+
* - GUILD_CREATE
|
|
54
|
+
* - GUILD_UPDATE
|
|
55
|
+
* - GUILD_DELETE
|
|
56
|
+
* - GUILD_ROLE_CREATE
|
|
57
|
+
* - GUILD_ROLE_UPDATE
|
|
58
|
+
* - GUILD_ROLE_DELETE
|
|
59
|
+
* - CHANNEL_CREATE
|
|
60
|
+
* - CHANNEL_UPDATE
|
|
61
|
+
* - CHANNEL_DELETE
|
|
62
|
+
* - CHANNEL_PINS_UPDATE
|
|
63
|
+
* - THREAD_CREATE
|
|
64
|
+
* - THREAD_UPDATE
|
|
65
|
+
* - THREAD_DELETE
|
|
66
|
+
* - THREAD_LIST_SYNC
|
|
67
|
+
* - THREAD_MEMBER_UPDATE
|
|
68
|
+
* - THREAD_MEMBERS_UPDATE
|
|
69
|
+
* - STAGE_INSTANCE_CREATE
|
|
70
|
+
* - STAGE_INSTANCE_UPDATE
|
|
71
|
+
* - STAGE_INSTANCE_DELETE
|
|
72
|
+
*/
|
|
73
|
+
GUILDS = 1 << 0,
|
|
74
|
+
/**
|
|
75
|
+
* - GUILD_MEMBER_ADD
|
|
76
|
+
* - GUILD_MEMBER_UPDATE
|
|
77
|
+
* - GUILD_MEMBER_REMOVE
|
|
78
|
+
* - THREAD_MEMBERS_UPDATE
|
|
79
|
+
*/
|
|
80
|
+
GUILD_MEMBERS = 1 << 1,
|
|
81
|
+
/**
|
|
82
|
+
* - GUILD_BAN_ADD
|
|
83
|
+
* - GUILD_BAN_REMOVE
|
|
84
|
+
*/
|
|
85
|
+
GUILD_BANS = 1 << 2,
|
|
86
|
+
/**
|
|
87
|
+
* - GUILD_EMOJIS_UPDATE
|
|
88
|
+
* - GUILD_STICKERS_UPDATE
|
|
89
|
+
*/
|
|
90
|
+
GUILD_EMOJIS_AND_STICKERS = 1 << 3,
|
|
91
|
+
/**
|
|
92
|
+
* - GUILD_INTEGRATIONS_UPDATE
|
|
93
|
+
* - INTEGRATION_CREATE
|
|
94
|
+
* - INTEGRATION_UPDATE
|
|
95
|
+
* - INTEGRATION_DELETE
|
|
96
|
+
*/
|
|
97
|
+
GUILD_INTEGRATIONS = 1 << 4,
|
|
98
|
+
/**
|
|
99
|
+
* - WEBHOOKS_UPDATE
|
|
100
|
+
*/
|
|
101
|
+
GUILD_WEBHOOKS = 1 << 5,
|
|
102
|
+
/**
|
|
103
|
+
* - INVITE_CREATE
|
|
104
|
+
* - INVITE_DELETE
|
|
105
|
+
*/
|
|
106
|
+
GUILD_INVITES = 1 << 6,
|
|
107
|
+
/**
|
|
108
|
+
* - VOICE_STATE_UPDATE
|
|
109
|
+
*/
|
|
110
|
+
GUILD_VOICE_STATES = 1 << 7,
|
|
111
|
+
/**
|
|
112
|
+
* - PRESENCE_UPDATE
|
|
113
|
+
*/
|
|
114
|
+
GUILD_PRESENCES = 1 << 8,
|
|
115
|
+
/**
|
|
116
|
+
* - MESSAGE_CREATE
|
|
117
|
+
* - MESSAGE_UPDATE
|
|
118
|
+
* - MESSAGE_DELETE
|
|
119
|
+
* - MESSAGE_DELETE_BULK
|
|
120
|
+
*/
|
|
121
|
+
GUILD_MESSAGES = 1 << 9,
|
|
122
|
+
/**
|
|
123
|
+
* - MESSAGE_REACTION_ADD
|
|
124
|
+
* - MESSAGE_REACTION_REMOVE
|
|
125
|
+
* - MESSAGE_REACTION_REMOVE_ALL
|
|
126
|
+
* - MESSAGE_REACTION_REMOVE_EMOJI
|
|
127
|
+
*/
|
|
128
|
+
GUILD_MESSAGE_REACTIONS = 1 << 10,
|
|
129
|
+
/**
|
|
130
|
+
* - TYPING_START
|
|
131
|
+
*/
|
|
132
|
+
GUILD_MESSAGE_TYPING = 1 << 11,
|
|
133
|
+
/**
|
|
134
|
+
* - MESSAGE_CREATE
|
|
135
|
+
* - MESSAGE_UPDATE
|
|
136
|
+
* - MESSAGE_DELETE
|
|
137
|
+
* - CHANNEL_PINS_UPDATE
|
|
138
|
+
*/
|
|
139
|
+
DIRECT_MESSAGES = 1 << 12,
|
|
140
|
+
/**
|
|
141
|
+
* - MESSAGE_REACTION_ADD
|
|
142
|
+
* - MESSAGE_REACTION_REMOVE
|
|
143
|
+
* - MESSAGE_REACTION_REMOVE_ALL
|
|
144
|
+
* - MESSAGE_REACTION_REMOVE_EMOJI
|
|
145
|
+
*/
|
|
146
|
+
DIRECT_MESSAGE_REACTIONS = 1 << 13,
|
|
147
|
+
/**
|
|
148
|
+
* - TYPING_START
|
|
149
|
+
*/
|
|
150
|
+
DIRECT_MESSAGE_TYPING = 1 << 14,
|
|
151
|
+
/**
|
|
152
|
+
* `MESSAGE_CONTENT` is a unique privileged intent that isn't directly associated with any Gateway events.
|
|
153
|
+
* Instead, access to `MESSAGE_CONTENT` permits your app to receive message content data across the APIs.
|
|
154
|
+
*
|
|
155
|
+
* Any fields affected by the message content intent are noted in the relevant documentation.
|
|
156
|
+
* For example, the content, embeds, attachments, and components fields in message objects all contain message content and therefore require the intent.
|
|
157
|
+
*
|
|
158
|
+
* Like other privileged intents, `MESSAGE_CONTENT` must be approved for your app.
|
|
159
|
+
* After your app is verified, you can apply for the intent from your app's settings within the Developer Portal.
|
|
160
|
+
* You can read more about the message content intent review policy in the [Help Center](https://support-dev.discord.com/hc/en-us/articles/5324827539479).
|
|
161
|
+
*
|
|
162
|
+
* Apps without the intent will receive empty values in fields that contain user-inputted content with a few exceptions:
|
|
163
|
+
* - Content in messages that an app sends
|
|
164
|
+
* - Content in DMs with the app
|
|
165
|
+
* - Content in which the app is mentioned
|
|
166
|
+
*
|
|
167
|
+
* @see https://discord.com/developers/docs/topics/gateway#message-content-intent
|
|
168
|
+
*/
|
|
169
|
+
MESSAGE_CONTENT = 1 << 15,
|
|
170
|
+
/**
|
|
171
|
+
* - GUILD_SCHEDULED_EVENT_CREATE
|
|
172
|
+
* - GUILD_SCHEDULED_EVENT_UPDATE
|
|
173
|
+
* - GUILD_SCHEDULED_EVENT_DELETE
|
|
174
|
+
* - GUILD_SCHEDULED_EVENT_USER_ADD
|
|
175
|
+
* - GUILD_SCHEDULED_EVENT_USER_REMOVE
|
|
176
|
+
*/
|
|
177
|
+
GUILD_SCHEDULED_EVENTS = 1 << 16,
|
|
178
|
+
/**
|
|
179
|
+
* - AUTO_MODERATION_RULE_CREATE
|
|
180
|
+
* - AUTO_MODERATION_RULE_UPDATE
|
|
181
|
+
* - AUTO_MODERATION_RULE_DELETE
|
|
182
|
+
*/
|
|
183
|
+
AUTO_MODERATION_CONFIGURATION = 1 << 20,
|
|
184
|
+
/**
|
|
185
|
+
* - AUTO_MODERATION_ACTION_EXECUTION
|
|
186
|
+
*/
|
|
187
|
+
AUTO_MODERATION_EXECUTION = 1 << 21,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface Params {
|
|
191
|
+
[Opcode.HELLO]: Params.Hello
|
|
192
|
+
[Opcode.IDENTIFY]: Params.Identify
|
|
193
|
+
[Opcode.RESUME]: Params.Resume
|
|
194
|
+
[Opcode.REQUEST_GUILD_MEMBERS]: Params.RequestGuildMembers
|
|
195
|
+
[Opcode.VOICE_STATE_UPDATE]: Params.VoiceStateUpdate
|
|
196
|
+
[Opcode.PRESENCE_UPDATE]: Params.PresenceUpdate
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export namespace Params {
|
|
200
|
+
/** https://discord.com/developers/docs/topics/gateway-events#hello-hello-structure */
|
|
201
|
+
export interface Hello {
|
|
202
|
+
/** the interval (in milliseconds) the client should heartbeat with */
|
|
203
|
+
heartbeat_interval: integer
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** https://discord.com/developers/docs/topics/gateway-events#identify-identify-structure */
|
|
207
|
+
export interface Identify {
|
|
208
|
+
/** authentication token */
|
|
209
|
+
token: string
|
|
210
|
+
/** connection properties */
|
|
211
|
+
properties: ConnectionProperties
|
|
212
|
+
/** whether this connection supports compression of packets */
|
|
213
|
+
compress?: boolean
|
|
214
|
+
/** value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list */
|
|
215
|
+
large_threshold?: integer
|
|
216
|
+
/** used for Guild Sharding */
|
|
217
|
+
shard?: [shard_id: integer, num_shards: integer]
|
|
218
|
+
/** presence structure for initial presence information */
|
|
219
|
+
presence?: PresenceUpdate
|
|
220
|
+
/** the Gateway Intents you wish to receive */
|
|
221
|
+
intents: integer
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** https://discord.com/developers/docs/topics/gateway-events#identify-identify-connection-properties */
|
|
225
|
+
export interface ConnectionProperties {
|
|
226
|
+
/** Your operating system */
|
|
227
|
+
os: string
|
|
228
|
+
/** Your library name */
|
|
229
|
+
browser: string
|
|
230
|
+
/** Your library name */
|
|
231
|
+
device: string
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** https://discord.com/developers/docs/topics/gateway-events#resume-resume-structure */
|
|
235
|
+
export interface Resume {
|
|
236
|
+
/** session token */
|
|
237
|
+
token: string
|
|
238
|
+
/** session id */
|
|
239
|
+
session_id: string
|
|
240
|
+
/** last sequence number received */
|
|
241
|
+
seq: integer
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** https://discord.com/developers/docs/topics/gateway-events#request-guild-members-guild-request-members-structure */
|
|
245
|
+
export interface RequestGuildMembers {
|
|
246
|
+
/** id of the guild to get members for */
|
|
247
|
+
guild_id: snowflake
|
|
248
|
+
/** string that username starts with, or an empty string to return all members */
|
|
249
|
+
query?: string
|
|
250
|
+
/** maximum number of members to send matching the query; a limit of 0 can be used with an empty string query to return all members */
|
|
251
|
+
limit: integer
|
|
252
|
+
/** used to specify if we want the presences of the matched members */
|
|
253
|
+
presences?: boolean
|
|
254
|
+
/** used to specify which users you wish to fetch */
|
|
255
|
+
user_ids?: snowflake | snowflake[]
|
|
256
|
+
/** nonce to identify the Guild Members Chunk response */
|
|
257
|
+
nonce?: string
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** https://discord.com/developers/docs/topics/gateway-events#update-voice-state-gateway-voice-state-update-structure */
|
|
261
|
+
export interface VoiceStateUpdate {
|
|
262
|
+
/** id of the guild */
|
|
263
|
+
guild_id: snowflake
|
|
264
|
+
/** id of the voice channel client wants to join (null if disconnecting) */
|
|
265
|
+
channel_id?: snowflake
|
|
266
|
+
/** is the client muted */
|
|
267
|
+
self_mute: boolean
|
|
268
|
+
/** is the client deafened */
|
|
269
|
+
self_deaf: boolean
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** https://discord.com/developers/docs/topics/gateway-events#update-presence-gateway-presence-update-structure */
|
|
273
|
+
export interface PresenceUpdate {
|
|
274
|
+
/** unix time (in milliseconds) of when the client went idle, or null if the client is not idle */
|
|
275
|
+
since?: integer
|
|
276
|
+
/** the user's activities */
|
|
277
|
+
activities: Activity[]
|
|
278
|
+
/** the user's new status */
|
|
279
|
+
status: StatusType
|
|
280
|
+
/** whether or not the client is afk */
|
|
281
|
+
afk: boolean
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** https://discord.com/developers/docs/topics/gateway-events#gateway-events */
|
|
287
|
+
export interface GatewayEvents {}
|
|
288
|
+
|
|
289
|
+
/** https://discord.com/developers/docs/topics/gateway-events#session-start-limit-object-session-start-limit-structure */
|
|
290
|
+
export interface SessionStartLimit {
|
|
291
|
+
/** The total number of session starts the current user is allowed */
|
|
292
|
+
total: integer
|
|
293
|
+
/** The remaining number of session starts the current user is allowed */
|
|
294
|
+
remaining: integer
|
|
295
|
+
/** The number of milliseconds after which the limit resets */
|
|
296
|
+
reset_after: integer
|
|
297
|
+
/** The number of identify requests allowed per 5 seconds */
|
|
298
|
+
max_concurrency: integer
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway-example-response */
|
|
302
|
+
export interface GetGatewayResponse {
|
|
303
|
+
url: string
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot-json-response */
|
|
307
|
+
export interface GetGatewayBotResponse extends GetGatewayResponse {
|
|
308
|
+
shards: integer
|
|
309
|
+
session_start_limit: SessionStartLimit
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
declare module './internal' {
|
|
313
|
+
interface Internal {
|
|
314
|
+
/**
|
|
315
|
+
* Returns an object with a single valid WSS URL, which the client can use for Connecting. Clients should cache this value and only call this endpoint to retrieve a new URL if they are unable to properly establish a connection using the cached version of the URL.
|
|
316
|
+
* @see https://discord.com/developers/docs/topics/gateway#get-gateway
|
|
317
|
+
*/
|
|
318
|
+
getGateway(): Promise<GetGatewayResponse>
|
|
319
|
+
/**
|
|
320
|
+
* Returns an object based on the information in Get Gateway, plus additional metadata that can help during the operation of large or sharded bots. Unlike the Get Gateway, this route should not be cached for extended periods of time as the value is not guaranteed to be the same per-call, and changes as the bot joins/leaves guilds.
|
|
321
|
+
* @see https://discord.com/developers/docs/topics/gateway#get-gateway-bot
|
|
322
|
+
*/
|
|
323
|
+
getGatewayBot(): Promise<GetGatewayBotResponse>
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
Internal.define({
|
|
328
|
+
'/gateway': {
|
|
329
|
+
GET: 'getGateway',
|
|
330
|
+
},
|
|
331
|
+
'/gateway/bot': {
|
|
332
|
+
GET: 'getGatewayBot',
|
|
333
|
+
},
|
|
334
|
+
})
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Gateway, integer, Internal, snowflake, timestamp, User } from '.'
|
|
2
|
+
|
|
3
|
+
/** https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure */
|
|
4
|
+
export interface GuildMember {
|
|
5
|
+
/** the user this guild member represents */
|
|
6
|
+
user?: User
|
|
7
|
+
/** this users guild nickname */
|
|
8
|
+
nick?: string
|
|
9
|
+
/** the member's guild avatar hash */
|
|
10
|
+
avatar?: string
|
|
11
|
+
/** array of role object ids */
|
|
12
|
+
roles: snowflake[]
|
|
13
|
+
/** when the user joined the guild */
|
|
14
|
+
joined_at: timestamp
|
|
15
|
+
/** when the user started boosting the guild */
|
|
16
|
+
premium_since?: timestamp
|
|
17
|
+
/** whether the user is deafened in voice channels */
|
|
18
|
+
deaf: boolean
|
|
19
|
+
/** whether the user is muted in voice channels */
|
|
20
|
+
mute: boolean
|
|
21
|
+
/** whether the user has not yet passed the guild's Membership Screening requirements */
|
|
22
|
+
pending?: boolean
|
|
23
|
+
/** total permissions of the member in the channel, including overwrites, returned when in the interaction object */
|
|
24
|
+
permissions?: string
|
|
25
|
+
/** when the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out */
|
|
26
|
+
communication_disabled_until?: timestamp
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export namespace GuildMember {
|
|
30
|
+
export namespace Params {
|
|
31
|
+
/** https://discord.com/developers/docs/resources/guild#list-guild-members-query-string-params */
|
|
32
|
+
export interface List {
|
|
33
|
+
/** max number of members to return (1-1000) */
|
|
34
|
+
limit?: integer
|
|
35
|
+
/** the highest user id in the previous page */
|
|
36
|
+
after?: snowflake
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** https://discord.com/developers/docs/resources/guild#search-guild-members-query-string-params */
|
|
40
|
+
export interface Search {
|
|
41
|
+
/** Query string to match username(s) and nickname(s) against. */
|
|
42
|
+
query: string
|
|
43
|
+
/** max number of members to return (1-1000) */
|
|
44
|
+
limit?: integer
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** https://discord.com/developers/docs/resources/guild#add-guild-member-json-params */
|
|
48
|
+
export interface Add {
|
|
49
|
+
/** an oauth2 access token granted with the guilds.join to the bot's application for the user you want to add to the guild */
|
|
50
|
+
access_token: string
|
|
51
|
+
/** value to set user's nickname to */
|
|
52
|
+
nick: string
|
|
53
|
+
/** array of role ids the member is assigned */
|
|
54
|
+
roles: snowflake[]
|
|
55
|
+
/** whether the user is muted in voice channels */
|
|
56
|
+
mute: boolean
|
|
57
|
+
/** whether the user is deafened in voice channels */
|
|
58
|
+
deaf: boolean
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** https://discord.com/developers/docs/resources/guild#modify-guild-member-json-params */
|
|
62
|
+
export interface Modify {
|
|
63
|
+
/** value to set user's nickname to */
|
|
64
|
+
nick: string
|
|
65
|
+
/** array of role ids the member is assigned */
|
|
66
|
+
roles: snowflake[]
|
|
67
|
+
/** whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel */
|
|
68
|
+
mute: boolean
|
|
69
|
+
/** whether the user is deafened in voice channels. Will throw a 400 if the user is not in a voice channel */
|
|
70
|
+
deaf: boolean
|
|
71
|
+
/** id of channel to move user to (if they are connected to voice) */
|
|
72
|
+
channel_id: snowflake
|
|
73
|
+
/** when the user's timeout will expire and the user will be able to communicate in the guild again (up to 28 days in the future), set to null to remove timeout */
|
|
74
|
+
communication_disabled_until?: timestamp
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** https://discord.com/developers/docs/resources/guild#modify-current-member-json-params */
|
|
78
|
+
export interface ModifyCurrent {
|
|
79
|
+
/** value to set user's nickname to */
|
|
80
|
+
nick?: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count-query-string-params */
|
|
84
|
+
export interface GetPruneCount {
|
|
85
|
+
/** number of days to count prune for (1-30) */
|
|
86
|
+
days: integer
|
|
87
|
+
/** role(s) to include */
|
|
88
|
+
include_roles: string
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** https://discord.com/developers/docs/resources/guild#begin-guild-prune-json-params */
|
|
92
|
+
export interface BeginPrune {
|
|
93
|
+
/** number of days to prune (1-30) */
|
|
94
|
+
days: integer
|
|
95
|
+
/** whether 'pruned' is returned, discouraged for large guilds */
|
|
96
|
+
compute_prune_count: boolean
|
|
97
|
+
/** role(s) to include */
|
|
98
|
+
include_roles: snowflake[]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export namespace Event {
|
|
103
|
+
/** https://discord.com/developers/docs/topics/gateway-events#guild-member-add-guild-member-add-extra-fields */
|
|
104
|
+
export interface Add extends GuildMember {
|
|
105
|
+
/** id of the guild */
|
|
106
|
+
guild_id: snowflake
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** https://discord.com/developers/docs/topics/gateway-events#guild-member-remove-guild-member-remove-event-fields */
|
|
110
|
+
export interface Remove {
|
|
111
|
+
/** the id of the guild */
|
|
112
|
+
guild_id: snowflake
|
|
113
|
+
/** the user who was removed */
|
|
114
|
+
user: User
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** https://discord.com/developers/docs/topics/gateway-events#guild-member-update-guild-member-update-event-fields */
|
|
118
|
+
export interface Update {
|
|
119
|
+
/** the id of the guild */
|
|
120
|
+
guild_id: snowflake
|
|
121
|
+
/** user role ids */
|
|
122
|
+
roles: snowflake[]
|
|
123
|
+
/** the user */
|
|
124
|
+
user: User
|
|
125
|
+
/** nickname of the user in the guild */
|
|
126
|
+
nick?: string
|
|
127
|
+
/** the member's guild avatar hash */
|
|
128
|
+
avatar?: string
|
|
129
|
+
/** when the user joined the guild */
|
|
130
|
+
joined_at?: timestamp
|
|
131
|
+
/** when the user starting boosting the guild */
|
|
132
|
+
premium_since?: timestamp
|
|
133
|
+
/** whether the user is deafened in voice channels */
|
|
134
|
+
deaf?: boolean
|
|
135
|
+
/** whether the user is muted in voice channels */
|
|
136
|
+
mute?: boolean
|
|
137
|
+
/** whether the user has not yet passed the guild's Membership Screening requirements */
|
|
138
|
+
pending?: boolean
|
|
139
|
+
/** when the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out */
|
|
140
|
+
communication_disabled_until?: timestamp
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** https://discord.com/developers/docs/topics/gateway-events#guild-members-chunk-guild-members-chunk-event-fields */
|
|
144
|
+
export interface Chunk {
|
|
145
|
+
/** the id of the guild */
|
|
146
|
+
guild_id: snowflake
|
|
147
|
+
/** set of guild members */
|
|
148
|
+
members: GuildMember[]
|
|
149
|
+
/** the chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count) */
|
|
150
|
+
chunk_index: integer
|
|
151
|
+
/** the total number of expected chunks for this response */
|
|
152
|
+
chunk_count: integer
|
|
153
|
+
/** if passing an invalid id to REQUEST_GUILD_MEMBERS, it will be returned here */
|
|
154
|
+
not_found?: snowflake[]
|
|
155
|
+
/** if passing true to REQUEST_GUILD_MEMBERS, presences of the returned members will be here */
|
|
156
|
+
presences?: Gateway.Params.PresenceUpdate[]
|
|
157
|
+
/** the nonce used in the Guild Members Request */
|
|
158
|
+
nonce?: string
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
declare module './gateway' {
|
|
164
|
+
interface GatewayEvents {
|
|
165
|
+
/** new user joined a guild */
|
|
166
|
+
GUILD_MEMBER_ADD: GuildMember.Event.Add
|
|
167
|
+
/** user was removed from a guild */
|
|
168
|
+
GUILD_MEMBER_REMOVE: GuildMember.Event.Remove
|
|
169
|
+
/** guild member was updated */
|
|
170
|
+
GUILD_MEMBER_UPDATE: GuildMember.Event.Update
|
|
171
|
+
/** response to Request Guild Members */
|
|
172
|
+
GUILD_MEMBERS_CHUNK: GuildMember.Event.Chunk
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare module './internal' {
|
|
177
|
+
interface Internal {
|
|
178
|
+
/**
|
|
179
|
+
* Returns a guild member object for the specified user.
|
|
180
|
+
* @see https://discord.com/developers/docs/resources/guild#get-guild-member
|
|
181
|
+
*/
|
|
182
|
+
getGuildMember(guild_id: snowflake, user_id: snowflake): Promise<GuildMember>
|
|
183
|
+
/**
|
|
184
|
+
* Returns a list of guild member objects that are members of the guild.
|
|
185
|
+
* @see https://discord.com/developers/docs/resources/guild#list-guild-members
|
|
186
|
+
*/
|
|
187
|
+
listGuildMembers(guild_id: snowflake, params?: GuildMember.Params.List): Promise<GuildMember[]>
|
|
188
|
+
/**
|
|
189
|
+
* Returns a list of guild member objects whose username or nickname starts with a provided string.
|
|
190
|
+
* @see https://discord.com/developers/docs/resources/guild#search-guild-members
|
|
191
|
+
*/
|
|
192
|
+
searchGuildMembers(guild_id: snowflake, params?: GuildMember.Params.Search): Promise<GuildMember[]>
|
|
193
|
+
/**
|
|
194
|
+
* Adds a user to the guild, provided you have a valid oauth2 access token for the user with the guilds.join scope. Returns a 201 Created with the guild member as the body, or 204 No Content if the user is already a member of the guild. Fires a Guild Member Add Gateway event.
|
|
195
|
+
* @see https://discord.com/developers/docs/resources/guild#add-guild-member
|
|
196
|
+
*/
|
|
197
|
+
addGuildMember(guild_id: snowflake, user_id: snowflake, params: GuildMember.Params.Add): Promise<void>
|
|
198
|
+
/**
|
|
199
|
+
* Modify attributes of a guild member. Returns a 200 OK with the guild member as the body. Fires a Guild Member Update Gateway event. If the channel_id is set to null, this will force the target user to be disconnected from voice.
|
|
200
|
+
* @see https://discord.com/developers/docs/resources/guild#modify-guild-member
|
|
201
|
+
*/
|
|
202
|
+
modifyGuildMember(guild_id: snowflake, user_id: snowflake, params: GuildMember.Params.Modify): Promise<void>
|
|
203
|
+
/**
|
|
204
|
+
* Modifies the current member in a guild. Returns a 200 with the updated member object on success. Fires a Guild Member Update Gateway event.
|
|
205
|
+
* @see https://discord.com/developers/docs/resources/guild#modify-current-member
|
|
206
|
+
*/
|
|
207
|
+
modifyCurrentMember(guild_id: snowflake, params: GuildMember.Params.ModifyCurrent): Promise<void>
|
|
208
|
+
/**
|
|
209
|
+
* Adds a role to a guild member. Requires the MANAGE_ROLES permission. Returns a 204 empty response on success. Fires a Guild Member Update Gateway event.
|
|
210
|
+
* @see https://discord.com/developers/docs/resources/guild#add-guild-member-role
|
|
211
|
+
*/
|
|
212
|
+
addGuildMemberRole(guild_id: snowflake, user_id: snowflake, role_id: snowflake): Promise<void>
|
|
213
|
+
/**
|
|
214
|
+
* Removes a role from a guild member. Requires the MANAGE_ROLES permission. Returns a 204 empty response on success. Fires a Guild Member Update Gateway event.
|
|
215
|
+
* @see https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
|
216
|
+
*/
|
|
217
|
+
removeGuildMemberRole(guild_id: snowflake, user_id: snowflake, role_id: snowflake): Promise<void>
|
|
218
|
+
/**
|
|
219
|
+
* Remove a member from a guild. Requires KICK_MEMBERS permission. Returns a 204 empty response on success. Fires a Guild Member Remove Gateway event.
|
|
220
|
+
* @see https://discord.com/developers/docs/resources/guild#remove-guild-member
|
|
221
|
+
*/
|
|
222
|
+
removeGuildMember(guild_id: snowflake, user_id: snowflake): Promise<void>
|
|
223
|
+
/**
|
|
224
|
+
* Returns an object with one 'pruned' key indicating the number of members that would be removed in a prune operation. Requires the KICK_MEMBERS permission.
|
|
225
|
+
* @see https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
|
226
|
+
*/
|
|
227
|
+
getGuildPruneCount(guild_id: snowflake, params?: GuildMember.Params.GetPruneCount): Promise<void>
|
|
228
|
+
/**
|
|
229
|
+
* Begin a prune operation. Requires the KICK_MEMBERS permission. Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation. For large guilds it's recommended to set the compute_prune_count option to false, forcing 'pruned' to null. Fires multiple Guild Member Remove Gateway events.
|
|
230
|
+
* @see https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
|
231
|
+
*/
|
|
232
|
+
beginGuildPrune(guild_id: snowflake, params: GuildMember.Params.BeginPrune): Promise<void>
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
Internal.define({
|
|
237
|
+
'/guilds/{guild.id}/members/{user.id}': {
|
|
238
|
+
GET: 'getGuildMember',
|
|
239
|
+
PUT: 'addGuildMember',
|
|
240
|
+
PATCH: 'modifyGuildMember',
|
|
241
|
+
DELETE: 'removeGuildMember',
|
|
242
|
+
},
|
|
243
|
+
'/guilds/{guild.id}/members': {
|
|
244
|
+
GET: 'listGuildMembers',
|
|
245
|
+
},
|
|
246
|
+
'/guilds/{guild.id}/members/search': {
|
|
247
|
+
GET: 'searchGuildMembers',
|
|
248
|
+
},
|
|
249
|
+
'/guilds/{guild.id}/members/@me': {
|
|
250
|
+
PATCH: 'modifyCurrentMember',
|
|
251
|
+
},
|
|
252
|
+
'/guilds/{guild.id}/members/{user.id}/roles/{role.id}': {
|
|
253
|
+
PUT: 'addGuildMemberRole',
|
|
254
|
+
DELETE: 'removeGuildMemberRole',
|
|
255
|
+
},
|
|
256
|
+
'/guilds/{guild.id}/prune': {
|
|
257
|
+
GET: 'getGuildPruneCount',
|
|
258
|
+
POST: 'beginGuildPrune',
|
|
259
|
+
},
|
|
260
|
+
})
|