@fluxerjs/core 1.1.0 → 1.1.1
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/LICENSE +203 -0
- package/dist/{Channel-WJZZSNML.mjs → Channel-4WVFDOCG.mjs} +2 -1
- package/dist/{ClientUser-DJO2FS7P.mjs → ClientUser-PXAAKR2P.mjs} +1 -1
- package/dist/{Guild-2P77HBQM.mjs → Guild-FMBCTAV4.mjs} +2 -1
- package/dist/{MessageReaction-V4UZ7OXE.mjs → MessageReaction-AYSOCOMX.mjs} +2 -1
- package/dist/{chunk-JHNKZIHY.mjs → chunk-4F765HVV.mjs} +2 -2
- package/dist/{chunk-4XJIM6SC.mjs → chunk-FRVZ7D6D.mjs} +6 -28
- package/dist/{chunk-CEABHTAF.mjs → chunk-K6NLD6SB.mjs} +22 -1
- package/dist/{chunk-LU2SNC5G.mjs → chunk-RWFKZ3DF.mjs} +33 -12
- package/dist/chunk-V6T5VMWD.mjs +26 -0
- package/dist/index.js +283 -242
- package/dist/index.mjs +24 -19
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -86,25 +86,12 @@ var init_messageUtils = __esm({
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
// src/
|
|
90
|
-
var
|
|
91
|
-
var
|
|
92
|
-
"src/
|
|
89
|
+
// src/structures/Base.ts
|
|
90
|
+
var Base;
|
|
91
|
+
var init_Base = __esm({
|
|
92
|
+
"src/structures/Base.ts"() {
|
|
93
93
|
"use strict";
|
|
94
|
-
|
|
95
|
-
constructor(client, channelId) {
|
|
96
|
-
this.client = client;
|
|
97
|
-
this.channelId = channelId;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Fetch a message by ID from this channel.
|
|
101
|
-
* @param messageId - Snowflake of the message
|
|
102
|
-
* @returns The message
|
|
103
|
-
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
104
|
-
*/
|
|
105
|
-
async fetch(messageId) {
|
|
106
|
-
return this.client.channels.fetchMessage(this.channelId, messageId);
|
|
107
|
-
}
|
|
94
|
+
Base = class {
|
|
108
95
|
};
|
|
109
96
|
}
|
|
110
97
|
});
|
|
@@ -162,145 +149,20 @@ var init_Events = __esm({
|
|
|
162
149
|
}
|
|
163
150
|
});
|
|
164
151
|
|
|
165
|
-
// src/util/MessageCollector.ts
|
|
166
|
-
var import_events, import_collection, MessageCollector;
|
|
167
|
-
var init_MessageCollector = __esm({
|
|
168
|
-
"src/util/MessageCollector.ts"() {
|
|
169
|
-
"use strict";
|
|
170
|
-
import_events = require("events");
|
|
171
|
-
import_collection = require("@fluxerjs/collection");
|
|
172
|
-
init_Events();
|
|
173
|
-
MessageCollector = class extends import_events.EventEmitter {
|
|
174
|
-
client;
|
|
175
|
-
channelId;
|
|
176
|
-
options;
|
|
177
|
-
collected = new import_collection.Collection();
|
|
178
|
-
_timeout = null;
|
|
179
|
-
_ended = false;
|
|
180
|
-
_listener;
|
|
181
|
-
constructor(client, channelId, options = {}) {
|
|
182
|
-
super();
|
|
183
|
-
this.client = client;
|
|
184
|
-
this.channelId = channelId;
|
|
185
|
-
this.options = {
|
|
186
|
-
filter: options.filter ?? (() => true),
|
|
187
|
-
time: options.time ?? 0,
|
|
188
|
-
max: options.max ?? 0
|
|
189
|
-
};
|
|
190
|
-
this._listener = (message) => {
|
|
191
|
-
if (this._ended || message.channelId !== this.channelId) return;
|
|
192
|
-
if (!this.options.filter(message)) return;
|
|
193
|
-
this.collected.set(message.id, message);
|
|
194
|
-
this.emit("collect", message);
|
|
195
|
-
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
196
|
-
this.stop("limit");
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
this.client.on(Events.MessageCreate, this._listener);
|
|
200
|
-
if (this.options.time > 0) {
|
|
201
|
-
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
stop(reason = "user") {
|
|
205
|
-
if (this._ended) return;
|
|
206
|
-
this._ended = true;
|
|
207
|
-
this.client.off(Events.MessageCreate, this._listener);
|
|
208
|
-
if (this._timeout) {
|
|
209
|
-
clearTimeout(this._timeout);
|
|
210
|
-
this._timeout = null;
|
|
211
|
-
}
|
|
212
|
-
this.emit("end", this.collected, reason);
|
|
213
|
-
}
|
|
214
|
-
on(event, listener) {
|
|
215
|
-
return super.on(event, listener);
|
|
216
|
-
}
|
|
217
|
-
emit(event, ...args) {
|
|
218
|
-
return super.emit(event, ...args);
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// src/structures/Base.ts
|
|
225
|
-
var Base;
|
|
226
|
-
var init_Base = __esm({
|
|
227
|
-
"src/structures/Base.ts"() {
|
|
228
|
-
"use strict";
|
|
229
|
-
Base = class {
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// src/util/Constants.ts
|
|
235
|
-
var CDN_URL;
|
|
236
|
-
var init_Constants = __esm({
|
|
237
|
-
"src/util/Constants.ts"() {
|
|
238
|
-
"use strict";
|
|
239
|
-
CDN_URL = "https://fluxerusercontent.com";
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// src/util/cdn.ts
|
|
244
|
-
function getExtension(hash, options) {
|
|
245
|
-
const ext = options?.extension ?? "png";
|
|
246
|
-
if (hash?.startsWith("a_")) return "gif";
|
|
247
|
-
return ext;
|
|
248
|
-
}
|
|
249
|
-
function appendSize(options) {
|
|
250
|
-
return options?.size ? `?size=${options.size}` : "";
|
|
251
|
-
}
|
|
252
|
-
function cdnAvatarURL(userId, avatarHash, options) {
|
|
253
|
-
if (!avatarHash) return null;
|
|
254
|
-
const ext = getExtension(avatarHash, options);
|
|
255
|
-
const size = appendSize(options);
|
|
256
|
-
return `${CDN_URL}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
257
|
-
}
|
|
258
|
-
function cdnDisplayAvatarURL(userId, avatarHash, options) {
|
|
259
|
-
return cdnAvatarURL(userId, avatarHash, options) ?? `${CDN_URL}/avatars/0/0.png`;
|
|
260
|
-
}
|
|
261
|
-
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
262
|
-
if (!bannerHash) return null;
|
|
263
|
-
const ext = getExtension(bannerHash, options);
|
|
264
|
-
const size = appendSize(options);
|
|
265
|
-
return `${CDN_URL}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
266
|
-
}
|
|
267
|
-
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
268
|
-
if (!avatarHash) return null;
|
|
269
|
-
const ext = getExtension(avatarHash, options);
|
|
270
|
-
const size = appendSize(options);
|
|
271
|
-
return `${CDN_URL}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
272
|
-
}
|
|
273
|
-
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
274
|
-
if (!bannerHash) return null;
|
|
275
|
-
const ext = getExtension(bannerHash, options);
|
|
276
|
-
const size = appendSize(options);
|
|
277
|
-
return `${CDN_URL}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
278
|
-
}
|
|
279
|
-
function cdnDefaultAvatarURL(discriminatorIndex) {
|
|
280
|
-
const index = discriminatorIndex != null ? discriminatorIndex % 5 : 0;
|
|
281
|
-
return `${CDN_URL}/avatars/0/${index}.png`;
|
|
282
|
-
}
|
|
283
|
-
var init_cdn = __esm({
|
|
284
|
-
"src/util/cdn.ts"() {
|
|
285
|
-
"use strict";
|
|
286
|
-
init_Constants();
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
|
|
290
152
|
// src/util/ReactionCollector.ts
|
|
291
|
-
var
|
|
153
|
+
var import_events, import_collection, ReactionCollector;
|
|
292
154
|
var init_ReactionCollector = __esm({
|
|
293
155
|
"src/util/ReactionCollector.ts"() {
|
|
294
156
|
"use strict";
|
|
295
|
-
|
|
296
|
-
|
|
157
|
+
import_events = require("events");
|
|
158
|
+
import_collection = require("@fluxerjs/collection");
|
|
297
159
|
init_Events();
|
|
298
|
-
ReactionCollector = class extends
|
|
160
|
+
ReactionCollector = class extends import_events.EventEmitter {
|
|
299
161
|
client;
|
|
300
162
|
messageId;
|
|
301
163
|
channelId;
|
|
302
164
|
options;
|
|
303
|
-
collected = new
|
|
165
|
+
collected = new import_collection.Collection();
|
|
304
166
|
_timeout = null;
|
|
305
167
|
_ended = false;
|
|
306
168
|
_listener;
|
|
@@ -354,12 +216,12 @@ var Message_exports = {};
|
|
|
354
216
|
__export(Message_exports, {
|
|
355
217
|
Message: () => Message
|
|
356
218
|
});
|
|
357
|
-
var
|
|
219
|
+
var import_collection2, import_types, import_builders2, Message;
|
|
358
220
|
var init_Message = __esm({
|
|
359
221
|
"src/structures/Message.ts"() {
|
|
360
222
|
"use strict";
|
|
361
223
|
init_Base();
|
|
362
|
-
|
|
224
|
+
import_collection2 = require("@fluxerjs/collection");
|
|
363
225
|
import_types = require("@fluxerjs/types");
|
|
364
226
|
import_builders2 = require("@fluxerjs/builders");
|
|
365
227
|
init_messageUtils();
|
|
@@ -414,7 +276,7 @@ var init_Message = __esm({
|
|
|
414
276
|
this.createdAt = new Date(data.timestamp);
|
|
415
277
|
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
416
278
|
this.pinned = data.pinned;
|
|
417
|
-
this.attachments = new
|
|
279
|
+
this.attachments = new import_collection2.Collection();
|
|
418
280
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
|
|
419
281
|
this.type = data.type ?? import_types.MessageType.Default;
|
|
420
282
|
this.flags = data.flags ?? 0;
|
|
@@ -596,17 +458,174 @@ var init_Message = __esm({
|
|
|
596
458
|
}
|
|
597
459
|
});
|
|
598
460
|
|
|
461
|
+
// src/client/MessageManager.ts
|
|
462
|
+
var import_types2, import_rest, MessageManager;
|
|
463
|
+
var init_MessageManager = __esm({
|
|
464
|
+
"src/client/MessageManager.ts"() {
|
|
465
|
+
"use strict";
|
|
466
|
+
import_types2 = require("@fluxerjs/types");
|
|
467
|
+
import_rest = require("@fluxerjs/rest");
|
|
468
|
+
init_FluxerError();
|
|
469
|
+
init_ErrorCodes();
|
|
470
|
+
MessageManager = class {
|
|
471
|
+
constructor(client, channelId) {
|
|
472
|
+
this.client = client;
|
|
473
|
+
this.channelId = channelId;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Fetch a message by ID from this channel.
|
|
477
|
+
* @param messageId - Snowflake of the message
|
|
478
|
+
* @returns The message
|
|
479
|
+
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
480
|
+
*/
|
|
481
|
+
async fetch(messageId) {
|
|
482
|
+
try {
|
|
483
|
+
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
484
|
+
const data = await this.client.rest.get(
|
|
485
|
+
import_types2.Routes.channelMessage(this.channelId, messageId)
|
|
486
|
+
);
|
|
487
|
+
return new Message2(this.client, data);
|
|
488
|
+
} catch (err) {
|
|
489
|
+
if (err instanceof import_rest.RateLimitError) throw err;
|
|
490
|
+
if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
|
|
491
|
+
throw new FluxerError(`Message ${messageId} not found in channel ${this.channelId}`, {
|
|
492
|
+
code: ErrorCodes.MessageNotFound,
|
|
493
|
+
cause: err
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// src/util/MessageCollector.ts
|
|
504
|
+
var import_events2, import_collection3, MessageCollector;
|
|
505
|
+
var init_MessageCollector = __esm({
|
|
506
|
+
"src/util/MessageCollector.ts"() {
|
|
507
|
+
"use strict";
|
|
508
|
+
import_events2 = require("events");
|
|
509
|
+
import_collection3 = require("@fluxerjs/collection");
|
|
510
|
+
init_Events();
|
|
511
|
+
MessageCollector = class extends import_events2.EventEmitter {
|
|
512
|
+
client;
|
|
513
|
+
channelId;
|
|
514
|
+
options;
|
|
515
|
+
collected = new import_collection3.Collection();
|
|
516
|
+
_timeout = null;
|
|
517
|
+
_ended = false;
|
|
518
|
+
_listener;
|
|
519
|
+
constructor(client, channelId, options = {}) {
|
|
520
|
+
super();
|
|
521
|
+
this.client = client;
|
|
522
|
+
this.channelId = channelId;
|
|
523
|
+
this.options = {
|
|
524
|
+
filter: options.filter ?? (() => true),
|
|
525
|
+
time: options.time ?? 0,
|
|
526
|
+
max: options.max ?? 0
|
|
527
|
+
};
|
|
528
|
+
this._listener = (message) => {
|
|
529
|
+
if (this._ended || message.channelId !== this.channelId) return;
|
|
530
|
+
if (!this.options.filter(message)) return;
|
|
531
|
+
this.collected.set(message.id, message);
|
|
532
|
+
this.emit("collect", message);
|
|
533
|
+
if (this.options.max > 0 && this.collected.size >= this.options.max) {
|
|
534
|
+
this.stop("limit");
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
this.client.on(Events.MessageCreate, this._listener);
|
|
538
|
+
if (this.options.time > 0) {
|
|
539
|
+
this._timeout = setTimeout(() => this.stop("time"), this.options.time);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
stop(reason = "user") {
|
|
543
|
+
if (this._ended) return;
|
|
544
|
+
this._ended = true;
|
|
545
|
+
this.client.off(Events.MessageCreate, this._listener);
|
|
546
|
+
if (this._timeout) {
|
|
547
|
+
clearTimeout(this._timeout);
|
|
548
|
+
this._timeout = null;
|
|
549
|
+
}
|
|
550
|
+
this.emit("end", this.collected, reason);
|
|
551
|
+
}
|
|
552
|
+
on(event, listener) {
|
|
553
|
+
return super.on(event, listener);
|
|
554
|
+
}
|
|
555
|
+
emit(event, ...args) {
|
|
556
|
+
return super.emit(event, ...args);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
// src/util/Constants.ts
|
|
563
|
+
var CDN_URL;
|
|
564
|
+
var init_Constants = __esm({
|
|
565
|
+
"src/util/Constants.ts"() {
|
|
566
|
+
"use strict";
|
|
567
|
+
CDN_URL = "https://fluxerusercontent.com";
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// src/util/cdn.ts
|
|
572
|
+
function getExtension(hash, options) {
|
|
573
|
+
const ext = options?.extension ?? "png";
|
|
574
|
+
if (hash?.startsWith("a_")) return "gif";
|
|
575
|
+
return ext;
|
|
576
|
+
}
|
|
577
|
+
function appendSize(options) {
|
|
578
|
+
return options?.size ? `?size=${options.size}` : "";
|
|
579
|
+
}
|
|
580
|
+
function cdnAvatarURL(userId, avatarHash, options) {
|
|
581
|
+
if (!avatarHash) return null;
|
|
582
|
+
const ext = getExtension(avatarHash, options);
|
|
583
|
+
const size = appendSize(options);
|
|
584
|
+
return `${CDN_URL}/avatars/${userId}/${avatarHash}.${ext}${size}`;
|
|
585
|
+
}
|
|
586
|
+
function cdnDisplayAvatarURL(userId, avatarHash, options) {
|
|
587
|
+
return cdnAvatarURL(userId, avatarHash, options) ?? `${CDN_URL}/avatars/0/0.png`;
|
|
588
|
+
}
|
|
589
|
+
function cdnBannerURL(resourceId, bannerHash, options) {
|
|
590
|
+
if (!bannerHash) return null;
|
|
591
|
+
const ext = getExtension(bannerHash, options);
|
|
592
|
+
const size = appendSize(options);
|
|
593
|
+
return `${CDN_URL}/banners/${resourceId}/${bannerHash}.${ext}${size}`;
|
|
594
|
+
}
|
|
595
|
+
function cdnMemberAvatarURL(guildId, userId, avatarHash, options) {
|
|
596
|
+
if (!avatarHash) return null;
|
|
597
|
+
const ext = getExtension(avatarHash, options);
|
|
598
|
+
const size = appendSize(options);
|
|
599
|
+
return `${CDN_URL}/guilds/${guildId}/users/${userId}/avatars/${avatarHash}.${ext}${size}`;
|
|
600
|
+
}
|
|
601
|
+
function cdnMemberBannerURL(guildId, userId, bannerHash, options) {
|
|
602
|
+
if (!bannerHash) return null;
|
|
603
|
+
const ext = getExtension(bannerHash, options);
|
|
604
|
+
const size = appendSize(options);
|
|
605
|
+
return `${CDN_URL}/guilds/${guildId}/users/${userId}/banners/${bannerHash}.${ext}${size}`;
|
|
606
|
+
}
|
|
607
|
+
function cdnDefaultAvatarURL(discriminatorIndex) {
|
|
608
|
+
const index = discriminatorIndex != null ? discriminatorIndex % 5 : 0;
|
|
609
|
+
return `${CDN_URL}/avatars/0/${index}.png`;
|
|
610
|
+
}
|
|
611
|
+
var init_cdn = __esm({
|
|
612
|
+
"src/util/cdn.ts"() {
|
|
613
|
+
"use strict";
|
|
614
|
+
init_Constants();
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
599
618
|
// src/structures/Webhook.ts
|
|
600
619
|
var Webhook_exports = {};
|
|
601
620
|
__export(Webhook_exports, {
|
|
602
621
|
Webhook: () => Webhook
|
|
603
622
|
});
|
|
604
|
-
var
|
|
623
|
+
var import_types3, Webhook;
|
|
605
624
|
var init_Webhook = __esm({
|
|
606
625
|
"src/structures/Webhook.ts"() {
|
|
607
626
|
"use strict";
|
|
608
627
|
init_Base();
|
|
609
|
-
|
|
628
|
+
import_types3 = require("@fluxerjs/types");
|
|
610
629
|
init_messageUtils();
|
|
611
630
|
init_cdn();
|
|
612
631
|
Webhook = class _Webhook extends Base {
|
|
@@ -641,7 +660,7 @@ var init_Webhook = __esm({
|
|
|
641
660
|
}
|
|
642
661
|
/** Delete this webhook. Requires bot token with Manage Webhooks permission. */
|
|
643
662
|
async delete() {
|
|
644
|
-
await this.client.rest.delete(
|
|
663
|
+
await this.client.rest.delete(import_types3.Routes.webhook(this.id), { auth: true });
|
|
645
664
|
}
|
|
646
665
|
/**
|
|
647
666
|
* Edit this webhook. With token: name and avatar only. Without token (bot auth): name, avatar, and channel_id.
|
|
@@ -656,7 +675,7 @@ var init_Webhook = __esm({
|
|
|
656
675
|
body.channel_id = options.channel_id;
|
|
657
676
|
}
|
|
658
677
|
if (this.token) {
|
|
659
|
-
const data2 = await this.client.rest.patch(
|
|
678
|
+
const data2 = await this.client.rest.patch(import_types3.Routes.webhookExecute(this.id, this.token), {
|
|
660
679
|
body,
|
|
661
680
|
auth: false
|
|
662
681
|
});
|
|
@@ -665,7 +684,7 @@ var init_Webhook = __esm({
|
|
|
665
684
|
this.avatar = w2.avatar ?? null;
|
|
666
685
|
return this;
|
|
667
686
|
}
|
|
668
|
-
const data = await this.client.rest.patch(
|
|
687
|
+
const data = await this.client.rest.patch(import_types3.Routes.webhook(this.id), {
|
|
669
688
|
body,
|
|
670
689
|
auth: true
|
|
671
690
|
});
|
|
@@ -697,7 +716,7 @@ var init_Webhook = __esm({
|
|
|
697
716
|
if (opts.username !== void 0) body.username = opts.username;
|
|
698
717
|
if (opts.avatar_url !== void 0) body.avatar_url = opts.avatar_url;
|
|
699
718
|
if (opts.tts !== void 0) body.tts = opts.tts;
|
|
700
|
-
const route =
|
|
719
|
+
const route = import_types3.Routes.webhookExecute(this.id, this.token) + (wait ? "?wait=true" : "");
|
|
701
720
|
const postOptions = opts.files?.length ? { body, files: opts.files, auth: false } : { body, auth: false };
|
|
702
721
|
const data = await this.client.rest.post(
|
|
703
722
|
route,
|
|
@@ -716,7 +735,7 @@ var init_Webhook = __esm({
|
|
|
716
735
|
* @returns Webhook without token (cannot send)
|
|
717
736
|
*/
|
|
718
737
|
static async fetch(client, webhookId) {
|
|
719
|
-
const data = await client.rest.get(
|
|
738
|
+
const data = await client.rest.get(import_types3.Routes.webhook(webhookId));
|
|
720
739
|
return new _Webhook(client, data);
|
|
721
740
|
}
|
|
722
741
|
/**
|
|
@@ -746,12 +765,12 @@ var Invite_exports = {};
|
|
|
746
765
|
__export(Invite_exports, {
|
|
747
766
|
Invite: () => Invite
|
|
748
767
|
});
|
|
749
|
-
var
|
|
768
|
+
var import_types4, Invite;
|
|
750
769
|
var init_Invite = __esm({
|
|
751
770
|
"src/structures/Invite.ts"() {
|
|
752
771
|
"use strict";
|
|
753
772
|
init_Base();
|
|
754
|
-
|
|
773
|
+
import_types4 = require("@fluxerjs/types");
|
|
755
774
|
Invite = class extends Base {
|
|
756
775
|
client;
|
|
757
776
|
code;
|
|
@@ -801,7 +820,7 @@ var init_Invite = __esm({
|
|
|
801
820
|
* Requires Manage Guild or Create Instant Invite permission.
|
|
802
821
|
*/
|
|
803
822
|
async delete() {
|
|
804
|
-
await this.client.rest.delete(
|
|
823
|
+
await this.client.rest.delete(import_types4.Routes.invite(this.code), { auth: true });
|
|
805
824
|
}
|
|
806
825
|
};
|
|
807
826
|
}
|
|
@@ -818,7 +837,7 @@ __export(Channel_exports, {
|
|
|
818
837
|
TextChannel: () => TextChannel,
|
|
819
838
|
VoiceChannel: () => VoiceChannel
|
|
820
839
|
});
|
|
821
|
-
var
|
|
840
|
+
var import_types5, import_util, Channel, GuildChannel, TextChannel, CategoryChannel, VoiceChannel, LinkChannel, DMChannel;
|
|
822
841
|
var init_Channel = __esm({
|
|
823
842
|
"src/structures/Channel.ts"() {
|
|
824
843
|
"use strict";
|
|
@@ -826,7 +845,7 @@ var init_Channel = __esm({
|
|
|
826
845
|
init_MessageCollector();
|
|
827
846
|
init_Base();
|
|
828
847
|
init_messageUtils();
|
|
829
|
-
|
|
848
|
+
import_types5 = require("@fluxerjs/types");
|
|
830
849
|
import_util = require("@fluxerjs/util");
|
|
831
850
|
Channel = class _Channel extends Base {
|
|
832
851
|
/** Whether this channel has a send method (TextChannel, DMChannel). */
|
|
@@ -835,7 +854,7 @@ var init_Channel = __esm({
|
|
|
835
854
|
}
|
|
836
855
|
/** Whether this channel is a DM or Group DM. */
|
|
837
856
|
isDM() {
|
|
838
|
-
return this.type ===
|
|
857
|
+
return this.type === import_types5.ChannelType.DM || this.type === import_types5.ChannelType.GroupDM;
|
|
839
858
|
}
|
|
840
859
|
/** Whether this channel is voice-based (VoiceChannel). */
|
|
841
860
|
isVoice() {
|
|
@@ -871,10 +890,10 @@ var init_Channel = __esm({
|
|
|
871
890
|
*/
|
|
872
891
|
static from(client, data) {
|
|
873
892
|
const type = data.type ?? 0;
|
|
874
|
-
if (type ===
|
|
875
|
-
if (type ===
|
|
876
|
-
if (type ===
|
|
877
|
-
if (type ===
|
|
893
|
+
if (type === import_types5.ChannelType.GuildText) return new TextChannel(client, data);
|
|
894
|
+
if (type === import_types5.ChannelType.GuildCategory) return new CategoryChannel(client, data);
|
|
895
|
+
if (type === import_types5.ChannelType.GuildVoice) return new VoiceChannel(client, data);
|
|
896
|
+
if (type === import_types5.ChannelType.GuildLink || type === import_types5.ChannelType.GuildLinkExtended)
|
|
878
897
|
return new LinkChannel(client, data);
|
|
879
898
|
return new GuildChannel(client, data);
|
|
880
899
|
}
|
|
@@ -884,7 +903,7 @@ var init_Channel = __esm({
|
|
|
884
903
|
*/
|
|
885
904
|
static fromOrCreate(client, data) {
|
|
886
905
|
const type = data.type ?? 0;
|
|
887
|
-
if (type ===
|
|
906
|
+
if (type === import_types5.ChannelType.DM || type === import_types5.ChannelType.GroupDM)
|
|
888
907
|
return _Channel.createDM(client, data);
|
|
889
908
|
return _Channel.from(client, data);
|
|
890
909
|
}
|
|
@@ -893,7 +912,7 @@ var init_Channel = __esm({
|
|
|
893
912
|
* @param messageIds - Array of message IDs to delete (2–100)
|
|
894
913
|
*/
|
|
895
914
|
async bulkDeleteMessages(messageIds) {
|
|
896
|
-
await this.client.rest.post(
|
|
915
|
+
await this.client.rest.post(import_types5.Routes.channelBulkDelete(this.id), {
|
|
897
916
|
body: { message_ids: messageIds },
|
|
898
917
|
auth: true
|
|
899
918
|
});
|
|
@@ -902,7 +921,7 @@ var init_Channel = __esm({
|
|
|
902
921
|
* Send a typing indicator to the channel. Lasts ~10 seconds.
|
|
903
922
|
*/
|
|
904
923
|
async sendTyping() {
|
|
905
|
-
await this.client.rest.post(
|
|
924
|
+
await this.client.rest.post(import_types5.Routes.channelTyping(this.id), { auth: true });
|
|
906
925
|
}
|
|
907
926
|
};
|
|
908
927
|
GuildChannel = class extends Channel {
|
|
@@ -927,7 +946,7 @@ var init_Channel = __esm({
|
|
|
927
946
|
*/
|
|
928
947
|
async createWebhook(options) {
|
|
929
948
|
const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
|
|
930
|
-
const data = await this.client.rest.post(
|
|
949
|
+
const data = await this.client.rest.post(import_types5.Routes.channelWebhooks(this.id), {
|
|
931
950
|
body: options,
|
|
932
951
|
auth: true
|
|
933
952
|
});
|
|
@@ -939,7 +958,7 @@ var init_Channel = __esm({
|
|
|
939
958
|
*/
|
|
940
959
|
async fetchWebhooks() {
|
|
941
960
|
const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
|
|
942
|
-
const data = await this.client.rest.get(
|
|
961
|
+
const data = await this.client.rest.get(import_types5.Routes.channelWebhooks(this.id));
|
|
943
962
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
944
963
|
return list.map((w) => new Webhook2(this.client, w));
|
|
945
964
|
}
|
|
@@ -955,7 +974,7 @@ var init_Channel = __esm({
|
|
|
955
974
|
if (options?.max_age != null) body.max_age = options.max_age;
|
|
956
975
|
if (options?.unique != null) body.unique = options.unique;
|
|
957
976
|
if (options?.temporary != null) body.temporary = options.temporary;
|
|
958
|
-
const data = await this.client.rest.post(
|
|
977
|
+
const data = await this.client.rest.post(import_types5.Routes.channelInvites(this.id), {
|
|
959
978
|
body: Object.keys(body).length ? body : void 0,
|
|
960
979
|
auth: true
|
|
961
980
|
});
|
|
@@ -967,7 +986,7 @@ var init_Channel = __esm({
|
|
|
967
986
|
*/
|
|
968
987
|
async fetchInvites() {
|
|
969
988
|
const { Invite: Invite2 } = await Promise.resolve().then(() => (init_Invite(), Invite_exports));
|
|
970
|
-
const data = await this.client.rest.get(
|
|
989
|
+
const data = await this.client.rest.get(import_types5.Routes.channelInvites(this.id));
|
|
971
990
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
972
991
|
return list.map((i) => new Invite2(this.client, i));
|
|
973
992
|
}
|
|
@@ -993,7 +1012,7 @@ var init_Channel = __esm({
|
|
|
993
1012
|
const body = buildSendBody(options);
|
|
994
1013
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
995
1014
|
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
996
|
-
const data = await this.client.rest.post(
|
|
1015
|
+
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
997
1016
|
return new Message2(this.client, data);
|
|
998
1017
|
}
|
|
999
1018
|
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
@@ -1018,7 +1037,7 @@ var init_Channel = __esm({
|
|
|
1018
1037
|
*/
|
|
1019
1038
|
async fetchPinnedMessages() {
|
|
1020
1039
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
1021
|
-
const data = await this.client.rest.get(
|
|
1040
|
+
const data = await this.client.rest.get(import_types5.Routes.channelPins(this.id));
|
|
1022
1041
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1023
1042
|
return list.map((item) => {
|
|
1024
1043
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1085,7 +1104,7 @@ var init_Channel = __esm({
|
|
|
1085
1104
|
const body = buildSendBody(options);
|
|
1086
1105
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
1087
1106
|
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
1088
|
-
const data = await this.client.rest.post(
|
|
1107
|
+
const data = await this.client.rest.post(import_types5.Routes.channelMessages(this.id), postOptions);
|
|
1089
1108
|
return new Message2(this.client, data);
|
|
1090
1109
|
}
|
|
1091
1110
|
/** Message manager for this channel. Use channel.messages.fetch(messageId). */
|
|
@@ -1105,7 +1124,7 @@ var init_Channel = __esm({
|
|
|
1105
1124
|
*/
|
|
1106
1125
|
async fetchPinnedMessages() {
|
|
1107
1126
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
1108
|
-
const data = await this.client.rest.get(
|
|
1127
|
+
const data = await this.client.rest.get(import_types5.Routes.channelPins(this.id));
|
|
1109
1128
|
const list = Array.isArray(data) ? data : data?.items ?? [];
|
|
1110
1129
|
return list.map((item) => {
|
|
1111
1130
|
const msg = typeof item === "object" && item && "message" in item ? item.message : item;
|
|
@@ -1134,7 +1153,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
1134
1153
|
if (isOwner) return import_util3.ALL_PERMISSIONS_BIGINT;
|
|
1135
1154
|
let perms = basePermissions;
|
|
1136
1155
|
for (const overwrite of overwrites ?? []) {
|
|
1137
|
-
const applies = overwrite.type ===
|
|
1156
|
+
const applies = overwrite.type === import_types7.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types7.OverwriteType.Member && overwrite.id === memberId;
|
|
1138
1157
|
if (!applies) continue;
|
|
1139
1158
|
const allow = BigInt(overwrite.allow || "0");
|
|
1140
1159
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -1147,11 +1166,11 @@ function hasPermission(bitfield, permission) {
|
|
|
1147
1166
|
if ((bitfield & Administrator) !== 0n) return true;
|
|
1148
1167
|
return (bitfield & permission) === permission;
|
|
1149
1168
|
}
|
|
1150
|
-
var
|
|
1169
|
+
var import_types7, import_util3;
|
|
1151
1170
|
var init_permissions = __esm({
|
|
1152
1171
|
"src/util/permissions.ts"() {
|
|
1153
1172
|
"use strict";
|
|
1154
|
-
|
|
1173
|
+
import_types7 = require("@fluxerjs/types");
|
|
1155
1174
|
import_util3 = require("@fluxerjs/util");
|
|
1156
1175
|
}
|
|
1157
1176
|
});
|
|
@@ -1161,13 +1180,13 @@ var GuildMember_exports = {};
|
|
|
1161
1180
|
__export(GuildMember_exports, {
|
|
1162
1181
|
GuildMember: () => GuildMember
|
|
1163
1182
|
});
|
|
1164
|
-
var import_util4,
|
|
1183
|
+
var import_util4, import_types8, GuildMember;
|
|
1165
1184
|
var init_GuildMember = __esm({
|
|
1166
1185
|
"src/structures/GuildMember.ts"() {
|
|
1167
1186
|
"use strict";
|
|
1168
1187
|
init_Base();
|
|
1169
1188
|
import_util4 = require("@fluxerjs/util");
|
|
1170
|
-
|
|
1189
|
+
import_types8 = require("@fluxerjs/types");
|
|
1171
1190
|
init_cdn();
|
|
1172
1191
|
init_permissions();
|
|
1173
1192
|
GuildMember = class extends Base {
|
|
@@ -1234,7 +1253,7 @@ var init_GuildMember = __esm({
|
|
|
1234
1253
|
* Requires Manage Roles permission.
|
|
1235
1254
|
*/
|
|
1236
1255
|
async addRole(roleId) {
|
|
1237
|
-
await this.client.rest.put(
|
|
1256
|
+
await this.client.rest.put(import_types8.Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
1238
1257
|
}
|
|
1239
1258
|
/**
|
|
1240
1259
|
* Remove a role from this member.
|
|
@@ -1242,7 +1261,7 @@ var init_GuildMember = __esm({
|
|
|
1242
1261
|
* Requires Manage Roles permission.
|
|
1243
1262
|
*/
|
|
1244
1263
|
async removeRole(roleId) {
|
|
1245
|
-
await this.client.rest.delete(
|
|
1264
|
+
await this.client.rest.delete(import_types8.Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
1246
1265
|
}
|
|
1247
1266
|
/**
|
|
1248
1267
|
* Get the member's guild-level permissions (from roles only, no channel overwrites).
|
|
@@ -1380,12 +1399,12 @@ var GuildBan_exports = {};
|
|
|
1380
1399
|
__export(GuildBan_exports, {
|
|
1381
1400
|
GuildBan: () => GuildBan
|
|
1382
1401
|
});
|
|
1383
|
-
var
|
|
1402
|
+
var import_types9, GuildBan;
|
|
1384
1403
|
var init_GuildBan = __esm({
|
|
1385
1404
|
"src/structures/GuildBan.ts"() {
|
|
1386
1405
|
"use strict";
|
|
1387
1406
|
init_Base();
|
|
1388
|
-
|
|
1407
|
+
import_types9 = require("@fluxerjs/types");
|
|
1389
1408
|
GuildBan = class extends Base {
|
|
1390
1409
|
client;
|
|
1391
1410
|
guildId;
|
|
@@ -1407,7 +1426,7 @@ var init_GuildBan = __esm({
|
|
|
1407
1426
|
* Requires Ban Members permission.
|
|
1408
1427
|
*/
|
|
1409
1428
|
async unban() {
|
|
1410
|
-
await this.client.rest.delete(
|
|
1429
|
+
await this.client.rest.delete(import_types9.Routes.guildBan(this.guildId, this.user.id), {
|
|
1411
1430
|
auth: true
|
|
1412
1431
|
});
|
|
1413
1432
|
}
|
|
@@ -1420,12 +1439,12 @@ var Guild_exports = {};
|
|
|
1420
1439
|
__export(Guild_exports, {
|
|
1421
1440
|
Guild: () => Guild
|
|
1422
1441
|
});
|
|
1423
|
-
var import_util6,
|
|
1442
|
+
var import_util6, import_rest3, import_collection5, import_types10, Guild;
|
|
1424
1443
|
var init_Guild = __esm({
|
|
1425
1444
|
"src/structures/Guild.ts"() {
|
|
1426
1445
|
"use strict";
|
|
1427
1446
|
import_util6 = require("@fluxerjs/util");
|
|
1428
|
-
|
|
1447
|
+
import_rest3 = require("@fluxerjs/rest");
|
|
1429
1448
|
init_Base();
|
|
1430
1449
|
init_FluxerError();
|
|
1431
1450
|
init_ErrorCodes();
|
|
@@ -1433,7 +1452,7 @@ var init_Guild = __esm({
|
|
|
1433
1452
|
init_GuildMember();
|
|
1434
1453
|
init_Role();
|
|
1435
1454
|
init_Constants();
|
|
1436
|
-
|
|
1455
|
+
import_types10 = require("@fluxerjs/types");
|
|
1437
1456
|
Guild = class extends Base {
|
|
1438
1457
|
client;
|
|
1439
1458
|
id;
|
|
@@ -1525,7 +1544,7 @@ var init_Guild = __esm({
|
|
|
1525
1544
|
* Requires Manage Roles permission.
|
|
1526
1545
|
*/
|
|
1527
1546
|
async addRoleToMember(userId, roleId) {
|
|
1528
|
-
await this.client.rest.put(
|
|
1547
|
+
await this.client.rest.put(import_types10.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1529
1548
|
}
|
|
1530
1549
|
/**
|
|
1531
1550
|
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
@@ -1534,7 +1553,7 @@ var init_Guild = __esm({
|
|
|
1534
1553
|
* Requires Manage Roles permission.
|
|
1535
1554
|
*/
|
|
1536
1555
|
async removeRoleFromMember(userId, roleId) {
|
|
1537
|
-
await this.client.rest.delete(
|
|
1556
|
+
await this.client.rest.delete(import_types10.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1538
1557
|
}
|
|
1539
1558
|
/**
|
|
1540
1559
|
* Resolve a role ID from an argument (role mention, raw ID, or name).
|
|
@@ -1550,7 +1569,7 @@ var init_Guild = __esm({
|
|
|
1550
1569
|
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
1551
1570
|
);
|
|
1552
1571
|
if (cached) return cached.id;
|
|
1553
|
-
const roles = await this.client.rest.get(
|
|
1572
|
+
const roles = await this.client.rest.get(import_types10.Routes.guildRoles(this.id));
|
|
1554
1573
|
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
1555
1574
|
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
1556
1575
|
if (role) {
|
|
@@ -1573,7 +1592,7 @@ var init_Guild = __esm({
|
|
|
1573
1592
|
body.delete_message_days = options.delete_message_days;
|
|
1574
1593
|
if (options?.ban_duration_seconds != null)
|
|
1575
1594
|
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
1576
|
-
await this.client.rest.put(
|
|
1595
|
+
await this.client.rest.put(import_types10.Routes.guildBan(this.id, userId), {
|
|
1577
1596
|
body: Object.keys(body).length ? body : void 0,
|
|
1578
1597
|
auth: true
|
|
1579
1598
|
});
|
|
@@ -1584,7 +1603,7 @@ var init_Guild = __esm({
|
|
|
1584
1603
|
*/
|
|
1585
1604
|
async fetchBans() {
|
|
1586
1605
|
const { GuildBan: GuildBan2 } = await Promise.resolve().then(() => (init_GuildBan(), GuildBan_exports));
|
|
1587
|
-
const data = await this.client.rest.get(
|
|
1606
|
+
const data = await this.client.rest.get(import_types10.Routes.guildBans(this.id));
|
|
1588
1607
|
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
1589
1608
|
return list.map((b) => new GuildBan2(this.client, { ...b, guild_id: this.id }, this.id));
|
|
1590
1609
|
}
|
|
@@ -1594,7 +1613,7 @@ var init_Guild = __esm({
|
|
|
1594
1613
|
* Requires Ban Members permission.
|
|
1595
1614
|
*/
|
|
1596
1615
|
async unban(userId) {
|
|
1597
|
-
await this.client.rest.delete(
|
|
1616
|
+
await this.client.rest.delete(import_types10.Routes.guildBan(this.id, userId), { auth: true });
|
|
1598
1617
|
}
|
|
1599
1618
|
/**
|
|
1600
1619
|
* Kick a member from this guild.
|
|
@@ -1602,7 +1621,7 @@ var init_Guild = __esm({
|
|
|
1602
1621
|
* Requires Kick Members permission.
|
|
1603
1622
|
*/
|
|
1604
1623
|
async kick(userId) {
|
|
1605
|
-
await this.client.rest.delete(
|
|
1624
|
+
await this.client.rest.delete(import_types10.Routes.guildMember(this.id, userId), { auth: true });
|
|
1606
1625
|
}
|
|
1607
1626
|
/**
|
|
1608
1627
|
* Fetch a guild member by user ID.
|
|
@@ -1614,13 +1633,13 @@ var init_Guild = __esm({
|
|
|
1614
1633
|
async fetchMember(userId) {
|
|
1615
1634
|
try {
|
|
1616
1635
|
const data = await this.client.rest.get(
|
|
1617
|
-
|
|
1636
|
+
import_types10.Routes.guildMember(this.id, userId)
|
|
1618
1637
|
);
|
|
1619
1638
|
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
1620
1639
|
this.members.set(member.id, member);
|
|
1621
1640
|
return member;
|
|
1622
1641
|
} catch (err) {
|
|
1623
|
-
const statusCode = err instanceof
|
|
1642
|
+
const statusCode = err instanceof import_rest3.FluxerAPIError ? err.statusCode : err?.statusCode;
|
|
1624
1643
|
if (statusCode === 404) {
|
|
1625
1644
|
throw new FluxerError(`Member ${userId} not found in guild`, {
|
|
1626
1645
|
code: ErrorCodes.MemberNotFound,
|
|
@@ -1642,13 +1661,13 @@ var init_Guild = __esm({
|
|
|
1642
1661
|
if (options?.userId) params.set("user_id", options.userId);
|
|
1643
1662
|
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
1644
1663
|
const qs = params.toString();
|
|
1645
|
-
const url =
|
|
1664
|
+
const url = import_types10.Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
1646
1665
|
return this.client.rest.get(url);
|
|
1647
1666
|
}
|
|
1648
1667
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
1649
1668
|
async fetchWebhooks() {
|
|
1650
1669
|
const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
|
|
1651
|
-
const data = await this.client.rest.get(
|
|
1670
|
+
const data = await this.client.rest.get(import_types10.Routes.guildWebhooks(this.id));
|
|
1652
1671
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1653
1672
|
return list.map((w) => new Webhook2(this.client, w));
|
|
1654
1673
|
}
|
|
@@ -1659,7 +1678,7 @@ var init_Guild = __esm({
|
|
|
1659
1678
|
*/
|
|
1660
1679
|
async createChannel(data) {
|
|
1661
1680
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1662
|
-
const created = await this.client.rest.post(
|
|
1681
|
+
const created = await this.client.rest.post(import_types10.Routes.guildChannels(this.id), {
|
|
1663
1682
|
body: data,
|
|
1664
1683
|
auth: true
|
|
1665
1684
|
});
|
|
@@ -1676,7 +1695,7 @@ var init_Guild = __esm({
|
|
|
1676
1695
|
*/
|
|
1677
1696
|
async fetchChannels() {
|
|
1678
1697
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1679
|
-
const data = await this.client.rest.get(
|
|
1698
|
+
const data = await this.client.rest.get(import_types10.Routes.guildChannels(this.id));
|
|
1680
1699
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1681
1700
|
const channels = [];
|
|
1682
1701
|
for (const ch of list) {
|
|
@@ -1695,7 +1714,7 @@ var init_Guild = __esm({
|
|
|
1695
1714
|
* Requires Manage Channels permission.
|
|
1696
1715
|
*/
|
|
1697
1716
|
async setChannelPositions(updates) {
|
|
1698
|
-
await this.client.rest.patch(
|
|
1717
|
+
await this.client.rest.patch(import_types10.Routes.guildChannels(this.id), {
|
|
1699
1718
|
body: updates,
|
|
1700
1719
|
auth: true
|
|
1701
1720
|
});
|
|
@@ -1705,12 +1724,12 @@ var init_Guild = __esm({
|
|
|
1705
1724
|
});
|
|
1706
1725
|
|
|
1707
1726
|
// src/structures/User.ts
|
|
1708
|
-
var
|
|
1727
|
+
var import_types12, User;
|
|
1709
1728
|
var init_User = __esm({
|
|
1710
1729
|
"src/structures/User.ts"() {
|
|
1711
1730
|
"use strict";
|
|
1712
1731
|
init_Base();
|
|
1713
|
-
|
|
1732
|
+
import_types12 = require("@fluxerjs/types");
|
|
1714
1733
|
init_Constants();
|
|
1715
1734
|
User = class extends Base {
|
|
1716
1735
|
client;
|
|
@@ -1788,7 +1807,7 @@ var init_User = __esm({
|
|
|
1788
1807
|
*/
|
|
1789
1808
|
async createDM() {
|
|
1790
1809
|
const { DMChannel: DMChannelClass } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1791
|
-
const data = await this.client.rest.post(
|
|
1810
|
+
const data = await this.client.rest.post(import_types12.Routes.userMeChannels(), {
|
|
1792
1811
|
body: { recipient_id: this.id },
|
|
1793
1812
|
auth: true
|
|
1794
1813
|
});
|
|
@@ -1811,10 +1830,14 @@ var MessageReaction_exports = {};
|
|
|
1811
1830
|
__export(MessageReaction_exports, {
|
|
1812
1831
|
MessageReaction: () => MessageReaction
|
|
1813
1832
|
});
|
|
1814
|
-
var MessageReaction;
|
|
1833
|
+
var import_types13, import_rest4, MessageReaction;
|
|
1815
1834
|
var init_MessageReaction = __esm({
|
|
1816
1835
|
"src/structures/MessageReaction.ts"() {
|
|
1817
1836
|
"use strict";
|
|
1837
|
+
import_types13 = require("@fluxerjs/types");
|
|
1838
|
+
import_rest4 = require("@fluxerjs/rest");
|
|
1839
|
+
init_FluxerError();
|
|
1840
|
+
init_ErrorCodes();
|
|
1818
1841
|
init_Base();
|
|
1819
1842
|
MessageReaction = class extends Base {
|
|
1820
1843
|
client;
|
|
@@ -1847,7 +1870,22 @@ var init_MessageReaction = __esm({
|
|
|
1847
1870
|
* @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
|
|
1848
1871
|
*/
|
|
1849
1872
|
async fetchMessage() {
|
|
1850
|
-
|
|
1873
|
+
try {
|
|
1874
|
+
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
1875
|
+
const data = await this.client.rest.get(
|
|
1876
|
+
import_types13.Routes.channelMessage(this.channelId, this.messageId)
|
|
1877
|
+
);
|
|
1878
|
+
return new Message2(this.client, data);
|
|
1879
|
+
} catch (err) {
|
|
1880
|
+
if (err instanceof import_rest4.RateLimitError) throw err;
|
|
1881
|
+
if (err instanceof import_rest4.FluxerAPIError && err.statusCode === 404) {
|
|
1882
|
+
throw new FluxerError(
|
|
1883
|
+
`Message ${this.messageId} not found in channel ${this.channelId}`,
|
|
1884
|
+
{ code: ErrorCodes.MessageNotFound, cause: err }
|
|
1885
|
+
);
|
|
1886
|
+
}
|
|
1887
|
+
throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
|
|
1888
|
+
}
|
|
1851
1889
|
}
|
|
1852
1890
|
};
|
|
1853
1891
|
}
|
|
@@ -1858,12 +1896,12 @@ var ClientUser_exports = {};
|
|
|
1858
1896
|
__export(ClientUser_exports, {
|
|
1859
1897
|
ClientUser: () => ClientUser
|
|
1860
1898
|
});
|
|
1861
|
-
var
|
|
1899
|
+
var import_types14, ClientUser;
|
|
1862
1900
|
var init_ClientUser = __esm({
|
|
1863
1901
|
"src/client/ClientUser.ts"() {
|
|
1864
1902
|
"use strict";
|
|
1865
1903
|
init_User();
|
|
1866
|
-
|
|
1904
|
+
import_types14 = require("@fluxerjs/types");
|
|
1867
1905
|
ClientUser = class extends User {
|
|
1868
1906
|
constructor(client, data) {
|
|
1869
1907
|
super(client, { ...data });
|
|
@@ -1874,7 +1912,7 @@ var init_ClientUser = __esm({
|
|
|
1874
1912
|
*/
|
|
1875
1913
|
async fetchGuilds() {
|
|
1876
1914
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
1877
|
-
const data = await this.client.rest.get(
|
|
1915
|
+
const data = await this.client.rest.get(import_types14.Routes.currentUserGuilds());
|
|
1878
1916
|
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
1879
1917
|
const guilds = [];
|
|
1880
1918
|
for (const g of list) {
|
|
@@ -1889,7 +1927,7 @@ var init_ClientUser = __esm({
|
|
|
1889
1927
|
* @param guildId - The guild ID to leave
|
|
1890
1928
|
*/
|
|
1891
1929
|
async leaveGuild(guildId) {
|
|
1892
|
-
await this.client.rest.delete(
|
|
1930
|
+
await this.client.rest.delete(import_types14.Routes.leaveGuild(guildId), { auth: true });
|
|
1893
1931
|
this.client.guilds.delete(guildId);
|
|
1894
1932
|
}
|
|
1895
1933
|
};
|
|
@@ -1911,7 +1949,7 @@ __export(index_exports, {
|
|
|
1911
1949
|
ErrorCodes: () => ErrorCodes,
|
|
1912
1950
|
Events: () => Events,
|
|
1913
1951
|
FluxerError: () => FluxerError,
|
|
1914
|
-
GatewayOpcodes: () =>
|
|
1952
|
+
GatewayOpcodes: () => import_types18.GatewayOpcodes,
|
|
1915
1953
|
Guild: () => Guild,
|
|
1916
1954
|
GuildBan: () => GuildBan,
|
|
1917
1955
|
GuildChannel: () => GuildChannel,
|
|
@@ -1921,7 +1959,7 @@ __export(index_exports, {
|
|
|
1921
1959
|
Invite: () => Invite,
|
|
1922
1960
|
LinkChannel: () => LinkChannel,
|
|
1923
1961
|
Message: () => Message,
|
|
1924
|
-
MessageAttachmentFlags: () =>
|
|
1962
|
+
MessageAttachmentFlags: () => import_types18.MessageAttachmentFlags,
|
|
1925
1963
|
MessageCollector: () => MessageCollector,
|
|
1926
1964
|
MessageManager: () => MessageManager,
|
|
1927
1965
|
MessagePayload: () => import_builders3.MessagePayload,
|
|
@@ -1930,7 +1968,7 @@ __export(index_exports, {
|
|
|
1930
1968
|
PermissionsBitField: () => import_util9.PermissionsBitField,
|
|
1931
1969
|
ReactionCollector: () => ReactionCollector,
|
|
1932
1970
|
Role: () => Role,
|
|
1933
|
-
Routes: () =>
|
|
1971
|
+
Routes: () => import_types18.Routes,
|
|
1934
1972
|
TextChannel: () => TextChannel,
|
|
1935
1973
|
User: () => User,
|
|
1936
1974
|
VoiceChannel: () => VoiceChannel,
|
|
@@ -1947,16 +1985,16 @@ module.exports = __toCommonJS(index_exports);
|
|
|
1947
1985
|
|
|
1948
1986
|
// src/client/Client.ts
|
|
1949
1987
|
var import_events3 = require("events");
|
|
1950
|
-
var
|
|
1988
|
+
var import_rest5 = require("@fluxerjs/rest");
|
|
1951
1989
|
var import_ws = require("@fluxerjs/ws");
|
|
1952
|
-
var
|
|
1990
|
+
var import_types15 = require("@fluxerjs/types");
|
|
1953
1991
|
var import_collection7 = require("@fluxerjs/collection");
|
|
1954
1992
|
|
|
1955
1993
|
// src/client/ChannelManager.ts
|
|
1956
1994
|
var import_collection4 = require("@fluxerjs/collection");
|
|
1957
|
-
var
|
|
1995
|
+
var import_types6 = require("@fluxerjs/types");
|
|
1958
1996
|
var import_util2 = require("@fluxerjs/util");
|
|
1959
|
-
var
|
|
1997
|
+
var import_rest2 = require("@fluxerjs/rest");
|
|
1960
1998
|
init_FluxerError();
|
|
1961
1999
|
init_ErrorCodes();
|
|
1962
2000
|
init_messageUtils();
|
|
@@ -1980,7 +2018,7 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1980
2018
|
try {
|
|
1981
2019
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1982
2020
|
const data = await this.client.rest.get(
|
|
1983
|
-
|
|
2021
|
+
import_types6.Routes.channel(channelId)
|
|
1984
2022
|
);
|
|
1985
2023
|
const channel = Channel2.fromOrCreate(this.client, data);
|
|
1986
2024
|
if (!channel) {
|
|
@@ -1991,8 +2029,8 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
1991
2029
|
this.set(channel.id, channel);
|
|
1992
2030
|
return channel;
|
|
1993
2031
|
} catch (err) {
|
|
1994
|
-
if (err instanceof
|
|
1995
|
-
if (err instanceof
|
|
2032
|
+
if (err instanceof import_rest2.RateLimitError) throw err;
|
|
2033
|
+
if (err instanceof import_rest2.FluxerAPIError && err.statusCode === 404) {
|
|
1996
2034
|
throw new FluxerError(`Channel ${channelId} not found`, {
|
|
1997
2035
|
code: ErrorCodes.ChannelNotFound,
|
|
1998
2036
|
cause: err
|
|
@@ -2020,12 +2058,12 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
2020
2058
|
try {
|
|
2021
2059
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
2022
2060
|
const data = await this.client.rest.get(
|
|
2023
|
-
|
|
2061
|
+
import_types6.Routes.channelMessage(channelId, messageId)
|
|
2024
2062
|
);
|
|
2025
2063
|
return new Message2(this.client, data);
|
|
2026
2064
|
} catch (err) {
|
|
2027
|
-
if (err instanceof
|
|
2028
|
-
if (err instanceof
|
|
2065
|
+
if (err instanceof import_rest2.RateLimitError) throw err;
|
|
2066
|
+
if (err instanceof import_rest2.FluxerAPIError && err.statusCode === 404) {
|
|
2029
2067
|
throw new FluxerError(`Message ${messageId} not found in channel ${channelId}`, {
|
|
2030
2068
|
code: ErrorCodes.MessageNotFound,
|
|
2031
2069
|
cause: err
|
|
@@ -2050,14 +2088,14 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
2050
2088
|
const body = buildSendBody(payload);
|
|
2051
2089
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
2052
2090
|
const postOptions = opts.files?.length ? { body, files: opts.files } : { body };
|
|
2053
|
-
const data = await this.client.rest.post(
|
|
2091
|
+
const data = await this.client.rest.post(import_types6.Routes.channelMessages(channelId), postOptions);
|
|
2054
2092
|
return new Message2(this.client, data);
|
|
2055
2093
|
}
|
|
2056
2094
|
};
|
|
2057
2095
|
|
|
2058
2096
|
// src/client/GuildManager.ts
|
|
2059
2097
|
var import_collection6 = require("@fluxerjs/collection");
|
|
2060
|
-
var
|
|
2098
|
+
var import_types11 = require("@fluxerjs/types");
|
|
2061
2099
|
var GuildManager = class extends import_collection6.Collection {
|
|
2062
2100
|
constructor(client) {
|
|
2063
2101
|
super();
|
|
@@ -2077,7 +2115,7 @@ var GuildManager = class extends import_collection6.Collection {
|
|
|
2077
2115
|
try {
|
|
2078
2116
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2079
2117
|
const data = await this.client.rest.get(
|
|
2080
|
-
|
|
2118
|
+
import_types11.Routes.guild(guildId)
|
|
2081
2119
|
);
|
|
2082
2120
|
const guild = new Guild2(this.client, data);
|
|
2083
2121
|
this.set(guild.id, guild);
|
|
@@ -2388,7 +2426,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2388
2426
|
get: () => this.guilds,
|
|
2389
2427
|
configurable: true
|
|
2390
2428
|
});
|
|
2391
|
-
this.rest = new
|
|
2429
|
+
this.rest = new import_rest5.REST({
|
|
2392
2430
|
api: options.rest?.api ?? "https://api.fluxer.app",
|
|
2393
2431
|
version: options.rest?.version ?? "1",
|
|
2394
2432
|
...options.rest
|
|
@@ -2417,11 +2455,14 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2417
2455
|
if (typeof emoji === "object" && emoji.id) {
|
|
2418
2456
|
return (0, import_util7.formatEmoji)({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
2419
2457
|
}
|
|
2420
|
-
const parsed = (0, import_util7.parseEmoji)(
|
|
2458
|
+
const parsed = (0, import_util7.parseEmoji)(
|
|
2459
|
+
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
2460
|
+
);
|
|
2421
2461
|
if (!parsed) throw new Error("Invalid emoji");
|
|
2422
2462
|
if (parsed.id) return (0, import_util7.formatEmoji)(parsed);
|
|
2463
|
+
if (!/^\w+$/.test(parsed.name)) return encodeURIComponent(parsed.name);
|
|
2423
2464
|
if (guildId) {
|
|
2424
|
-
const emojis = await this.rest.get(
|
|
2465
|
+
const emojis = await this.rest.get(import_types15.Routes.guildEmojis(guildId));
|
|
2425
2466
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
2426
2467
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
2427
2468
|
if (found) return (0, import_util7.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -2588,7 +2629,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2588
2629
|
return this.readyAt !== null && this.user !== null;
|
|
2589
2630
|
}
|
|
2590
2631
|
static get Routes() {
|
|
2591
|
-
return
|
|
2632
|
+
return import_types15.Routes;
|
|
2592
2633
|
}
|
|
2593
2634
|
};
|
|
2594
2635
|
|
|
@@ -2609,7 +2650,7 @@ init_GuildBan();
|
|
|
2609
2650
|
|
|
2610
2651
|
// src/structures/GuildEmoji.ts
|
|
2611
2652
|
init_Base();
|
|
2612
|
-
var
|
|
2653
|
+
var import_types16 = require("@fluxerjs/types");
|
|
2613
2654
|
init_Constants();
|
|
2614
2655
|
var GuildEmoji = class extends Base {
|
|
2615
2656
|
client;
|
|
@@ -2637,7 +2678,7 @@ var GuildEmoji = class extends Base {
|
|
|
2637
2678
|
}
|
|
2638
2679
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2639
2680
|
async delete() {
|
|
2640
|
-
await this.client.rest.delete(
|
|
2681
|
+
await this.client.rest.delete(import_types16.Routes.guildEmoji(this.guildId, this.id), {
|
|
2641
2682
|
auth: true
|
|
2642
2683
|
});
|
|
2643
2684
|
}
|
|
@@ -2646,7 +2687,7 @@ var GuildEmoji = class extends Base {
|
|
|
2646
2687
|
* Requires Manage Emojis and Stickers permission.
|
|
2647
2688
|
*/
|
|
2648
2689
|
async edit(options) {
|
|
2649
|
-
const data = await this.client.rest.patch(
|
|
2690
|
+
const data = await this.client.rest.patch(import_types16.Routes.guildEmoji(this.guildId, this.id), {
|
|
2650
2691
|
body: options,
|
|
2651
2692
|
auth: true
|
|
2652
2693
|
});
|
|
@@ -2657,7 +2698,7 @@ var GuildEmoji = class extends Base {
|
|
|
2657
2698
|
|
|
2658
2699
|
// src/structures/GuildSticker.ts
|
|
2659
2700
|
init_Base();
|
|
2660
|
-
var
|
|
2701
|
+
var import_types17 = require("@fluxerjs/types");
|
|
2661
2702
|
init_Constants();
|
|
2662
2703
|
var GuildSticker = class extends Base {
|
|
2663
2704
|
client;
|
|
@@ -2685,7 +2726,7 @@ var GuildSticker = class extends Base {
|
|
|
2685
2726
|
}
|
|
2686
2727
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
2687
2728
|
async delete() {
|
|
2688
|
-
await this.client.rest.delete(
|
|
2729
|
+
await this.client.rest.delete(import_types17.Routes.guildSticker(this.guildId, this.id), {
|
|
2689
2730
|
auth: true
|
|
2690
2731
|
});
|
|
2691
2732
|
}
|
|
@@ -2694,7 +2735,7 @@ var GuildSticker = class extends Base {
|
|
|
2694
2735
|
* Requires Manage Emojis and Stickers permission.
|
|
2695
2736
|
*/
|
|
2696
2737
|
async edit(options) {
|
|
2697
|
-
const data = await this.client.rest.patch(
|
|
2738
|
+
const data = await this.client.rest.patch(import_types17.Routes.guildSticker(this.guildId, this.id), {
|
|
2698
2739
|
body: options,
|
|
2699
2740
|
auth: true
|
|
2700
2741
|
});
|
|
@@ -2712,7 +2753,7 @@ init_ReactionCollector();
|
|
|
2712
2753
|
init_FluxerError();
|
|
2713
2754
|
init_ErrorCodes();
|
|
2714
2755
|
var import_builders3 = require("@fluxerjs/builders");
|
|
2715
|
-
var
|
|
2756
|
+
var import_types18 = require("@fluxerjs/types");
|
|
2716
2757
|
var import_util8 = require("@fluxerjs/util");
|
|
2717
2758
|
var import_util9 = require("@fluxerjs/util");
|
|
2718
2759
|
init_cdn();
|