disgroove 1.1.4-dev.e511a6f → 1.1.5-dev.43fc5a3
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/README.md +2 -6
- package/dist/Client.js +1 -1
- package/dist/Client.js.map +1 -1
- package/dist/client/Client.d.ts +225 -0
- package/dist/client/Client.js +741 -0
- package/dist/client/Client.js.map +1 -0
- package/dist/client/ClientApplication.d.ts +261 -0
- package/dist/client/ClientApplication.js +187 -0
- package/dist/client/ClientApplication.js.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +19 -0
- package/dist/client/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/rest/Endpoints.d.ts +2 -4
- package/dist/rest/Endpoints.js +6 -8
- package/dist/rest/Endpoints.js.map +1 -1
- package/dist/rest/RequestsManager.js +8 -2
- package/dist/rest/RequestsManager.js.map +1 -1
- package/dist/structures/Application.d.ts +2 -3
- package/dist/structures/Application.js +1 -2
- package/dist/structures/Application.js.map +1 -1
- package/dist/structures/ApplicationCommand.d.ts +1 -1
- package/dist/structures/AutoModerationRule.d.ts +2 -2
- package/dist/structures/AutoModerationRule.js +1 -1
- package/dist/structures/AutoModerationRule.js.map +1 -1
- package/dist/structures/Base.d.ts +1 -1
- package/dist/structures/Channel.d.ts +8 -12
- package/dist/structures/Channel.js +11 -19
- package/dist/structures/Channel.js.map +1 -1
- package/dist/structures/Emoji.d.ts +1 -1
- package/dist/structures/Guild.d.ts +24 -24
- package/dist/structures/Guild.js +23 -23
- package/dist/structures/Guild.js.map +1 -1
- package/dist/structures/GuildMember.d.ts +2 -2
- package/dist/structures/GuildMember.js +1 -1
- package/dist/structures/GuildMember.js.map +1 -1
- package/dist/structures/GuildScheduledEvent.d.ts +2 -2
- package/dist/structures/GuildScheduledEvent.js +1 -1
- package/dist/structures/GuildScheduledEvent.js.map +1 -1
- package/dist/structures/GuildTemplate.d.ts +2 -2
- package/dist/structures/GuildTemplate.js +1 -1
- package/dist/structures/GuildTemplate.js.map +1 -1
- package/dist/structures/Integration.d.ts +1 -1
- package/dist/structures/Interaction.d.ts +1 -1
- package/dist/structures/Invite.d.ts +1 -1
- package/dist/structures/Message.d.ts +3 -7
- package/dist/structures/Message.js +5 -13
- package/dist/structures/Message.js.map +1 -1
- package/dist/structures/Role.d.ts +2 -2
- package/dist/structures/Role.js +1 -1
- package/dist/structures/Role.js.map +1 -1
- package/dist/structures/StageInstance.d.ts +2 -2
- package/dist/structures/StageInstance.js +1 -1
- package/dist/structures/StageInstance.js.map +1 -1
- package/dist/structures/Sticker.d.ts +1 -1
- package/dist/structures/Team.d.ts +1 -1
- package/dist/structures/User.d.ts +6 -6
- package/dist/structures/User.js +7 -7
- package/dist/structures/User.js.map +1 -1
- package/dist/structures/VoiceState.d.ts +1 -1
- package/dist/structures/Webhook.d.ts +3 -3
- package/dist/structures/Webhook.js +2 -2
- package/dist/structures/Webhook.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const rest_1 = require("../rest");
|
|
10
|
+
const structures_1 = require("../structures");
|
|
11
|
+
const node_events_1 = __importDefault(require("node:events"));
|
|
12
|
+
const _1 = require(".");
|
|
13
|
+
class Client extends node_events_1.default {
|
|
14
|
+
heartbeatInterval;
|
|
15
|
+
token;
|
|
16
|
+
intents;
|
|
17
|
+
shards;
|
|
18
|
+
auth;
|
|
19
|
+
rest;
|
|
20
|
+
ws;
|
|
21
|
+
user;
|
|
22
|
+
application;
|
|
23
|
+
constructor(token, options) {
|
|
24
|
+
super();
|
|
25
|
+
this.token = token;
|
|
26
|
+
this.intents =
|
|
27
|
+
options?.intents !== undefined
|
|
28
|
+
? Array.isArray(options.intents)
|
|
29
|
+
? options.intents.reduce((sum, num) => sum + num, 0)
|
|
30
|
+
: options.intents
|
|
31
|
+
: utils_1.GatewayIntents.AllNonPrivileged;
|
|
32
|
+
this.shards = options?.shards ?? -1;
|
|
33
|
+
this.auth = options?.auth ?? "Bot";
|
|
34
|
+
this.rest = new rest_1.REST(token, this.auth);
|
|
35
|
+
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json");
|
|
36
|
+
}
|
|
37
|
+
/** https://discord.com/developers/docs/resources/application#get-current-application */
|
|
38
|
+
async getApplication() {
|
|
39
|
+
return new structures_1.Application(await this.rest.get(rest_1.Endpoints.applicationCurrentUser()), this);
|
|
40
|
+
}
|
|
41
|
+
/** https://discord.com/developers/docs/resources/channel#get-channel */
|
|
42
|
+
async getChannel(channelId) {
|
|
43
|
+
return new structures_1.Channel(await this.rest.get(rest_1.Endpoints.channel(channelId)), this);
|
|
44
|
+
}
|
|
45
|
+
/** https://discord.com/developers/docs/resources/guild#create-guild */
|
|
46
|
+
async createGuild(options) {
|
|
47
|
+
return new structures_1.Guild(await this.rest.post(rest_1.Endpoints.guilds(), {
|
|
48
|
+
json: {
|
|
49
|
+
name: options.name,
|
|
50
|
+
region: options.region,
|
|
51
|
+
icon: options.icon,
|
|
52
|
+
verification_level: options.verificationLevel,
|
|
53
|
+
default_message_notifications: options.defaultMessageNotifications,
|
|
54
|
+
explicit_content_filter: options.explicitContentFilter,
|
|
55
|
+
roles: options.roles?.map((role) => (0, utils_1.roleToRaw)(role)),
|
|
56
|
+
channels: options.channels?.map((channel) => (0, utils_1.channelToRaw)(channel)),
|
|
57
|
+
afk_channel_id: options.afkChannelId,
|
|
58
|
+
afk_timeout: options.afkTimeout,
|
|
59
|
+
system_channel_id: options.systemChannelId,
|
|
60
|
+
system_channel_flags: options.systemChannelFlags,
|
|
61
|
+
},
|
|
62
|
+
}), this);
|
|
63
|
+
}
|
|
64
|
+
/** https://discord.com/developers/docs/resources/guild#get-guild */
|
|
65
|
+
async getGuild(guildId, options) {
|
|
66
|
+
return new structures_1.Guild(await this.rest.get(rest_1.Endpoints.guild(guildId), {
|
|
67
|
+
query: {
|
|
68
|
+
with_counts: options?.withCounts,
|
|
69
|
+
},
|
|
70
|
+
}), this);
|
|
71
|
+
}
|
|
72
|
+
/** https://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-template */
|
|
73
|
+
async createGuildFromTemplate(code, options) {
|
|
74
|
+
return new structures_1.Guild(await this.rest.post(rest_1.Endpoints.template(code), {
|
|
75
|
+
json: {
|
|
76
|
+
name: options.name,
|
|
77
|
+
icon: options.icon,
|
|
78
|
+
},
|
|
79
|
+
}), this);
|
|
80
|
+
}
|
|
81
|
+
/** https://discord.com/developers/docs/resources/invite#get-invite */
|
|
82
|
+
async getInvite(code, options) {
|
|
83
|
+
return new structures_1.Invite(await this.rest.get(rest_1.Endpoints.invite(code), {
|
|
84
|
+
query: {
|
|
85
|
+
with_counts: options?.withCounts,
|
|
86
|
+
with_expiration: options?.withExpiration,
|
|
87
|
+
guild_scheduled_event_id: options?.guildScheduledEventId,
|
|
88
|
+
},
|
|
89
|
+
}), this);
|
|
90
|
+
}
|
|
91
|
+
/** https://discord.com/developers/docs/resources/invite#delete-invite */
|
|
92
|
+
async deleteInvite(code, reason) {
|
|
93
|
+
return new structures_1.Invite(await this.rest.delete(rest_1.Endpoints.invite(code), {
|
|
94
|
+
reason,
|
|
95
|
+
}), this).toJSON();
|
|
96
|
+
}
|
|
97
|
+
/** https://discord.com/developers/docs/resources/stage-instance#create-stage-instance */
|
|
98
|
+
async createStageInstance(options, reason) {
|
|
99
|
+
return new structures_1.StageInstance(await this.rest.post(rest_1.Endpoints.stageInstances(), {
|
|
100
|
+
json: {
|
|
101
|
+
channel_id: options.channelId,
|
|
102
|
+
topic: options.topic,
|
|
103
|
+
privacy_level: options.privacyLevel,
|
|
104
|
+
send_start_notifications: options.sendStartNotifications,
|
|
105
|
+
},
|
|
106
|
+
reason,
|
|
107
|
+
}), this);
|
|
108
|
+
}
|
|
109
|
+
/** https://discord.com/developers/docs/resources/stage-instance#get-stage-instance */
|
|
110
|
+
async getStageInstance(channelId) {
|
|
111
|
+
return new structures_1.StageInstance(await this.rest.get(rest_1.Endpoints.stageInstance(channelId)), this);
|
|
112
|
+
}
|
|
113
|
+
/** https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs */
|
|
114
|
+
async getNitroStickerPacks() {
|
|
115
|
+
return this.rest
|
|
116
|
+
.get(rest_1.Endpoints.nitroStickerPacks())
|
|
117
|
+
.then((response) => ({
|
|
118
|
+
stickerPacks: response.sticker_packs.map((stickerPack) => ({
|
|
119
|
+
id: stickerPack.id,
|
|
120
|
+
stickers: stickerPack.stickers.map((sticker) => ({
|
|
121
|
+
id: sticker.id,
|
|
122
|
+
packId: sticker.pack_id,
|
|
123
|
+
name: sticker.name,
|
|
124
|
+
description: sticker.description,
|
|
125
|
+
tags: sticker.tags,
|
|
126
|
+
asset: sticker.asset,
|
|
127
|
+
type: sticker.type,
|
|
128
|
+
formatType: sticker.format_type,
|
|
129
|
+
available: sticker.available,
|
|
130
|
+
guildId: sticker.guild_id,
|
|
131
|
+
user: sticker.user !== undefined
|
|
132
|
+
? new structures_1.User(sticker.user, this)
|
|
133
|
+
: undefined,
|
|
134
|
+
sortValue: sticker.sort_value,
|
|
135
|
+
})),
|
|
136
|
+
name: stickerPack.name,
|
|
137
|
+
skuId: stickerPack.sku_id,
|
|
138
|
+
coverStickerId: stickerPack.cover_sticker_id,
|
|
139
|
+
description: stickerPack.description,
|
|
140
|
+
bannerAssetId: stickerPack.banner_asset_id,
|
|
141
|
+
})),
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
/** https://discord.com/developers/docs/resources/user#get-user */
|
|
145
|
+
async getUser(userId) {
|
|
146
|
+
return new structures_1.User(await this.rest.get(rest_1.Endpoints.user(userId ?? "@me")), this);
|
|
147
|
+
}
|
|
148
|
+
/** https://discord.com/developers/docs/resources/user#get-current-user-guilds */
|
|
149
|
+
async getGuilds(options) {
|
|
150
|
+
return this.rest
|
|
151
|
+
.get(rest_1.Endpoints.userGuilds(), {
|
|
152
|
+
query: {
|
|
153
|
+
before: options?.before,
|
|
154
|
+
after: options?.after,
|
|
155
|
+
limit: options?.limit,
|
|
156
|
+
with_counts: options?.withCounts,
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
.then((response) => response.map((data) => ({
|
|
160
|
+
id: data.id,
|
|
161
|
+
name: data.name,
|
|
162
|
+
icon: data.icon,
|
|
163
|
+
owner: data.owner,
|
|
164
|
+
permissions: data.permissions,
|
|
165
|
+
features: data.features,
|
|
166
|
+
approximate_member_count: data.approximate_member_count,
|
|
167
|
+
approximate_presence_count: data.approximate_presence_count,
|
|
168
|
+
})));
|
|
169
|
+
}
|
|
170
|
+
/** https://discord.com/developers/docs/resources/voice#list-voice-regions */
|
|
171
|
+
async getVoiceRegions() {
|
|
172
|
+
return this.rest
|
|
173
|
+
.get(rest_1.Endpoints.voiceRegions())
|
|
174
|
+
.then((response) => response.map((data) => ({
|
|
175
|
+
id: data.id,
|
|
176
|
+
name: data.name,
|
|
177
|
+
optimal: data.optimal,
|
|
178
|
+
deprecated: data.deprecated,
|
|
179
|
+
custom: data.custom,
|
|
180
|
+
})));
|
|
181
|
+
}
|
|
182
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway */
|
|
183
|
+
async getGateway() {
|
|
184
|
+
return this.rest.get(rest_1.Endpoints.gateway());
|
|
185
|
+
}
|
|
186
|
+
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
|
|
187
|
+
async getGatewayBot() {
|
|
188
|
+
return this.rest
|
|
189
|
+
.get(rest_1.Endpoints.gatewayBot())
|
|
190
|
+
.then((response) => ({
|
|
191
|
+
url: response.url,
|
|
192
|
+
shards: response.shards,
|
|
193
|
+
sessionStartLimit: {
|
|
194
|
+
total: response.session_start_limit.total,
|
|
195
|
+
remaining: response.session_start_limit.remaining,
|
|
196
|
+
resetAfter: response.session_start_limit.reset_after,
|
|
197
|
+
maxConcurrency: response.session_start_limit.max_concurrency,
|
|
198
|
+
},
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
|
202
|
+
updatePresence(options) {
|
|
203
|
+
this.ws.send(JSON.stringify({
|
|
204
|
+
op: utils_1.GatewayOPCodes.PresenceUpdate,
|
|
205
|
+
d: {
|
|
206
|
+
since: options.status === utils_1.StatusTypes.Idle ? Date.now() : null,
|
|
207
|
+
activities: options.activity !== undefined ? [options.activity] : null,
|
|
208
|
+
status: options.status ?? utils_1.StatusTypes.Online,
|
|
209
|
+
afk: !!options.afk,
|
|
210
|
+
},
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
/** https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information */
|
|
214
|
+
async getOAuth2Application() {
|
|
215
|
+
return new structures_1.Application(await this.rest.get(rest_1.Endpoints.oauth2CurrentApplication()), this);
|
|
216
|
+
}
|
|
217
|
+
/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information */
|
|
218
|
+
async getOAuth2Authorization() {
|
|
219
|
+
return this.rest
|
|
220
|
+
.get(rest_1.Endpoints.oauth2Authorization())
|
|
221
|
+
.then((response) => ({
|
|
222
|
+
application: new structures_1.Application(response.application, this),
|
|
223
|
+
scopes: response.scopes,
|
|
224
|
+
expires: response.expires,
|
|
225
|
+
user: response.user !== undefined
|
|
226
|
+
? new structures_1.User(response.user, this)
|
|
227
|
+
: undefined,
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
/** https://discord.com/developers/docs/topics/gateway#connections */
|
|
231
|
+
connect() {
|
|
232
|
+
this.ws.on("open", () => this.onWebSocketOpen());
|
|
233
|
+
this.ws.on("message", (data) => this.onWebSocketMessage(data));
|
|
234
|
+
this.ws.on("error", (err) => this.onWebSocketError(err));
|
|
235
|
+
this.ws.on("close", (code, reason) => this.onWebSocketClose(code, reason));
|
|
236
|
+
}
|
|
237
|
+
disconnect() {
|
|
238
|
+
if (this.heartbeatInterval) {
|
|
239
|
+
clearInterval(this.heartbeatInterval);
|
|
240
|
+
this.heartbeatInterval = null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
async onWebSocketOpen() {
|
|
244
|
+
const gatewayBot = await this.getGatewayBot();
|
|
245
|
+
const shards = this.shards !== -1 ? this.shards : gatewayBot.shards;
|
|
246
|
+
for (let i = 0; i < shards; i++) {
|
|
247
|
+
this.ws.send(JSON.stringify({
|
|
248
|
+
op: utils_1.GatewayOPCodes.Identify,
|
|
249
|
+
d: {
|
|
250
|
+
token: this.token,
|
|
251
|
+
shard: [i, shards],
|
|
252
|
+
intents: this.intents,
|
|
253
|
+
properties: {
|
|
254
|
+
os: process.platform,
|
|
255
|
+
browser: "disgroove",
|
|
256
|
+
device: "disgroove",
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
onWebSocketMessage(data) {
|
|
263
|
+
const packet = JSON.parse(data.toString());
|
|
264
|
+
switch (packet.op) {
|
|
265
|
+
case utils_1.GatewayOPCodes.Reconnect:
|
|
266
|
+
super.emit(utils_1.GatewayEvents.Reconnect);
|
|
267
|
+
break;
|
|
268
|
+
case utils_1.GatewayOPCodes.InvalidSession:
|
|
269
|
+
super.emit(utils_1.GatewayEvents.InvalidSession);
|
|
270
|
+
break;
|
|
271
|
+
case utils_1.GatewayOPCodes.Hello:
|
|
272
|
+
{
|
|
273
|
+
this.heartbeatInterval = setInterval(() => {
|
|
274
|
+
this.ws.send(JSON.stringify({
|
|
275
|
+
op: utils_1.GatewayOPCodes.Heartbeat,
|
|
276
|
+
d: null,
|
|
277
|
+
}));
|
|
278
|
+
}, packet.d.heartbeat_interval);
|
|
279
|
+
super.emit(utils_1.GatewayEvents.Hello, {
|
|
280
|
+
heartbeatInterval: packet.d.heartbeat_interval,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
switch (packet.t) {
|
|
286
|
+
case "READY":
|
|
287
|
+
{
|
|
288
|
+
this.user = new structures_1.User(packet.d.user, this);
|
|
289
|
+
this.application = new _1.ClientApplication(packet.d.application, this);
|
|
290
|
+
super.emit(utils_1.GatewayEvents.Ready);
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
case "RESUMED":
|
|
294
|
+
super.emit(utils_1.GatewayEvents.Resumed);
|
|
295
|
+
break;
|
|
296
|
+
case "APPLICATION_COMMAND_PERMISSIONS_UPDATE":
|
|
297
|
+
super.emit(utils_1.GatewayEvents.ApplicationCommandPermissionsUpdate, {
|
|
298
|
+
id: packet.d.id,
|
|
299
|
+
applicationId: packet.d.application_id,
|
|
300
|
+
guildId: packet.d.guild_id,
|
|
301
|
+
permissions: packet.d.permissions.map((permission) => ({
|
|
302
|
+
id: permission.id,
|
|
303
|
+
type: permission.type,
|
|
304
|
+
permission: permission.permission,
|
|
305
|
+
})),
|
|
306
|
+
});
|
|
307
|
+
break;
|
|
308
|
+
case "AUTO_MODERATION_RULE_CREATE":
|
|
309
|
+
super.emit(utils_1.GatewayEvents.AutoModerationRuleCreate, new structures_1.AutoModerationRule(packet.d, this));
|
|
310
|
+
break;
|
|
311
|
+
case "AUTO_MODERATION_RULE_UPDATE":
|
|
312
|
+
super.emit(utils_1.GatewayEvents.AutoModerationRuleUpdate, new structures_1.AutoModerationRule(packet.d, this));
|
|
313
|
+
break;
|
|
314
|
+
case "AUTO_MODERATION_RULE_DELETE":
|
|
315
|
+
super.emit(utils_1.GatewayEvents.AutoModerationRuleDelete, new structures_1.AutoModerationRule(packet.d, this).toJSON());
|
|
316
|
+
break;
|
|
317
|
+
case "AUTO_MODERATION_ACTION_EXECUTION":
|
|
318
|
+
super.emit(utils_1.GatewayEvents.AutoModerationActionExecution, {
|
|
319
|
+
guildId: packet.d.guild_id,
|
|
320
|
+
action: {
|
|
321
|
+
type: packet.d.action.type,
|
|
322
|
+
metadata: packet.d.action.metadata,
|
|
323
|
+
},
|
|
324
|
+
ruleId: packet.d.rule_id,
|
|
325
|
+
ruleTriggerType: packet.d.rule_trigger_type,
|
|
326
|
+
userId: packet.d.user_id,
|
|
327
|
+
channelId: packet.d.channel_id,
|
|
328
|
+
messageId: packet.d.message_id,
|
|
329
|
+
alertSystemMessageId: packet.d.alert_system_message_id,
|
|
330
|
+
content: packet.d.content,
|
|
331
|
+
matchedKeyword: packet.d.matched_keyword,
|
|
332
|
+
matchedContent: packet.d.matched_content,
|
|
333
|
+
});
|
|
334
|
+
break;
|
|
335
|
+
case "CHANNEL_CREATE":
|
|
336
|
+
super.emit(utils_1.GatewayEvents.ChannelCreate, new structures_1.Channel(packet.d, this));
|
|
337
|
+
break;
|
|
338
|
+
case "CHANNEL_UPDATE":
|
|
339
|
+
super.emit(utils_1.GatewayEvents.ChannelUpdate, new structures_1.Channel(packet.d, this));
|
|
340
|
+
break;
|
|
341
|
+
case "CHANNEL_DELETE":
|
|
342
|
+
super.emit(utils_1.GatewayEvents.ChannelDelete, new structures_1.Channel(packet.d, this).toJSON());
|
|
343
|
+
break;
|
|
344
|
+
case "CHANNEL_PINS_UPDATE":
|
|
345
|
+
super.emit(utils_1.GatewayEvents.ChannelPinsUpdate, {
|
|
346
|
+
guildId: packet.d.guild_id,
|
|
347
|
+
channelId: packet.d.channel_id,
|
|
348
|
+
lastPinTimestamp: packet.d.last_pin_timestamp,
|
|
349
|
+
});
|
|
350
|
+
break;
|
|
351
|
+
case "THREAD_CREATE":
|
|
352
|
+
super.emit(utils_1.GatewayEvents.ThreadCreate, new structures_1.Channel(packet.d, this));
|
|
353
|
+
break;
|
|
354
|
+
case "THREAD_UPDATE":
|
|
355
|
+
super.emit(utils_1.GatewayEvents.ThreadUpdate, new structures_1.Channel(packet.d, this));
|
|
356
|
+
break;
|
|
357
|
+
case "THREAD_DELETE":
|
|
358
|
+
super.emit(utils_1.GatewayEvents.ThreadDelete, new structures_1.Channel(packet.d, this).toJSON());
|
|
359
|
+
break;
|
|
360
|
+
case "THREAD_LIST_SYNC":
|
|
361
|
+
super.emit(utils_1.GatewayEvents.ThreadListSync, {
|
|
362
|
+
guildId: packet.d.guild_id,
|
|
363
|
+
channelIds: packet.d.channel_ids,
|
|
364
|
+
threads: packet.d.threads.map((channel) => new structures_1.Channel(channel, this)),
|
|
365
|
+
members: packet.d.members.map((member) => ({
|
|
366
|
+
id: member.id,
|
|
367
|
+
userId: member.user_id,
|
|
368
|
+
joinTimestamp: member.join_timestamp,
|
|
369
|
+
flags: member.flags,
|
|
370
|
+
member: member.member !== undefined
|
|
371
|
+
? new structures_1.GuildMember(member.member, this)
|
|
372
|
+
: undefined,
|
|
373
|
+
})),
|
|
374
|
+
});
|
|
375
|
+
break;
|
|
376
|
+
case "THREAD_MEMBER_UPDATE":
|
|
377
|
+
super.emit(utils_1.GatewayEvents.ThreadMemberUpdate, {
|
|
378
|
+
id: packet.d.id,
|
|
379
|
+
userId: packet.d.user_id,
|
|
380
|
+
joinTimestamp: packet.d.join_timestamp,
|
|
381
|
+
flags: packet.d.flags,
|
|
382
|
+
member: packet.d.member !== undefined
|
|
383
|
+
? new structures_1.GuildMember(packet.d.member, this)
|
|
384
|
+
: undefined,
|
|
385
|
+
guildId: packet.d.guild_id,
|
|
386
|
+
});
|
|
387
|
+
break;
|
|
388
|
+
case "THREAD_MEMBERS_UPDATE":
|
|
389
|
+
super.emit(utils_1.GatewayEvents.ThreadMembersUpdate, {
|
|
390
|
+
id: packet.d.id,
|
|
391
|
+
guildId: packet.d.guild_id,
|
|
392
|
+
memberCount: packet.d.member_count,
|
|
393
|
+
addedMembers: packet.d.added_members?.map((member) => ({
|
|
394
|
+
id: member.id,
|
|
395
|
+
userId: member.user_id,
|
|
396
|
+
joinTimestamp: member.join_timestamp,
|
|
397
|
+
flags: member.flags,
|
|
398
|
+
member: member.member !== undefined
|
|
399
|
+
? new structures_1.GuildMember(member.member, this)
|
|
400
|
+
: undefined,
|
|
401
|
+
})),
|
|
402
|
+
removedMemberIds: packet.d.removed_member_ids,
|
|
403
|
+
});
|
|
404
|
+
break;
|
|
405
|
+
case "GUILD_CREATE":
|
|
406
|
+
super.emit(utils_1.GatewayEvents.GuildCreate, new structures_1.Guild(packet.d, this));
|
|
407
|
+
break;
|
|
408
|
+
case "GUILD_UPDATE":
|
|
409
|
+
super.emit(utils_1.GatewayEvents.GuildUpdate, new structures_1.Guild(packet.d, this));
|
|
410
|
+
break;
|
|
411
|
+
case "GUILD_DELETE":
|
|
412
|
+
super.emit(utils_1.GatewayEvents.GuildDelete, {
|
|
413
|
+
id: packet.d.id,
|
|
414
|
+
unavailable: packet.d.unavailable,
|
|
415
|
+
});
|
|
416
|
+
break;
|
|
417
|
+
case "GUILD_AUDIT_LOG_ENTRY_CREATE":
|
|
418
|
+
super.emit(utils_1.GatewayEvents.GuildAuditLogEntryCreate, (0, utils_1.auditLogEntryToJSON)(packet.d));
|
|
419
|
+
break;
|
|
420
|
+
case "GUILD_BAN_ADD":
|
|
421
|
+
super.emit(utils_1.GatewayEvents.GuildBanAdd, {
|
|
422
|
+
guildId: packet.d.guild_id,
|
|
423
|
+
user: new structures_1.User(packet.d.user, this),
|
|
424
|
+
});
|
|
425
|
+
break;
|
|
426
|
+
case "GUILD_BAN_REMOVE":
|
|
427
|
+
super.emit(utils_1.GatewayEvents.GuildBanRemove, {
|
|
428
|
+
guildId: packet.d.guild_id,
|
|
429
|
+
user: new structures_1.User(packet.d.user, this),
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
case "GUILD_EMOJIS_UPDATE":
|
|
433
|
+
super.emit(utils_1.GatewayEvents.GuildEmojisUpdate, {
|
|
434
|
+
guildId: packet.d.guild_id,
|
|
435
|
+
emojis: packet.d.emojis.map((emoji) => new structures_1.Emoji(emoji, this).toJSON()),
|
|
436
|
+
});
|
|
437
|
+
break;
|
|
438
|
+
case "GUILD_STICKERS_UPDATE":
|
|
439
|
+
super.emit(utils_1.GatewayEvents.GuildStickersUpdate, {
|
|
440
|
+
guildId: packet.d.guild_id,
|
|
441
|
+
stickers: packet.d.stickers.map((sticker) => ({
|
|
442
|
+
id: sticker.id,
|
|
443
|
+
packId: sticker.pack_id,
|
|
444
|
+
name: sticker.name,
|
|
445
|
+
description: sticker.description,
|
|
446
|
+
tags: sticker.tags,
|
|
447
|
+
asset: sticker.asset,
|
|
448
|
+
type: sticker.type,
|
|
449
|
+
formatType: sticker.format_type,
|
|
450
|
+
available: sticker.available,
|
|
451
|
+
guildId: sticker.guild_id,
|
|
452
|
+
user: sticker.user !== undefined
|
|
453
|
+
? new structures_1.User(sticker.user, this)
|
|
454
|
+
: undefined,
|
|
455
|
+
sortValue: sticker.sort_value,
|
|
456
|
+
})),
|
|
457
|
+
});
|
|
458
|
+
break;
|
|
459
|
+
case "GUILD_INTEGRATIONS_UPDATE":
|
|
460
|
+
super.emit(utils_1.GatewayEvents.GuildIntegrationsUpdate, {
|
|
461
|
+
guildId: packet.d.guild_id,
|
|
462
|
+
});
|
|
463
|
+
break;
|
|
464
|
+
case "GUILD_MEMBER_ADD":
|
|
465
|
+
super.emit(utils_1.GatewayEvents.GuildMemberAdd, new structures_1.GuildMember(packet.d, this));
|
|
466
|
+
break;
|
|
467
|
+
case "GUILD_MEMBER_REMOVE":
|
|
468
|
+
super.emit(utils_1.GatewayEvents.GuildMemberRemove, {
|
|
469
|
+
guildId: packet.d.guild_id,
|
|
470
|
+
user: new structures_1.User(packet.d.user, this),
|
|
471
|
+
});
|
|
472
|
+
break;
|
|
473
|
+
case "GUILD_MEMBER_UPDATE":
|
|
474
|
+
super.emit(utils_1.GatewayEvents.GuildMemberUpdate, {
|
|
475
|
+
guildId: packet.d.guild_id,
|
|
476
|
+
roles: packet.d.roles,
|
|
477
|
+
user: new structures_1.User(packet.d.user, this),
|
|
478
|
+
nick: packet.d.nick,
|
|
479
|
+
avatar: packet.d.avatar,
|
|
480
|
+
joinedAt: packet.d.joined_at,
|
|
481
|
+
premiumSince: packet.d.premium_since,
|
|
482
|
+
deaf: packet.d.deaf,
|
|
483
|
+
mute: packet.d.mute,
|
|
484
|
+
pending: packet.d.pending,
|
|
485
|
+
communicationDisabledUntil: packet.d.communication_disabled_until,
|
|
486
|
+
});
|
|
487
|
+
break;
|
|
488
|
+
case "GUILD_MEMBERS_CHUNK":
|
|
489
|
+
super.emit(utils_1.GatewayEvents.GuildMembersChunk, {
|
|
490
|
+
guildId: packet.d.guild_id,
|
|
491
|
+
members: packet.d.members.map((member) => new structures_1.GuildMember(member, this)),
|
|
492
|
+
chunkIndex: packet.d.chunk_index,
|
|
493
|
+
chunkCount: packet.d.chunk_count,
|
|
494
|
+
notFound: packet.d.not_found,
|
|
495
|
+
presences: packet.d.presences,
|
|
496
|
+
nonce: packet.d.nonce,
|
|
497
|
+
});
|
|
498
|
+
break;
|
|
499
|
+
case "GUILD_ROLE_CREATE":
|
|
500
|
+
super.emit(utils_1.GatewayEvents.GuildRoleCreate, {
|
|
501
|
+
guildId: packet.d.guild_id,
|
|
502
|
+
role: new structures_1.Role(packet.d.role, this),
|
|
503
|
+
});
|
|
504
|
+
break;
|
|
505
|
+
case "GUILD_ROLE_UPDATE":
|
|
506
|
+
super.emit(utils_1.GatewayEvents.GuildRoleUpdate, {
|
|
507
|
+
guildId: packet.d.guild_id,
|
|
508
|
+
role: new structures_1.Role(packet.d.role, this),
|
|
509
|
+
});
|
|
510
|
+
break;
|
|
511
|
+
case "GUILD_ROLE_DELETE":
|
|
512
|
+
super.emit(utils_1.GatewayEvents.GuildRoleDelete, {
|
|
513
|
+
guildId: packet.d.guild_id,
|
|
514
|
+
roleId: packet.d.role_id,
|
|
515
|
+
});
|
|
516
|
+
break;
|
|
517
|
+
case "GUILD_SCHEDULED_EVENT_CREATE":
|
|
518
|
+
super.emit(utils_1.GatewayEvents.GuildScheduledEventCreate, new structures_1.GuildScheduledEvent(packet.d, this));
|
|
519
|
+
break;
|
|
520
|
+
case "GUILD_SCHEDULED_EVENT_UPDATE":
|
|
521
|
+
super.emit(utils_1.GatewayEvents.GuildScheduledEventUpdate, new structures_1.GuildScheduledEvent(packet.d, this));
|
|
522
|
+
break;
|
|
523
|
+
case "GUILD_SCHEDULED_EVENT_DELETE":
|
|
524
|
+
super.emit(utils_1.GatewayEvents.GuildScheduledEventDelete, new structures_1.GuildScheduledEvent(packet.d, this).toJSON());
|
|
525
|
+
break;
|
|
526
|
+
case "GUILD_SCHEDULED_EVENT_USER_ADD":
|
|
527
|
+
super.emit(utils_1.GatewayEvents.GuildScheduledEventUserAdd, {
|
|
528
|
+
guildScheduledEventId: packet.d.guild_scheduled_event_id,
|
|
529
|
+
userId: packet.d.user_id,
|
|
530
|
+
guildId: packet.d.guild_id,
|
|
531
|
+
});
|
|
532
|
+
break;
|
|
533
|
+
case "GUILD_SCHEDULED_EVENT_USER_REMOVE":
|
|
534
|
+
super.emit(utils_1.GatewayEvents.GuildScheduledEventUserRemove, {
|
|
535
|
+
guildScheduledEventId: packet.d.guild_scheduled_event_id,
|
|
536
|
+
userId: packet.d.user_id,
|
|
537
|
+
guildId: packet.d.guild_id,
|
|
538
|
+
});
|
|
539
|
+
break;
|
|
540
|
+
case "INTEGRATION_CREATE":
|
|
541
|
+
super.emit(utils_1.GatewayEvents.IntegrationCreate, new structures_1.Integration(packet.d, this));
|
|
542
|
+
break;
|
|
543
|
+
case "INTEGRATION_UPDATE":
|
|
544
|
+
super.emit(utils_1.GatewayEvents.IntegrationUpdate, new structures_1.Integration(packet.d, this));
|
|
545
|
+
break;
|
|
546
|
+
case "INTEGRATION_DELETE":
|
|
547
|
+
super.emit(utils_1.GatewayEvents.IntegrationDelete, {
|
|
548
|
+
id: packet.d.id,
|
|
549
|
+
guildId: packet.d.guild_id,
|
|
550
|
+
applicationId: packet.d.application_id,
|
|
551
|
+
});
|
|
552
|
+
break;
|
|
553
|
+
case "INTERACTION_CREATE":
|
|
554
|
+
super.emit(utils_1.GatewayEvents.InteractionCreate, new structures_1.Interaction(packet.d, this));
|
|
555
|
+
break;
|
|
556
|
+
case "INVITE_CREATE":
|
|
557
|
+
super.emit(utils_1.GatewayEvents.InviteCreate, {
|
|
558
|
+
channelId: packet.d.channel_id,
|
|
559
|
+
code: packet.d.code,
|
|
560
|
+
createdAt: packet.d.created_at,
|
|
561
|
+
guildId: packet.d.guild_id,
|
|
562
|
+
inviter: packet.d.inviter !== undefined
|
|
563
|
+
? new structures_1.User(packet.d.inviter, this)
|
|
564
|
+
: undefined,
|
|
565
|
+
maxAge: packet.d.max_age,
|
|
566
|
+
maxUses: packet.d.max_uses,
|
|
567
|
+
targetType: packet.d.target_type,
|
|
568
|
+
targetUser: packet.d.target_user !== undefined
|
|
569
|
+
? new structures_1.User(packet.d.target_user, this)
|
|
570
|
+
: undefined,
|
|
571
|
+
targetApplication: packet.d.target_application !== undefined
|
|
572
|
+
? new structures_1.Application(packet.d.target_application, this)
|
|
573
|
+
: undefined,
|
|
574
|
+
temporary: packet.d.temporary,
|
|
575
|
+
uses: packet.d.uses,
|
|
576
|
+
});
|
|
577
|
+
break;
|
|
578
|
+
case "INVITE_DELETE":
|
|
579
|
+
super.emit(utils_1.GatewayEvents.InviteDelete, {
|
|
580
|
+
channelId: packet.d.channel_id,
|
|
581
|
+
guildId: packet.d.guild_id,
|
|
582
|
+
code: packet.d.code,
|
|
583
|
+
});
|
|
584
|
+
break;
|
|
585
|
+
case "MESSAGE_CREATE":
|
|
586
|
+
super.emit(utils_1.GatewayEvents.MessageCreate, new structures_1.Message(packet.d, this));
|
|
587
|
+
break;
|
|
588
|
+
case "MESSAGE_UPDATE":
|
|
589
|
+
super.emit(utils_1.GatewayEvents.MessageUpdate, new structures_1.Message(packet.d, this));
|
|
590
|
+
break;
|
|
591
|
+
case "MESSAGE_DELETE":
|
|
592
|
+
super.emit(utils_1.GatewayEvents.MessageDelete, new structures_1.Message(packet.d, this).toJSON());
|
|
593
|
+
break;
|
|
594
|
+
case "MESSAGE_DELETE_BULK":
|
|
595
|
+
super.emit(utils_1.GatewayEvents.MessageDeleteBulk, {
|
|
596
|
+
ids: packet.d.ids,
|
|
597
|
+
channelId: packet.d.channel_id,
|
|
598
|
+
guildId: packet.d.guild_id,
|
|
599
|
+
});
|
|
600
|
+
break;
|
|
601
|
+
case "MESSAGE_REACTION_ADD":
|
|
602
|
+
super.emit(utils_1.GatewayEvents.MessageReactionAdd, {
|
|
603
|
+
userId: packet.d.user_id,
|
|
604
|
+
channelId: packet.d.channel_id,
|
|
605
|
+
messageId: packet.d.message_id,
|
|
606
|
+
guildId: packet.d.guild_id,
|
|
607
|
+
member: packet.d.member !== undefined
|
|
608
|
+
? new structures_1.GuildMember(packet.d.member, this)
|
|
609
|
+
: undefined,
|
|
610
|
+
emoji: new structures_1.Emoji(packet.d.emoji, this),
|
|
611
|
+
messageAuthorId: packet.d.message_author_id,
|
|
612
|
+
});
|
|
613
|
+
break;
|
|
614
|
+
case "MESSAGE_REACTION_REMOVE":
|
|
615
|
+
super.emit(utils_1.GatewayEvents.MessageReactionRemove, {
|
|
616
|
+
userId: packet.d.user_id,
|
|
617
|
+
channelId: packet.d.channel_id,
|
|
618
|
+
messageId: packet.d.message_id,
|
|
619
|
+
guildId: packet.d.guild_id,
|
|
620
|
+
emoji: new structures_1.Emoji(packet.d.emoji, this),
|
|
621
|
+
});
|
|
622
|
+
break;
|
|
623
|
+
case "MESSAGE_REACTION_REMOVE_ALL":
|
|
624
|
+
super.emit(utils_1.GatewayEvents.MessageReactionRemoveAll, {
|
|
625
|
+
channelId: packet.d.channel_id,
|
|
626
|
+
messageId: packet.d.message_id,
|
|
627
|
+
guildId: packet.d.guild_id,
|
|
628
|
+
});
|
|
629
|
+
break;
|
|
630
|
+
case "MESSAGE_REACTION_REMOVE_EMOJI":
|
|
631
|
+
super.emit(utils_1.GatewayEvents.MessageReactionRemoveEmoji, {
|
|
632
|
+
channelId: packet.d.channel_id,
|
|
633
|
+
guildId: packet.d.guild_id,
|
|
634
|
+
messageId: packet.d.message_id,
|
|
635
|
+
emoji: new structures_1.Emoji(packet.d.emoji, this),
|
|
636
|
+
});
|
|
637
|
+
break;
|
|
638
|
+
case "PRESENCE_UPDATE":
|
|
639
|
+
super.emit(utils_1.GatewayEvents.PresenceUpdate, {
|
|
640
|
+
user: new structures_1.User(packet.d.user, this),
|
|
641
|
+
guildId: packet.d.guild_id,
|
|
642
|
+
status: packet.d.status,
|
|
643
|
+
activities: packet.d.activities.map((activity) => ({
|
|
644
|
+
name: activity.name,
|
|
645
|
+
type: activity.type,
|
|
646
|
+
url: activity.url,
|
|
647
|
+
createdAt: activity.created_at,
|
|
648
|
+
timestamps: {
|
|
649
|
+
start: activity.timestamps?.start,
|
|
650
|
+
end: activity.timestamps?.end,
|
|
651
|
+
},
|
|
652
|
+
applicationId: activity.application_id,
|
|
653
|
+
details: activity.details,
|
|
654
|
+
state: activity.state,
|
|
655
|
+
party: activity.party,
|
|
656
|
+
assets: {
|
|
657
|
+
largeImage: activity.assets?.large_image,
|
|
658
|
+
largeText: activity.assets?.large_text,
|
|
659
|
+
smallImage: activity.assets?.small_image,
|
|
660
|
+
smallText: activity.assets?.small_text,
|
|
661
|
+
},
|
|
662
|
+
secrets: activity.secrets,
|
|
663
|
+
instance: activity.instance,
|
|
664
|
+
flags: activity.flags,
|
|
665
|
+
buttons: activity.buttons,
|
|
666
|
+
})),
|
|
667
|
+
clientStatus: {
|
|
668
|
+
desktop: packet.d.client_status.desktop,
|
|
669
|
+
mobile: packet.d.client_status.mobile,
|
|
670
|
+
web: packet.d.client_status.web,
|
|
671
|
+
},
|
|
672
|
+
});
|
|
673
|
+
break;
|
|
674
|
+
case "STAGE_INSTANCE_CREATE":
|
|
675
|
+
super.emit(utils_1.GatewayEvents.StageInstanceCreate, new structures_1.StageInstance(packet.d, this));
|
|
676
|
+
break;
|
|
677
|
+
case "STAGE_INSTANCE_UPDATE":
|
|
678
|
+
super.emit(utils_1.GatewayEvents.StageInstanceUpdate, new structures_1.StageInstance(packet.d, this));
|
|
679
|
+
break;
|
|
680
|
+
case "STAGE_INSTANCE_DELETE":
|
|
681
|
+
super.emit(utils_1.GatewayEvents.StageInstanceDelete, new structures_1.StageInstance(packet.d, this).toJSON());
|
|
682
|
+
break;
|
|
683
|
+
case "TYPING_START":
|
|
684
|
+
super.emit(utils_1.GatewayEvents.TypingStart, {
|
|
685
|
+
channelId: packet.d.channel_id,
|
|
686
|
+
guildId: packet.d.guild_id,
|
|
687
|
+
userId: packet.d.user_id,
|
|
688
|
+
timestamp: packet.d.timestamp,
|
|
689
|
+
member: packet.d.member !== undefined
|
|
690
|
+
? new structures_1.GuildMember(packet.d.member, this)
|
|
691
|
+
: undefined,
|
|
692
|
+
});
|
|
693
|
+
break;
|
|
694
|
+
case "USER_UPDATE":
|
|
695
|
+
super.emit(utils_1.GatewayEvents.UserUpdate, new structures_1.User(packet.d, this));
|
|
696
|
+
break;
|
|
697
|
+
case "VOICE_STATE_UPDATE":
|
|
698
|
+
super.emit(utils_1.GatewayEvents.VoiceStateUpdate, {
|
|
699
|
+
guildId: packet.d.guild_id,
|
|
700
|
+
channelId: packet.d.channel_id,
|
|
701
|
+
userId: packet.d.user_id,
|
|
702
|
+
member: packet.d.member !== undefined
|
|
703
|
+
? new structures_1.GuildMember(packet.d.member, this)
|
|
704
|
+
: undefined,
|
|
705
|
+
sessionId: packet.d.session_id,
|
|
706
|
+
deaf: packet.d.deaf,
|
|
707
|
+
mute: packet.d.mute,
|
|
708
|
+
selfDeaf: packet.d.self_deaf,
|
|
709
|
+
selfMute: packet.d.self_mute,
|
|
710
|
+
selfStream: packet.d.self_stream,
|
|
711
|
+
selfVideo: packet.d.self_video,
|
|
712
|
+
suppress: packet.d.suppress,
|
|
713
|
+
requestToSpeakTimestamp: packet.d.request_to_speak_timestamp,
|
|
714
|
+
});
|
|
715
|
+
break;
|
|
716
|
+
case "VOICE_SERVER_UPDATE":
|
|
717
|
+
super.emit(utils_1.GatewayEvents.VoiceServerUpdate, {
|
|
718
|
+
token: packet.d.token,
|
|
719
|
+
guildId: packet.d.guild_id,
|
|
720
|
+
endpoint: packet.d.endpoint,
|
|
721
|
+
});
|
|
722
|
+
break;
|
|
723
|
+
case "WEBHOOKS_UPDATE":
|
|
724
|
+
super.emit(utils_1.GatewayEvents.WebhooksUpdate, {
|
|
725
|
+
guildId: packet.d.guild_id,
|
|
726
|
+
channelId: packet.d.channel_id,
|
|
727
|
+
});
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
onWebSocketError(err) {
|
|
732
|
+
throw err;
|
|
733
|
+
}
|
|
734
|
+
onWebSocketClose(code, reason) {
|
|
735
|
+
if (code === 1000)
|
|
736
|
+
return;
|
|
737
|
+
throw new Error(`[${code}] ${reason}`);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
exports.Client = Client;
|
|
741
|
+
//# sourceMappingURL=Client.js.map
|