disgroove 2.2.2-dev.23938d8 → 2.2.2-dev.bd3875c

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.
@@ -39,8 +39,10 @@ class Shard {
39
39
  sessionID;
40
40
  constructor(id, client) {
41
41
  this.id = id;
42
+ this.heartbeatInterval = null;
42
43
  this.client = client;
43
- this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json");
44
+ this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", client.ws);
45
+ this.sessionID = null;
44
46
  }
45
47
  /** https://discord.com/developers/docs/topics/gateway#connections */
46
48
  connect() {
@@ -83,33 +85,33 @@ class Shard {
83
85
  }));
84
86
  }
85
87
  onDispatch(packet) {
86
- this.client.emit(constants_1.GatewayEvents.Dispatch, packet);
88
+ this.client.emit("dispatch", packet);
87
89
  switch (packet.t) {
88
- case "READY":
90
+ case constants_1.GatewayEvents.Ready:
89
91
  {
90
92
  this.sessionID = packet.d.session_id;
91
93
  this.client.user = this.client.util.userFromRaw(packet.d.user);
92
94
  this.client.application = packet.d.application;
93
- this.client.emit(constants_1.GatewayEvents.Ready);
95
+ this.client.emit("ready");
94
96
  }
95
97
  break;
96
- case "RESUMED":
97
- this.client.emit(constants_1.GatewayEvents.Resumed);
98
+ case constants_1.GatewayEvents.Resumed:
99
+ this.client.emit("resumed");
98
100
  break;
99
- case "APPLICATION_COMMAND_PERMISSIONS_UPDATE":
100
- this.client.emit(constants_1.GatewayEvents.ApplicationCommandPermissionsUpdate, this.client.util.guildApplicationCommandPermissionsFromRaw(packet.d));
101
+ case constants_1.GatewayEvents.ApplicationCommandPermissionsUpdate:
102
+ this.client.emit("applicationCommandPermissionsUpdate", this.client.util.guildApplicationCommandPermissionsFromRaw(packet.d));
101
103
  break;
102
- case "AUTO_MODERATION_RULE_CREATE":
103
- this.client.emit(constants_1.GatewayEvents.AutoModerationRuleCreate, this.client.util.autoModerationRuleFromRaw(packet.d));
104
+ case constants_1.GatewayEvents.AutoModerationRuleCreate:
105
+ this.client.emit("autoModerationRuleCreate", this.client.util.autoModerationRuleFromRaw(packet.d));
104
106
  break;
105
- case "AUTO_MODERATION_RULE_UPDATE":
106
- this.client.emit(constants_1.GatewayEvents.AutoModerationRuleUpdate, this.client.util.autoModerationRuleFromRaw(packet.d));
107
+ case constants_1.GatewayEvents.AutoModerationRuleUpdate:
108
+ this.client.emit("autoModerationRuleUpdate", this.client.util.autoModerationRuleFromRaw(packet.d));
107
109
  break;
108
- case "AUTO_MODERATION_RULE_DELETE":
109
- this.client.emit(constants_1.GatewayEvents.AutoModerationRuleDelete, this.client.util.autoModerationRuleFromRaw(packet.d));
110
+ case constants_1.GatewayEvents.AutoModerationRuleDelete:
111
+ this.client.emit("autoModerationRuleDelete", this.client.util.autoModerationRuleFromRaw(packet.d));
110
112
  break;
111
- case "AUTO_MODERATION_ACTION_EXECUTION":
112
- this.client.emit(constants_1.GatewayEvents.AutoModerationActionExecution, {
113
+ case constants_1.GatewayEvents.AutoModerationActionExecution:
114
+ this.client.emit("autoModerationActionExecution", {
113
115
  guildID: packet.d.guild_id,
114
116
  action: {
115
117
  type: packet.d.action.type,
@@ -130,41 +132,41 @@ class Shard {
130
132
  matchedContent: packet.d.matched_content,
131
133
  });
132
134
  break;
133
- case "CHANNEL_CREATE":
134
- this.client.emit(constants_1.GatewayEvents.ChannelCreate, this.client.util.channelFromRaw(packet.d));
135
+ case constants_1.GatewayEvents.ChannelCreate:
136
+ this.client.emit("channelCreate", this.client.util.channelFromRaw(packet.d));
135
137
  break;
136
- case "CHANNEL_UPDATE":
137
- this.client.emit(constants_1.GatewayEvents.ChannelUpdate, this.client.util.channelFromRaw(packet.d));
138
+ case constants_1.GatewayEvents.ChannelUpdate:
139
+ this.client.emit("channelUpdate", this.client.util.channelFromRaw(packet.d));
138
140
  break;
139
- case "CHANNEL_DELETE":
140
- this.client.emit(constants_1.GatewayEvents.ChannelDelete, this.client.util.channelFromRaw(packet.d));
141
+ case constants_1.GatewayEvents.ChannelDelete:
142
+ this.client.emit("channelDelete", this.client.util.channelFromRaw(packet.d));
141
143
  break;
142
- case "CHANNEL_PINS_UPDATE":
143
- this.client.emit(constants_1.GatewayEvents.ChannelPinsUpdate, {
144
+ case constants_1.GatewayEvents.ChannelPinsUpdate:
145
+ this.client.emit("channelPinsUpdate", {
144
146
  guildID: packet.d.guild_id,
145
147
  channelID: packet.d.channel_id,
146
148
  lastPinTimestamp: packet.d.last_pin_timestamp,
147
149
  });
148
150
  break;
149
- case "THREAD_CREATE":
150
- this.client.emit(constants_1.GatewayEvents.ThreadCreate, this.client.util.channelFromRaw(packet.d));
151
+ case constants_1.GatewayEvents.ThreadCreate:
152
+ this.client.emit("threadCreate", this.client.util.channelFromRaw(packet.d));
151
153
  break;
152
- case "THREAD_UPDATE":
153
- this.client.emit(constants_1.GatewayEvents.ThreadUpdate, this.client.util.channelFromRaw(packet.d));
154
+ case constants_1.GatewayEvents.ThreadUpdate:
155
+ this.client.emit("threadUpdate", this.client.util.channelFromRaw(packet.d));
154
156
  break;
155
- case "THREAD_DELETE":
156
- this.client.emit(constants_1.GatewayEvents.ThreadDelete, this.client.util.channelFromRaw(packet.d));
157
+ case constants_1.GatewayEvents.ThreadDelete:
158
+ this.client.emit("threadDelete", this.client.util.channelFromRaw(packet.d));
157
159
  break;
158
- case "THREAD_LIST_SYNC":
159
- this.client.emit(constants_1.GatewayEvents.ThreadListSync, {
160
+ case constants_1.GatewayEvents.ThreadListSync:
161
+ this.client.emit("threadListSync", {
160
162
  guildID: packet.d.guild_id,
161
163
  channelIDs: packet.d.channel_ids,
162
164
  threads: packet.d.threads.map((thread) => this.client.util.channelFromRaw(thread)),
163
165
  members: packet.d.members.map((threadMember) => this.client.util.threadMemberFromRaw(threadMember)),
164
166
  });
165
167
  break;
166
- case "THREAD_MEMBER_UPDATE":
167
- this.client.emit(constants_1.GatewayEvents.ThreadMemberUpdate, {
168
+ case constants_1.GatewayEvents.ThreadMemberUpdate:
169
+ this.client.emit("threadMemberUpdate", {
168
170
  id: packet.d.id,
169
171
  userID: packet.d.user_id,
170
172
  joinTimestamp: packet.d.join_timestamp,
@@ -175,8 +177,8 @@ class Shard {
175
177
  guildID: packet.d.guild_id,
176
178
  });
177
179
  break;
178
- case "THREAD_MEMBERS_UPDATE":
179
- this.client.emit(constants_1.GatewayEvents.ThreadMembersUpdate, {
180
+ case constants_1.GatewayEvents.ThreadMembersUpdate:
181
+ this.client.emit("threadMembersUpdate", {
180
182
  id: packet.d.id,
181
183
  guildID: packet.d.guild_id,
182
184
  memberCount: packet.d.member_count,
@@ -184,79 +186,79 @@ class Shard {
184
186
  removedMemberIDs: packet.d.removed_member_ids,
185
187
  });
186
188
  break;
187
- case "ENTITLEMENT_CREATE":
188
- this.client.emit(constants_1.GatewayEvents.EntitlementCreate, this.client.util.entitlementFromRaw(packet.d));
189
+ case constants_1.GatewayEvents.EntitlementCreate:
190
+ this.client.emit("entitlementCreate", this.client.util.entitlementFromRaw(packet.d));
189
191
  break;
190
- case "ENTITLEMENT_UPDATE":
191
- this.client.emit(constants_1.GatewayEvents.EntitlementUpdate, this.client.util.entitlementFromRaw(packet.d));
192
+ case constants_1.GatewayEvents.EntitlementUpdate:
193
+ this.client.emit("entitlementUpdate", this.client.util.entitlementFromRaw(packet.d));
192
194
  break;
193
- case "ENTITLEMENT_DELETE":
194
- this.client.emit(constants_1.GatewayEvents.EntitlementDelete, this.client.util.entitlementFromRaw(packet.d));
195
+ case constants_1.GatewayEvents.EntitlementDelete:
196
+ this.client.emit("entitlementDelete", this.client.util.entitlementFromRaw(packet.d));
195
197
  break;
196
- case "GUILD_CREATE":
198
+ case constants_1.GatewayEvents.GuildCreate:
197
199
  {
198
200
  this.client.guildShardMap[packet.d.id] = this.id;
199
201
  this.client.guilds.set(packet.d.id, this.client.util.guildFromRaw(packet.d));
200
- this.client.emit(constants_1.GatewayEvents.GuildCreate, this.client.util.guildFromRaw(packet.d));
202
+ this.client.emit("guildCreate", this.client.util.guildFromRaw(packet.d));
201
203
  }
202
204
  break;
203
- case "GUILD_UPDATE":
205
+ case constants_1.GatewayEvents.GuildUpdate:
204
206
  {
205
207
  this.client.guilds.set(packet.d.id, this.client.util.guildFromRaw(packet.d));
206
- this.client.emit(constants_1.GatewayEvents.GuildUpdate, this.client.util.guildFromRaw(packet.d));
208
+ this.client.emit("guildUpdate", this.client.util.guildFromRaw(packet.d));
207
209
  }
208
210
  break;
209
- case "GUILD_DELETE":
211
+ case constants_1.GatewayEvents.GuildDelete:
210
212
  {
211
213
  delete this.client.guildShardMap[packet.d.id];
212
214
  this.client.guilds.delete(packet.d.id);
213
- this.client.emit(constants_1.GatewayEvents.GuildDelete, {
215
+ this.client.emit("guildDelete", {
214
216
  id: packet.d.id,
215
217
  unavailable: packet.d.unavailable,
216
218
  });
217
219
  }
218
220
  break;
219
- case "GUILD_AUDIT_LOG_ENTRY_CREATE":
220
- this.client.emit(constants_1.GatewayEvents.GuildAuditLogEntryCreate, {
221
+ case constants_1.GatewayEvents.GuildAuditLogEntryCreate:
222
+ this.client.emit("guildAuditLogEntryCreate", {
221
223
  ...this.client.util.auditLogEntryFromRaw(packet.d),
222
224
  guildID: packet.d.guild_id,
223
225
  });
224
226
  break;
225
- case "GUILD_BAN_ADD":
226
- this.client.emit(constants_1.GatewayEvents.GuildBanAdd, {
227
+ case constants_1.GatewayEvents.GuildBanAdd:
228
+ this.client.emit("guildBanAdd", {
227
229
  guildID: packet.d.guild_id,
228
230
  user: this.client.util.userFromRaw(packet.d.user),
229
231
  });
230
232
  break;
231
- case "GUILD_BAN_REMOVE":
232
- this.client.emit(constants_1.GatewayEvents.GuildBanRemove, {
233
+ case constants_1.GatewayEvents.GuildBanRemove:
234
+ this.client.emit("guildBanRemove", {
233
235
  guildID: packet.d.guild_id,
234
236
  user: this.client.util.userFromRaw(packet.d.user),
235
237
  });
236
238
  break;
237
- case "GUILD_EMOJIS_UPDATE":
238
- this.client.emit(constants_1.GatewayEvents.GuildEmojisUpdate, packet.d.emojis.map((emoji) => this.client.util.emojiFromRaw(emoji)), packet.d.guild_id);
239
+ case constants_1.GatewayEvents.GuildEmojisUpdate:
240
+ this.client.emit("guildEmojisUpdate", packet.d.emojis.map((emoji) => this.client.util.emojiFromRaw(emoji)), packet.d.guild_id);
239
241
  break;
240
- case "GUILD_STICKERS_UPDATE":
241
- this.client.emit(constants_1.GatewayEvents.GuildStickersUpdate, packet.d.stickers.map((sticker) => this.client.util.stickerFromRaw(sticker)), packet.d.guild_id);
242
+ case constants_1.GatewayEvents.GuildStickersUpdate:
243
+ this.client.emit("guildStickersUpdate", packet.d.stickers.map((sticker) => this.client.util.stickerFromRaw(sticker)), packet.d.guild_id);
242
244
  break;
243
- case "GUILD_INTEGRATIONS_UPDATE":
244
- this.client.emit(constants_1.GatewayEvents.GuildIntegrationsUpdate, packet.d.guild_id);
245
+ case constants_1.GatewayEvents.GuildIntegrationsUpdate:
246
+ this.client.emit("guildIntegrationsUpdate", packet.d.guild_id);
245
247
  break;
246
- case "GUILD_MEMBER_ADD":
247
- this.client.emit(constants_1.GatewayEvents.GuildMemberAdd, {
248
+ case constants_1.GatewayEvents.GuildMemberAdd:
249
+ this.client.emit("guildMemberAdd", {
248
250
  ...this.client.util.guildMemberFromRaw(packet.d),
249
251
  guildID: packet.d.guild_id,
250
252
  });
251
253
  break;
252
- case "GUILD_MEMBER_REMOVE":
253
- this.client.emit(constants_1.GatewayEvents.GuildMemberRemove, {
254
+ case constants_1.GatewayEvents.GuildMemberRemove:
255
+ this.client.emit("guildMemberRemove", {
254
256
  guildID: packet.d.guild_id,
255
257
  user: this.client.util.userFromRaw(packet.d.user),
256
258
  });
257
259
  break;
258
- case "GUILD_MEMBER_UPDATE":
259
- this.client.emit(constants_1.GatewayEvents.GuildMemberUpdate, {
260
+ case constants_1.GatewayEvents.GuildMemberUpdate:
261
+ this.client.emit("guildMemberUpdate", {
260
262
  guildID: packet.d.guild_id,
261
263
  roles: packet.d.roles,
262
264
  user: this.client.util.userFromRaw(packet.d.user),
@@ -277,8 +279,8 @@ class Shard {
277
279
  : undefined,
278
280
  });
279
281
  break;
280
- case "GUILD_MEMBERS_CHUNK":
281
- this.client.emit(constants_1.GatewayEvents.GuildMembersChunk, {
282
+ case constants_1.GatewayEvents.GuildMembersChunk:
283
+ this.client.emit("guildMembersChunk", {
282
284
  guildID: packet.d.guild_id,
283
285
  members: packet.d.members.map((guildMember) => this.client.util.guildMemberFromRaw(guildMember)),
284
286
  chunkIndex: packet.d.chunk_index,
@@ -288,54 +290,54 @@ class Shard {
288
290
  nonce: packet.d.nonce,
289
291
  });
290
292
  break;
291
- case "GUILD_ROLE_CREATE":
292
- this.client.emit(constants_1.GatewayEvents.GuildRoleCreate, this.client.util.roleFromRaw(packet.d.role), packet.d.guild_id);
293
+ case constants_1.GatewayEvents.GuildRoleCreate:
294
+ this.client.emit("guildRoleCreate", this.client.util.roleFromRaw(packet.d.role), packet.d.guild_id);
293
295
  break;
294
- case "GUILD_ROLE_UPDATE":
295
- this.client.emit(constants_1.GatewayEvents.GuildRoleUpdate, this.client.util.roleFromRaw(packet.d.role), packet.d.guild_id);
296
+ case constants_1.GatewayEvents.GuildRoleUpdate:
297
+ this.client.emit("guildRoleUpdate", this.client.util.roleFromRaw(packet.d.role), packet.d.guild_id);
296
298
  break;
297
- case "GUILD_ROLE_DELETE":
298
- this.client.emit(constants_1.GatewayEvents.GuildRoleDelete, packet.d.role_id, packet.d.guild_id);
299
+ case constants_1.GatewayEvents.GuildRoleDelete:
300
+ this.client.emit("guildRoleDelete", packet.d.role_id, packet.d.guild_id);
299
301
  break;
300
- case "GUILD_SCHEDULED_EVENT_CREATE":
301
- this.client.emit(constants_1.GatewayEvents.GuildScheduledEventCreate, this.client.util.guildScheduledEventFromRaw(packet.d));
302
+ case constants_1.GatewayEvents.GuildScheduledEventCreate:
303
+ this.client.emit("guildScheduledEventCreate", this.client.util.guildScheduledEventFromRaw(packet.d));
302
304
  break;
303
- case "GUILD_SCHEDULED_EVENT_UPDATE":
304
- this.client.emit(constants_1.GatewayEvents.GuildScheduledEventUpdate, this.client.util.guildScheduledEventFromRaw(packet.d));
305
+ case constants_1.GatewayEvents.GuildScheduledEventUpdate:
306
+ this.client.emit("guildScheduledEventUpdate", this.client.util.guildScheduledEventFromRaw(packet.d));
305
307
  break;
306
- case "GUILD_SCHEDULED_EVENT_DELETE":
307
- this.client.emit(constants_1.GatewayEvents.GuildScheduledEventDelete, this.client.util.guildScheduledEventFromRaw(packet.d));
308
+ case constants_1.GatewayEvents.GuildScheduledEventDelete:
309
+ this.client.emit("guildScheduledEventDelete", this.client.util.guildScheduledEventFromRaw(packet.d));
308
310
  break;
309
- case "GUILD_SCHEDULED_EVENT_USER_ADD":
310
- this.client.emit(constants_1.GatewayEvents.GuildScheduledEventUserAdd, packet.d.user_id, packet.d.guild_scheduled_event_id, packet.d.guild_id);
311
+ case constants_1.GatewayEvents.GuildScheduledEventUserAdd:
312
+ this.client.emit("guildScheduledEventUserAdd", packet.d.user_id, packet.d.guild_scheduled_event_id, packet.d.guild_id);
311
313
  break;
312
- case "GUILD_SCHEDULED_EVENT_USER_REMOVE":
313
- this.client.emit(constants_1.GatewayEvents.GuildScheduledEventUserRemove, packet.d.user_id, packet.d.guild_scheduled_event_id, packet.d.guild_id);
314
+ case constants_1.GatewayEvents.GuildScheduledEventUserRemove:
315
+ this.client.emit("guildScheduledEventUserRemove", packet.d.user_id, packet.d.guild_scheduled_event_id, packet.d.guild_id);
314
316
  break;
315
- case "INTEGRATION_CREATE":
316
- this.client.emit(constants_1.GatewayEvents.IntegrationCreate, {
317
+ case constants_1.GatewayEvents.IntegrationCreate:
318
+ this.client.emit("integrationCreate", {
317
319
  ...this.client.util.integrationFromRaw(packet.d),
318
320
  guildID: packet.d.guild_id,
319
321
  });
320
322
  break;
321
- case "INTEGRATION_UPDATE":
322
- this.client.emit(constants_1.GatewayEvents.IntegrationUpdate, {
323
+ case constants_1.GatewayEvents.IntegrationUpdate:
324
+ this.client.emit("integrationUpdate", {
323
325
  ...this.client.util.integrationFromRaw(packet.d),
324
326
  guildID: packet.d.guild_id,
325
327
  });
326
328
  break;
327
- case "INTEGRATION_DELETE":
328
- this.client.emit(constants_1.GatewayEvents.IntegrationDelete, {
329
+ case constants_1.GatewayEvents.IntegrationDelete:
330
+ this.client.emit("integrationDelete", {
329
331
  id: packet.d.id,
330
332
  guildID: packet.d.guild_id,
331
333
  applicationID: packet.d.application_id,
332
334
  });
333
335
  break;
334
- case "INTERACTION_CREATE":
335
- this.client.emit(constants_1.GatewayEvents.InteractionCreate, this.client.util.interactionFromRaw(packet.d));
336
+ case constants_1.GatewayEvents.InteractionCreate:
337
+ this.client.emit("interactionCreate", this.client.util.interactionFromRaw(packet.d));
336
338
  break;
337
- case "INVITE_CREATE":
338
- this.client.emit(constants_1.GatewayEvents.InviteCreate, {
339
+ case constants_1.GatewayEvents.InviteCreate:
340
+ this.client.emit("inviteCreate", {
339
341
  channelID: packet.d.channel_id,
340
342
  code: packet.d.code,
341
343
  createdAt: packet.d.created_at,
@@ -356,15 +358,15 @@ class Shard {
356
358
  uses: packet.d.uses,
357
359
  });
358
360
  break;
359
- case "INVITE_DELETE":
360
- this.client.emit(constants_1.GatewayEvents.InviteDelete, {
361
+ case constants_1.GatewayEvents.InviteDelete:
362
+ this.client.emit("inviteDelete", {
361
363
  channelID: packet.d.channel_id,
362
364
  guildID: packet.d.guild_id,
363
365
  code: packet.d.code,
364
366
  });
365
367
  break;
366
- case "MESSAGE_CREATE":
367
- this.client.emit(constants_1.GatewayEvents.MessageCreate, {
368
+ case constants_1.GatewayEvents.MessageCreate:
369
+ this.client.emit("messageCreate", {
368
370
  ...this.client.util.messageFromRaw(packet.d),
369
371
  guildID: packet.d.guild_id,
370
372
  member: packet.d.member !== undefined
@@ -373,25 +375,25 @@ class Shard {
373
375
  mentions: packet.d.mentions.map((mention) => this.client.util.userFromRaw(mention)),
374
376
  });
375
377
  break;
376
- case "MESSAGE_UPDATE":
377
- this.client.emit(constants_1.GatewayEvents.MessageUpdate, this.client.util.messageFromRaw(packet.d));
378
+ case constants_1.GatewayEvents.MessageUpdate:
379
+ this.client.emit("messageUpdate", this.client.util.messageFromRaw(packet.d));
378
380
  break;
379
- case "MESSAGE_DELETE":
380
- this.client.emit(constants_1.GatewayEvents.MessageDelete, {
381
+ case constants_1.GatewayEvents.MessageDelete:
382
+ this.client.emit("messageDelete", {
381
383
  id: packet.d.id,
382
384
  channelID: packet.d.channel_id,
383
385
  guildID: packet.d.guild_id,
384
386
  });
385
387
  break;
386
- case "MESSAGE_DELETE_BULK":
387
- this.client.emit(constants_1.GatewayEvents.MessageDeleteBulk, {
388
+ case constants_1.GatewayEvents.MessageDeleteBulk:
389
+ this.client.emit("messageDeleteBulk", {
388
390
  ids: packet.d.ids,
389
391
  channelID: packet.d.channel_id,
390
392
  guildID: packet.d.guild_id,
391
393
  });
392
394
  break;
393
- case "MESSAGE_REACTION_ADD":
394
- this.client.emit(constants_1.GatewayEvents.MessageReactionAdd, {
395
+ case constants_1.GatewayEvents.MessageReactionAdd:
396
+ this.client.emit("messageReactionAdd", {
395
397
  userID: packet.d.user_id,
396
398
  channelID: packet.d.user_id,
397
399
  messageID: packet.d.user_id,
@@ -406,8 +408,8 @@ class Shard {
406
408
  type: packet.d.type,
407
409
  });
408
410
  break;
409
- case "MESSAGE_REACTION_REMOVE":
410
- this.client.emit(constants_1.GatewayEvents.MessageReactionRemove, {
411
+ case constants_1.GatewayEvents.MessageReactionRemove:
412
+ this.client.emit("messageReactionRemove", {
411
413
  userID: packet.d.user_id,
412
414
  channelID: packet.d.user_id,
413
415
  messageID: packet.d.user_id,
@@ -417,35 +419,35 @@ class Shard {
417
419
  type: packet.d.type,
418
420
  });
419
421
  break;
420
- case "MESSAGE_REACTION_REMOVE_ALL":
421
- this.client.emit(constants_1.GatewayEvents.MessageReactionRemoveAll, {
422
+ case constants_1.GatewayEvents.MessageReactionRemoveAll:
423
+ this.client.emit("messageReactionRemoveAll", {
422
424
  channelID: packet.d.channel_id,
423
425
  messageID: packet.d.message_id,
424
426
  guildID: packet.d.guild_id,
425
427
  });
426
428
  break;
427
- case "MESSAGE_REACTION_REMOVE_EMOJI":
428
- this.client.emit(constants_1.GatewayEvents.MessageReactionRemoveEmoji, {
429
+ case constants_1.GatewayEvents.MessageReactionRemoveEmoji:
430
+ this.client.emit("messageReactionRemoveEmoji", {
429
431
  channelID: packet.d.channel_id,
430
432
  guildID: packet.d.guild_id,
431
433
  messageID: packet.d.message_id,
432
434
  emoji: this.client.util.emojiFromRaw(packet.d.emoji),
433
435
  });
434
436
  break;
435
- case "PRESENCE_UPDATE":
436
- this.client.emit(constants_1.GatewayEvents.PresenceUpdate, this.client.util.presenceFromRaw(packet.d));
437
+ case constants_1.GatewayEvents.PresenceUpdate:
438
+ this.client.emit("presenceUpdate", this.client.util.presenceFromRaw(packet.d));
437
439
  break;
438
- case "STAGE_INSTANCE_CREATE":
439
- this.client.emit(constants_1.GatewayEvents.StageInstanceCreate, this.client.util.stageInstanceFromRaw(packet.d));
440
+ case constants_1.GatewayEvents.StageInstanceCreate:
441
+ this.client.emit("stageInstanceCreate", this.client.util.stageInstanceFromRaw(packet.d));
440
442
  break;
441
- case "STAGE_INSTANCE_UPDATE":
442
- this.client.emit(constants_1.GatewayEvents.StageInstanceUpdate, this.client.util.stageInstanceFromRaw(packet.d));
443
+ case constants_1.GatewayEvents.StageInstanceUpdate:
444
+ this.client.emit("stageInstanceUpdate", this.client.util.stageInstanceFromRaw(packet.d));
443
445
  break;
444
- case "STAGE_INSTANCE_DELETE":
445
- this.client.emit(constants_1.GatewayEvents.StageInstanceDelete, this.client.util.stageInstanceFromRaw(packet.d));
446
+ case constants_1.GatewayEvents.StageInstanceDelete:
447
+ this.client.emit("stageInstanceDelete", this.client.util.stageInstanceFromRaw(packet.d));
446
448
  break;
447
- case "TYPING_START":
448
- this.client.emit(constants_1.GatewayEvents.TypingStart, {
449
+ case constants_1.GatewayEvents.TypingStart:
450
+ this.client.emit("typingStart", {
449
451
  channelID: packet.d.channel_id,
450
452
  guildID: packet.d.guild_id,
451
453
  userID: packet.d.user_id,
@@ -455,32 +457,26 @@ class Shard {
455
457
  : undefined,
456
458
  });
457
459
  break;
458
- case "USER_UPDATE":
459
- this.client.emit(constants_1.GatewayEvents.UserUpdate, this.client.util.userFromRaw(packet.d));
460
+ case constants_1.GatewayEvents.UserUpdate:
461
+ this.client.emit("userUpdate", this.client.util.userFromRaw(packet.d));
460
462
  break;
461
- case "VOICE_STATE_UPDATE":
462
- this.client.emit(constants_1.GatewayEvents.VoiceStateUpdate, this.client.util.voiceStateFromRaw(packet.d));
463
+ case constants_1.GatewayEvents.VoiceStateUpdate:
464
+ this.client.emit("voiceStateUpdate", this.client.util.voiceStateFromRaw(packet.d));
463
465
  break;
464
- case "VOICE_SERVER_UPDATE":
466
+ case constants_1.GatewayEvents.VoiceServerUpdate:
465
467
  {
466
- this.client.voiceConnections.connect(packet.d.endpoint, {
467
- serverID: packet.d.guild_id,
468
- userID: this.client.user.id,
469
- sessionID: this.sessionID,
470
- token: packet.d.token,
471
- });
472
- this.client.emit(constants_1.GatewayEvents.VoiceServerUpdate, {
468
+ this.client.emit("voiceServerUpdate", {
473
469
  token: packet.d.token,
474
470
  guildID: packet.d.guild_id,
475
471
  endpoint: packet.d.endpoint,
476
472
  });
477
473
  }
478
474
  break;
479
- case "WEBHOOKS_UPDATE":
480
- this.client.emit(constants_1.GatewayEvents.WebhooksUpdate, packet.d.channel_id, packet.d.guild_id);
475
+ case constants_1.GatewayEvents.WebhooksUpdate:
476
+ this.client.emit("webhooksUpdate", packet.d.channel_id, packet.d.guild_id);
481
477
  break;
482
- case "MESSAGE_POLL_VOTE_ADD":
483
- this.client.emit(constants_1.GatewayEvents.MessagePollVoteAdd, {
478
+ case constants_1.GatewayEvents.MessagePollVoteAdd:
479
+ this.client.emit("messagePollVoteAdd", {
484
480
  userID: packet.d.user_id,
485
481
  channelID: packet.d.channel_id,
486
482
  messageID: packet.d.message_id,
@@ -488,8 +484,8 @@ class Shard {
488
484
  answerID: packet.d.answer_id,
489
485
  });
490
486
  break;
491
- case "MESSAGE_POLL_VOTE_REMOVE":
492
- this.client.emit(constants_1.GatewayEvents.MessagePollVoteRemove, {
487
+ case constants_1.GatewayEvents.MessagePollVoteRemove:
488
+ this.client.emit("messagePollVoteRemove", {
493
489
  userID: packet.d.user_id,
494
490
  channelID: packet.d.channel_id,
495
491
  messageID: packet.d.message_id,
@@ -502,13 +498,32 @@ class Shard {
502
498
  onWebSocketOpen() {
503
499
  this.identify({
504
500
  token: this.client.token,
505
- shard: [this.id, this.client.shardsCount],
506
- intents: this.client.intents,
507
501
  properties: {
508
502
  os: process.platform,
509
503
  browser: pkg.name,
510
504
  device: pkg.name,
511
505
  },
506
+ compress: this.client.compress,
507
+ largeThreshold: this.client.largeThreshold,
508
+ shard: [this.id, this.client.shardsCount],
509
+ presence: this.client.presence !== undefined
510
+ ? {
511
+ since: this.client.presence.status === constants_1.StatusTypes.Idle
512
+ ? Date.now()
513
+ : null,
514
+ activities: this.client.presence.activities?.map((activity) => ({
515
+ name: activity.type === constants_1.ActivityType.Custom
516
+ ? "Custom Status"
517
+ : activity.name,
518
+ type: activity.type,
519
+ url: activity.url,
520
+ state: activity.state,
521
+ })),
522
+ status: this.client.presence.status ?? constants_1.StatusTypes.Online,
523
+ afk: !!this.client.presence.afk,
524
+ }
525
+ : undefined,
526
+ intents: this.client.intents,
512
527
  });
513
528
  }
514
529
  onWebSocketMessage(data) {
@@ -518,15 +533,15 @@ class Shard {
518
533
  this.onDispatch(packet);
519
534
  break;
520
535
  case constants_1.GatewayOPCodes.Reconnect:
521
- this.client.emit(constants_1.GatewayEvents.Reconnect);
536
+ this.client.emit("reconnect");
522
537
  break;
523
538
  case constants_1.GatewayOPCodes.InvalidSession:
524
- this.client.emit(constants_1.GatewayEvents.InvalidSession);
539
+ this.client.emit("invalidSession");
525
540
  break;
526
541
  case constants_1.GatewayOPCodes.Hello:
527
542
  {
528
543
  this.heartbeatInterval = setInterval(() => this.heartbeat(null), packet.d.heartbeat_interval);
529
- this.client.emit(constants_1.GatewayEvents.Hello);
544
+ this.client.emit("hello");
530
545
  }
531
546
  break;
532
547
  }
@@ -537,7 +552,7 @@ class Shard {
537
552
  onWebSocketClose(code, reason) {
538
553
  if (code === 1000)
539
554
  return;
540
- throw new utils_1.GatewayError(`[${code}] ${reason}`);
555
+ throw new utils_1.GatewayError(code, reason.toString());
541
556
  }
542
557
  /** https://discord.com/developers/docs/topics/gateway-events#request-guild-members */
543
558
  requestGuildMembers(options) {
@@ -570,7 +585,14 @@ class Shard {
570
585
  op: constants_1.GatewayOPCodes.PresenceUpdate,
571
586
  d: {
572
587
  since: options.status === constants_1.StatusTypes.Idle ? Date.now() : null,
573
- activities: options.activities,
588
+ activities: options.activities?.map((activity) => ({
589
+ name: activity.type === constants_1.ActivityType.Custom
590
+ ? "Custom Status"
591
+ : activity.name,
592
+ type: activity.type,
593
+ url: activity.url,
594
+ state: activity.state,
595
+ })),
574
596
  status: options.status ?? constants_1.StatusTypes.Online,
575
597
  afk: !!options.afk,
576
598
  },
@@ -26,6 +26,5 @@ export * from "./types/user";
26
26
  export * from "./types/voice";
27
27
  export * from "./types/webhook";
28
28
  export * from "./utils";
29
- export * from "./voice";
30
29
  export * from "./Client";
31
30
  export * from "./constants";
package/dist/lib/index.js CHANGED
@@ -42,6 +42,5 @@ __exportStar(require("./types/user"), exports);
42
42
  __exportStar(require("./types/voice"), exports);
43
43
  __exportStar(require("./types/webhook"), exports);
44
44
  __exportStar(require("./utils"), exports);
45
- __exportStar(require("./voice"), exports);
46
45
  __exportStar(require("./Client"), exports);
47
46
  __exportStar(require("./constants"), exports);
@@ -12,7 +12,7 @@ export interface RequestData {
12
12
  form?: FormData;
13
13
  files?: Array<File> | null;
14
14
  reason?: string;
15
- query?: Partial<Record<string, string | number | boolean | Array<string>>>;
15
+ query?: Record<string, any>;
16
16
  authorization?: boolean;
17
17
  }
18
18
  /** https://discord.com/developers/docs/reference#error-messages */
@@ -106,7 +106,7 @@ class RequestManager {
106
106
  const responseJSON = await response.json();
107
107
  reject(responseJSON.code !== 0
108
108
  ? new utils_1.RESTError(responseJSON.code, responseJSON.message, responseJSON.errors, method, endpoint)
109
- : new utils_1.HTTPError(response.status, response.statusText, method, endpoint));
109
+ : new utils_1.HTTPError(response.status, response.statusText, responseJSON.errors, method, endpoint));
110
110
  }
111
111
  }
112
112
  else if (response.status === constants_1.HTTPResponseCodes.NoContent) {