@fluxerjs/core 3.4.0 → 3.5.0
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/dist/{SubpathMessage-BAwFSagN.d.mts → SubpathMessage-3ykAJr_F.d.mts} +165 -3
- package/dist/{SubpathMessage-Dq-1tI7E.d.ts → SubpathMessage-nY2WQ8V1.d.ts} +165 -3
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +522 -241
- package/dist/client.mjs +442 -161
- package/dist/cluster.d.mts +1 -1
- package/dist/cluster.d.ts +1 -1
- package/dist/cluster.js +522 -241
- package/dist/cluster.mjs +442 -161
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +563 -278
- package/dist/index.mjs +446 -163
- package/dist/message.d.mts +1 -1
- package/dist/message.d.ts +1 -1
- package/dist/message.js +18 -3
- package/dist/message.mjs +18 -3
- package/package.json +7 -7
package/dist/client.js
CHANGED
|
@@ -28,8 +28,8 @@ module.exports = __toCommonJS(SubpathClient_exports);
|
|
|
28
28
|
// src/ClientCore/Client.ts
|
|
29
29
|
var import_node_events3 = require("events");
|
|
30
30
|
var import_rest3 = require("@fluxerjs/rest");
|
|
31
|
-
var
|
|
32
|
-
var
|
|
31
|
+
var import_types46 = require("@fluxerjs/types");
|
|
32
|
+
var import_util27 = require("@fluxerjs/util");
|
|
33
33
|
|
|
34
34
|
// src/Domain/Message/Message.ts
|
|
35
35
|
var import_builders3 = require("@fluxerjs/builders");
|
|
@@ -1007,6 +1007,13 @@ var Events = {
|
|
|
1007
1007
|
VoiceSignal: "voiceSignal",
|
|
1008
1008
|
OperatorPassUpdate: "operatorPassUpdate",
|
|
1009
1009
|
VoiceStatesSync: "voiceStatesSync",
|
|
1010
|
+
VoiceJoinQueued: "voiceJoinQueued",
|
|
1011
|
+
StageInstanceCreate: "stageInstanceCreate",
|
|
1012
|
+
StageInstanceUpdate: "stageInstanceUpdate",
|
|
1013
|
+
StageInstanceDelete: "stageInstanceDelete",
|
|
1014
|
+
StageCountsUpdate: "stageCountsUpdate",
|
|
1015
|
+
StageVoiceStatesSync: "stageVoiceStatesSync",
|
|
1016
|
+
StageAudienceListUpdate: "stageAudienceListUpdate",
|
|
1010
1017
|
WebhooksUpdate: "webhooksUpdate",
|
|
1011
1018
|
Resumed: "resumed",
|
|
1012
1019
|
Error: "error",
|
|
@@ -1566,11 +1573,11 @@ var Channel = class extends Base {
|
|
|
1566
1573
|
* Checks {@link ChannelType}, not whether `send` exists on the instance.
|
|
1567
1574
|
*/
|
|
1568
1575
|
isTextBased() {
|
|
1569
|
-
return this.type === import_types7.ChannelType.GuildText || this.type === import_types7.ChannelType.GuildAnnouncement || this.type === import_types7.ChannelType.GuildVoice || this.type === import_types7.ChannelType.DM || this.type === import_types7.ChannelType.GroupDM || this.type === import_types7.ChannelType.DMPersonalNotes || this.type === import_types7.ChannelType.AnnouncementThread || this.type === import_types7.ChannelType.PublicThread || this.type === import_types7.ChannelType.PrivateThread;
|
|
1576
|
+
return this.type === import_types7.ChannelType.GuildText || this.type === import_types7.ChannelType.GuildAnnouncement || this.type === import_types7.ChannelType.GuildVoice || this.type === import_types7.ChannelType.GuildStageVoice || this.type === import_types7.ChannelType.DM || this.type === import_types7.ChannelType.GroupDM || this.type === import_types7.ChannelType.DMPersonalNotes || this.type === import_types7.ChannelType.AnnouncementThread || this.type === import_types7.ChannelType.PublicThread || this.type === import_types7.ChannelType.PrivateThread;
|
|
1570
1577
|
}
|
|
1571
1578
|
/** Check if this is a guild channel, including threads, forums, and media channels. */
|
|
1572
1579
|
isGuild() {
|
|
1573
|
-
return this.type === import_types7.ChannelType.GuildText || this.type === import_types7.ChannelType.GuildAnnouncement || this.type === import_types7.ChannelType.GuildVoice || this.type === import_types7.ChannelType.GuildCategory || this.type === import_types7.ChannelType.GuildLink || this.type === import_types7.ChannelType.AnnouncementThread || this.type === import_types7.ChannelType.PublicThread || this.type === import_types7.ChannelType.PrivateThread || this.type === import_types7.ChannelType.GuildForum || this.type === import_types7.ChannelType.GuildMedia;
|
|
1580
|
+
return this.type === import_types7.ChannelType.GuildText || this.type === import_types7.ChannelType.GuildAnnouncement || this.type === import_types7.ChannelType.GuildVoice || this.type === import_types7.ChannelType.GuildStageVoice || this.type === import_types7.ChannelType.GuildCategory || this.type === import_types7.ChannelType.GuildLink || this.type === import_types7.ChannelType.AnnouncementThread || this.type === import_types7.ChannelType.PublicThread || this.type === import_types7.ChannelType.PrivateThread || this.type === import_types7.ChannelType.GuildForum || this.type === import_types7.ChannelType.GuildMedia;
|
|
1574
1581
|
}
|
|
1575
1582
|
/** Check if this is a thread (public, private, or announcement). */
|
|
1576
1583
|
isThread() {
|
|
@@ -1604,10 +1611,18 @@ var Channel = class extends Base {
|
|
|
1604
1611
|
isPersonalNotes() {
|
|
1605
1612
|
return this.type === import_types7.ChannelType.DMPersonalNotes;
|
|
1606
1613
|
}
|
|
1607
|
-
/** Check if this is a voice channel. */
|
|
1614
|
+
/** Check if this is a voice channel (type 2 only; see {@link isVoiceBased} to include stages). */
|
|
1608
1615
|
isVoice() {
|
|
1609
1616
|
return this.type === import_types7.ChannelType.GuildVoice;
|
|
1610
1617
|
}
|
|
1618
|
+
/** Check if this is a stage channel (type 13). */
|
|
1619
|
+
isStage() {
|
|
1620
|
+
return this.type === import_types7.ChannelType.GuildStageVoice;
|
|
1621
|
+
}
|
|
1622
|
+
/** Check if this is a voice or stage channel, i.e. one `@fluxerjs/voice` can join. */
|
|
1623
|
+
isVoiceBased() {
|
|
1624
|
+
return this.type === import_types7.ChannelType.GuildVoice || this.type === import_types7.ChannelType.GuildStageVoice;
|
|
1625
|
+
}
|
|
1611
1626
|
/** Check if this is a link channel. */
|
|
1612
1627
|
isLink() {
|
|
1613
1628
|
return this.type === import_types7.ChannelType.GuildLink;
|
|
@@ -2618,8 +2633,8 @@ var PartialMessage = class {
|
|
|
2618
2633
|
};
|
|
2619
2634
|
|
|
2620
2635
|
// src/Domain/User.ts
|
|
2621
|
-
var
|
|
2622
|
-
var
|
|
2636
|
+
var import_types22 = require("@fluxerjs/types");
|
|
2637
|
+
var import_util15 = require("@fluxerjs/util");
|
|
2623
2638
|
|
|
2624
2639
|
// src/Domain/Channel/Dm.ts
|
|
2625
2640
|
var import_types12 = require("@fluxerjs/types");
|
|
@@ -2758,11 +2773,11 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2758
2773
|
};
|
|
2759
2774
|
|
|
2760
2775
|
// src/Domain/Channel/Forum.ts
|
|
2761
|
-
var
|
|
2776
|
+
var import_types20 = require("@fluxerjs/types");
|
|
2762
2777
|
|
|
2763
2778
|
// src/Domain/Channel/Guild.ts
|
|
2764
|
-
var
|
|
2765
|
-
var
|
|
2779
|
+
var import_types17 = require("@fluxerjs/types");
|
|
2780
|
+
var import_util14 = require("@fluxerjs/util");
|
|
2766
2781
|
|
|
2767
2782
|
// src/Domain/Invite.ts
|
|
2768
2783
|
var import_types13 = require("@fluxerjs/types");
|
|
@@ -3352,6 +3367,127 @@ var PermissionOverwriteManager = class {
|
|
|
3352
3367
|
}
|
|
3353
3368
|
};
|
|
3354
3369
|
|
|
3370
|
+
// src/Domain/StageInstance.ts
|
|
3371
|
+
var import_types16 = require("@fluxerjs/types");
|
|
3372
|
+
var import_util13 = require("@fluxerjs/util");
|
|
3373
|
+
var StageInstance = class extends Base {
|
|
3374
|
+
client;
|
|
3375
|
+
id;
|
|
3376
|
+
guildId;
|
|
3377
|
+
channelId;
|
|
3378
|
+
topic;
|
|
3379
|
+
/** Always {@link StageInstancePrivacyLevel.GuildOnly} on Fluxer. */
|
|
3380
|
+
privacyLevel;
|
|
3381
|
+
/** Always `true` on Fluxer. */
|
|
3382
|
+
discoverableDisabled;
|
|
3383
|
+
/** Always null on Fluxer. */
|
|
3384
|
+
guildScheduledEventId;
|
|
3385
|
+
constructor(client, data) {
|
|
3386
|
+
super();
|
|
3387
|
+
this.client = client;
|
|
3388
|
+
this.id = data.id;
|
|
3389
|
+
this.guildId = data.guild_id;
|
|
3390
|
+
this.channelId = data.channel_id;
|
|
3391
|
+
this.topic = data.topic;
|
|
3392
|
+
this.privacyLevel = data.privacy_level ?? import_types16.StageInstancePrivacyLevel.GuildOnly;
|
|
3393
|
+
this.discoverableDisabled = data.discoverable_disabled ?? true;
|
|
3394
|
+
this.guildScheduledEventId = data.guild_scheduled_event_id ?? null;
|
|
3395
|
+
}
|
|
3396
|
+
/** @internal Patch in place from a newer payload. */
|
|
3397
|
+
_patch(data) {
|
|
3398
|
+
if (data.topic !== void 0) this.topic = data.topic;
|
|
3399
|
+
if (data.privacy_level !== void 0) this.privacyLevel = data.privacy_level;
|
|
3400
|
+
if (data.discoverable_disabled !== void 0) {
|
|
3401
|
+
this.discoverableDisabled = data.discoverable_disabled;
|
|
3402
|
+
}
|
|
3403
|
+
if (data.guild_scheduled_event_id !== void 0) {
|
|
3404
|
+
this.guildScheduledEventId = data.guild_scheduled_event_id ?? null;
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
get guild() {
|
|
3408
|
+
return this.client.guilds.get(this.guildId) ?? null;
|
|
3409
|
+
}
|
|
3410
|
+
get channel() {
|
|
3411
|
+
const channel = this.client.channels.get(this.channelId);
|
|
3412
|
+
return channel?.isStage() ? channel : null;
|
|
3413
|
+
}
|
|
3414
|
+
/** Unix timestamp (ms) when the stage started, from its snowflake ID. */
|
|
3415
|
+
get createdTimestamp() {
|
|
3416
|
+
return import_util13.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
3417
|
+
}
|
|
3418
|
+
get createdAt() {
|
|
3419
|
+
return import_util13.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
3420
|
+
}
|
|
3421
|
+
/**
|
|
3422
|
+
* Change the live stage. Needs a stage moderator.
|
|
3423
|
+
* Fires `STAGE_INSTANCE_UPDATE`.
|
|
3424
|
+
*/
|
|
3425
|
+
async edit(options) {
|
|
3426
|
+
const body = {};
|
|
3427
|
+
if (options.topic !== void 0) body.topic = options.topic;
|
|
3428
|
+
const data = await this.client.rest.patch(
|
|
3429
|
+
import_types16.Routes.stageInstance(this.channelId),
|
|
3430
|
+
{ body, auth: true, ...auditReasonHeaders(options.reason) }
|
|
3431
|
+
);
|
|
3432
|
+
this._patch(data);
|
|
3433
|
+
return this;
|
|
3434
|
+
}
|
|
3435
|
+
/** Change the stage topic. Shorthand for {@link edit}. */
|
|
3436
|
+
async setTopic(topic, reason) {
|
|
3437
|
+
return this.edit({ topic, reason });
|
|
3438
|
+
}
|
|
3439
|
+
/**
|
|
3440
|
+
* End the stage. Needs a stage moderator. Speakers move to the audience, raised hands are
|
|
3441
|
+
* lowered, and everyone stays connected unless `disconnectAll` is set.
|
|
3442
|
+
*/
|
|
3443
|
+
async delete(options = {}) {
|
|
3444
|
+
const route = import_types16.Routes.stageInstance(this.channelId) + (options.disconnectAll ? "?disconnect_all=true" : "");
|
|
3445
|
+
await this.client.rest.delete(route, { auth: true, ...auditReasonHeaders(options.reason) });
|
|
3446
|
+
}
|
|
3447
|
+
toJSON() {
|
|
3448
|
+
return {
|
|
3449
|
+
id: this.id,
|
|
3450
|
+
guild_id: this.guildId,
|
|
3451
|
+
channel_id: this.channelId,
|
|
3452
|
+
topic: this.topic,
|
|
3453
|
+
privacy_level: this.privacyLevel,
|
|
3454
|
+
discoverable_disabled: this.discoverableDisabled,
|
|
3455
|
+
guild_scheduled_event_id: this.guildScheduledEventId
|
|
3456
|
+
};
|
|
3457
|
+
}
|
|
3458
|
+
};
|
|
3459
|
+
|
|
3460
|
+
// src/Domain/Channel/StageSync.ts
|
|
3461
|
+
function syncStageInstances(guild, instances) {
|
|
3462
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3463
|
+
for (const data of instances) {
|
|
3464
|
+
seen.add(data.id);
|
|
3465
|
+
const existing = guild.stageInstances.get(data.id);
|
|
3466
|
+
if (existing) existing._patch(data);
|
|
3467
|
+
else guild.stageInstances.set(data.id, new StageInstance(guild.client, data));
|
|
3468
|
+
}
|
|
3469
|
+
for (const id of [...guild.stageInstances.keys()]) {
|
|
3470
|
+
if (!seen.has(id)) guild.stageInstances.delete(id);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
function applyStageCounts(guild, counts) {
|
|
3474
|
+
for (const count of counts) {
|
|
3475
|
+
const channel = guild.channels.get(count.channel_id);
|
|
3476
|
+
if (channel?.isStage()) channel._patchCounts(count);
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
function cacheStageInstance(client, data) {
|
|
3480
|
+
const guild = client.guilds.get(data.guild_id);
|
|
3481
|
+
const existing = guild?.stageInstances.get(data.id);
|
|
3482
|
+
if (existing) {
|
|
3483
|
+
existing._patch(data);
|
|
3484
|
+
return existing;
|
|
3485
|
+
}
|
|
3486
|
+
const instance = new StageInstance(client, data);
|
|
3487
|
+
guild?.stageInstances.set(instance.id, instance);
|
|
3488
|
+
return instance;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3355
3491
|
// src/Domain/Channel/ThreadBind.ts
|
|
3356
3492
|
var factory;
|
|
3357
3493
|
var managers = /* @__PURE__ */ new WeakMap();
|
|
@@ -3406,7 +3542,7 @@ var GuildChannel = class extends Channel {
|
|
|
3406
3542
|
}
|
|
3407
3543
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
3408
3544
|
async createWebhook(options) {
|
|
3409
|
-
const data = await this.client.rest.post(
|
|
3545
|
+
const data = await this.client.rest.post(import_types17.Routes.channelWebhooks(this.id), {
|
|
3410
3546
|
body: options,
|
|
3411
3547
|
auth: true
|
|
3412
3548
|
});
|
|
@@ -3414,13 +3550,13 @@ var GuildChannel = class extends Channel {
|
|
|
3414
3550
|
}
|
|
3415
3551
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
3416
3552
|
async fetchWebhooks() {
|
|
3417
|
-
const data = await this.client.rest.get(
|
|
3553
|
+
const data = await this.client.rest.get(import_types17.Routes.channelWebhooks(this.id));
|
|
3418
3554
|
return data.map((w) => new Webhook(this.client, w));
|
|
3419
3555
|
}
|
|
3420
3556
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
3421
3557
|
async createInvite(options) {
|
|
3422
3558
|
const body = options ? toChannelInviteBody(options) : {};
|
|
3423
|
-
const data = await this.client.rest.post(
|
|
3559
|
+
const data = await this.client.rest.post(import_types17.Routes.channelInvites(this.id), {
|
|
3424
3560
|
body: Object.keys(body).length ? body : void 0,
|
|
3425
3561
|
auth: true
|
|
3426
3562
|
});
|
|
@@ -3428,7 +3564,7 @@ var GuildChannel = class extends Channel {
|
|
|
3428
3564
|
}
|
|
3429
3565
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
3430
3566
|
async fetchInvites() {
|
|
3431
|
-
const data = await this.client.rest.get(
|
|
3567
|
+
const data = await this.client.rest.get(import_types17.Routes.channelInvites(this.id));
|
|
3432
3568
|
return data.map((i) => new Invite(this.client, i));
|
|
3433
3569
|
}
|
|
3434
3570
|
/** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
|
|
@@ -3437,7 +3573,7 @@ var GuildChannel = class extends Channel {
|
|
|
3437
3573
|
const me = this.client.guilds.get(this.guildId)?.members.me;
|
|
3438
3574
|
if (!me) return false;
|
|
3439
3575
|
const perms = me.permissionsIn(this);
|
|
3440
|
-
return perms.has(
|
|
3576
|
+
return perms.has(import_util14.PermissionFlags.ViewChannel) && perms.has(import_util14.PermissionFlags.SendMessages);
|
|
3441
3577
|
}
|
|
3442
3578
|
/**
|
|
3443
3579
|
* Like {@link canSendMessage}, but hydrates `members.me` via REST when missing.
|
|
@@ -3458,7 +3594,7 @@ var GuildChannel = class extends Channel {
|
|
|
3458
3594
|
}
|
|
3459
3595
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
3460
3596
|
async edit(options) {
|
|
3461
|
-
const data = await this.client.rest.patch(
|
|
3597
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3462
3598
|
body: toChannelEditBody(options),
|
|
3463
3599
|
auth: true,
|
|
3464
3600
|
...auditReasonHeaders(options.reason)
|
|
@@ -3540,7 +3676,7 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3540
3676
|
* Sends only those fields. The thread-parent update body does not accept a channel rename.
|
|
3541
3677
|
*/
|
|
3542
3678
|
async editThreadDefaults(options) {
|
|
3543
|
-
const data = await this.client.rest.patch(
|
|
3679
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3544
3680
|
body: toThreadParentEditBody(options),
|
|
3545
3681
|
auth: true,
|
|
3546
3682
|
...auditReasonHeaders(options.reason)
|
|
@@ -3556,14 +3692,14 @@ var AnnouncementChannel = class extends TextChannel {
|
|
|
3556
3692
|
*/
|
|
3557
3693
|
async follow(webhookChannelId) {
|
|
3558
3694
|
return this.client.rest.post(
|
|
3559
|
-
|
|
3695
|
+
import_types17.Routes.channelFollowers(this.id),
|
|
3560
3696
|
{ body: { webhook_channel_id: webhookChannelId }, auth: true }
|
|
3561
3697
|
);
|
|
3562
3698
|
}
|
|
3563
3699
|
/** Fetch follower counts for this announcement channel. */
|
|
3564
3700
|
async fetchFollowerStats() {
|
|
3565
3701
|
return this.client.rest.get(
|
|
3566
|
-
|
|
3702
|
+
import_types17.Routes.channelFollowerStats(this.id),
|
|
3567
3703
|
{ auth: true }
|
|
3568
3704
|
);
|
|
3569
3705
|
}
|
|
@@ -3638,6 +3774,96 @@ var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
|
3638
3774
|
if ("rtc_p2p" in data) this.rtcP2p = data.rtc_p2p ?? false;
|
|
3639
3775
|
}
|
|
3640
3776
|
};
|
|
3777
|
+
var StageChannel = class extends VoiceChannel {
|
|
3778
|
+
/** Last known stage counts, or null until Fluxer sends them. */
|
|
3779
|
+
counts = null;
|
|
3780
|
+
/** The cached live stage of this channel, or null when the stage isn't live (or not cached). */
|
|
3781
|
+
get stageInstance() {
|
|
3782
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
3783
|
+
if (!guild) return null;
|
|
3784
|
+
for (const instance of guild.stageInstances.values()) {
|
|
3785
|
+
if (instance.channelId === this.id) return instance;
|
|
3786
|
+
}
|
|
3787
|
+
return null;
|
|
3788
|
+
}
|
|
3789
|
+
/** Whether the stage is live according to the cache. */
|
|
3790
|
+
get isLive() {
|
|
3791
|
+
return this.stageInstance !== null;
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* Start a stage in this channel. Needs a stage moderator (`MANAGE_CHANNELS`, `MUTE_MEMBERS` and
|
|
3795
|
+
* `MOVE_MEMBERS`). When the caller is connected to the stage, they become a speaker.
|
|
3796
|
+
*/
|
|
3797
|
+
async createStageInstance(options) {
|
|
3798
|
+
const body = { channel_id: this.id, topic: options.topic };
|
|
3799
|
+
if (options.sendStartNotification !== void 0) {
|
|
3800
|
+
body.send_start_notification = options.sendStartNotification;
|
|
3801
|
+
}
|
|
3802
|
+
const data = await this.client.rest.post(import_types17.Routes.stageInstances(), {
|
|
3803
|
+
body,
|
|
3804
|
+
auth: true,
|
|
3805
|
+
...auditReasonHeaders(options.reason)
|
|
3806
|
+
});
|
|
3807
|
+
return cacheStageInstance(this.client, data);
|
|
3808
|
+
}
|
|
3809
|
+
/** Fetch the live stage of this channel. Rejects with `UNKNOWN_STAGE_INSTANCE` when not live. */
|
|
3810
|
+
async fetchStageInstance() {
|
|
3811
|
+
const data = await this.client.rest.get(import_types17.Routes.stageInstance(this.id), {
|
|
3812
|
+
auth: true
|
|
3813
|
+
});
|
|
3814
|
+
return cacheStageInstance(this.client, data);
|
|
3815
|
+
}
|
|
3816
|
+
/**
|
|
3817
|
+
* Move a member (or yourself when `user` is omitted) between the audience and the speakers.
|
|
3818
|
+
*
|
|
3819
|
+
* - Yourself, `false`: become a speaker (needs `MUTE_MEMBERS`), or accept an open invite.
|
|
3820
|
+
* - Yourself, `true`: move to the audience, or decline an invite.
|
|
3821
|
+
* - Another member, `false`: invite them to speak (a bot becomes a speaker at once). Needs `MUTE_MEMBERS`.
|
|
3822
|
+
* - Another member, `true`: move them to the audience and clear a raised hand or invite.
|
|
3823
|
+
*/
|
|
3824
|
+
async setSuppressed(suppressed, user) {
|
|
3825
|
+
const userId = user === void 0 ? "@me" : typeof user === "string" ? user : user.id;
|
|
3826
|
+
const body = {
|
|
3827
|
+
channel_id: this.id,
|
|
3828
|
+
suppress: suppressed
|
|
3829
|
+
};
|
|
3830
|
+
await this.client.rest.patch(import_types17.Routes.guildVoiceState(this.guildId, userId), {
|
|
3831
|
+
body,
|
|
3832
|
+
auth: true
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
/** Invite a member to speak (a bot becomes a speaker at once). Needs `MUTE_MEMBERS`. */
|
|
3836
|
+
async inviteToSpeak(user) {
|
|
3837
|
+
await this.setSuppressed(false, user);
|
|
3838
|
+
}
|
|
3839
|
+
/** Move a speaker (or yourself when `user` is omitted) to the audience. */
|
|
3840
|
+
async moveToAudience(user) {
|
|
3841
|
+
await this.setSuppressed(true, user);
|
|
3842
|
+
}
|
|
3843
|
+
/**
|
|
3844
|
+
* Raise (`true`) or lower (`false`) your hand. Raising needs a live stage and
|
|
3845
|
+
* `REQUEST_TO_SPEAK`; lowering also accepts an open invite to speak.
|
|
3846
|
+
*/
|
|
3847
|
+
async setRequestToSpeak(raised = true) {
|
|
3848
|
+
const body = {
|
|
3849
|
+
channel_id: this.id,
|
|
3850
|
+
request_to_speak_timestamp: raised ? (/* @__PURE__ */ new Date()).toISOString() : null
|
|
3851
|
+
};
|
|
3852
|
+
await this.client.rest.patch(import_types17.Routes.guildVoiceState(this.guildId, "@me"), {
|
|
3853
|
+
body,
|
|
3854
|
+
auth: true
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
/** @internal Apply a stage count object. */
|
|
3858
|
+
_patchCounts(data) {
|
|
3859
|
+
this.counts = {
|
|
3860
|
+
listenerCount: data.listener_count,
|
|
3861
|
+
speakerCount: data.speaker_count,
|
|
3862
|
+
requestCount: data.request_count,
|
|
3863
|
+
videoEnabled: data.video_enabled ?? null
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3641
3867
|
var LinkChannel = class extends GuildChannel {
|
|
3642
3868
|
/** External URL this channel links to. */
|
|
3643
3869
|
url;
|
|
@@ -3651,10 +3877,10 @@ var LinkChannel = class extends GuildChannel {
|
|
|
3651
3877
|
};
|
|
3652
3878
|
|
|
3653
3879
|
// src/Domain/Channel/ThreadManager.ts
|
|
3654
|
-
var
|
|
3880
|
+
var import_types19 = require("@fluxerjs/types");
|
|
3655
3881
|
|
|
3656
3882
|
// src/Domain/Channel/ThreadChannel.ts
|
|
3657
|
-
var
|
|
3883
|
+
var import_types18 = require("@fluxerjs/types");
|
|
3658
3884
|
var ThreadMember = class {
|
|
3659
3885
|
/** Thread ID. */
|
|
3660
3886
|
id;
|
|
@@ -3781,7 +4007,7 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
3781
4007
|
* `appliedTags` is sent for public and announcement threads. `invitable` is sent for private threads.
|
|
3782
4008
|
*/
|
|
3783
4009
|
async edit(options) {
|
|
3784
|
-
const data = await this.client.rest.patch(
|
|
4010
|
+
const data = await this.client.rest.patch(import_types18.Routes.channel(this.id), {
|
|
3785
4011
|
body: toThreadEditBody(this.type, threadEditFields(options)),
|
|
3786
4012
|
auth: true,
|
|
3787
4013
|
...auditReasonHeaders(options.reason)
|
|
@@ -3799,16 +4025,16 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
3799
4025
|
}
|
|
3800
4026
|
/** Join this thread. */
|
|
3801
4027
|
async join() {
|
|
3802
|
-
await this.client.rest.put(
|
|
4028
|
+
await this.client.rest.put(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3803
4029
|
}
|
|
3804
4030
|
/** Leave this thread. */
|
|
3805
4031
|
async leave() {
|
|
3806
|
-
await this.client.rest.delete(
|
|
4032
|
+
await this.client.rest.delete(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3807
4033
|
}
|
|
3808
4034
|
/** Update the current user's notification settings for this thread. */
|
|
3809
4035
|
async editSelf(options) {
|
|
3810
4036
|
const data = await this.client.rest.patch(
|
|
3811
|
-
|
|
4037
|
+
import_types18.Routes.channelThreadMemberMeSettings(this.id),
|
|
3812
4038
|
{ body: toThreadMemberSettingsBody(options), auth: true }
|
|
3813
4039
|
);
|
|
3814
4040
|
this.member = data ? new ThreadMember(data) : null;
|
|
@@ -3822,7 +4048,7 @@ var ThreadMemberManager = class {
|
|
|
3822
4048
|
/** List members of this thread. */
|
|
3823
4049
|
async fetch(options) {
|
|
3824
4050
|
const data = await this.thread.client.rest.get(
|
|
3825
|
-
withQuery(
|
|
4051
|
+
withQuery(import_types18.Routes.channelThreadMembers(this.thread.id), {
|
|
3826
4052
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember),
|
|
3827
4053
|
after: options?.after,
|
|
3828
4054
|
limit: options?.limit
|
|
@@ -3833,7 +4059,7 @@ var ThreadMemberManager = class {
|
|
|
3833
4059
|
/** Fetch one member of this thread. */
|
|
3834
4060
|
async fetchOne(userId, options) {
|
|
3835
4061
|
const data = await this.thread.client.rest.get(
|
|
3836
|
-
withQuery(
|
|
4062
|
+
withQuery(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3837
4063
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember)
|
|
3838
4064
|
})
|
|
3839
4065
|
);
|
|
@@ -3841,19 +4067,19 @@ var ThreadMemberManager = class {
|
|
|
3841
4067
|
}
|
|
3842
4068
|
/** Add a user to this thread. Private threads only, unless the caller can manage the parent. */
|
|
3843
4069
|
async add(userId) {
|
|
3844
|
-
await this.thread.client.rest.put(
|
|
4070
|
+
await this.thread.client.rest.put(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3845
4071
|
auth: true
|
|
3846
4072
|
});
|
|
3847
4073
|
}
|
|
3848
4074
|
/** Remove a user from this thread. */
|
|
3849
4075
|
async remove(userId) {
|
|
3850
|
-
await this.thread.client.rest.delete(
|
|
4076
|
+
await this.thread.client.rest.delete(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3851
4077
|
auth: true
|
|
3852
4078
|
});
|
|
3853
4079
|
}
|
|
3854
4080
|
};
|
|
3855
4081
|
function isThreadType(type) {
|
|
3856
|
-
return type ===
|
|
4082
|
+
return type === import_types18.ChannelType.AnnouncementThread || type === import_types18.ChannelType.PublicThread || type === import_types18.ChannelType.PrivateThread;
|
|
3857
4083
|
}
|
|
3858
4084
|
|
|
3859
4085
|
// src/Domain/Channel/ThreadManager.ts
|
|
@@ -3866,13 +4092,13 @@ var ThreadManager = class {
|
|
|
3866
4092
|
* Forum and media channels must use {@link createPost}.
|
|
3867
4093
|
*/
|
|
3868
4094
|
async create(options) {
|
|
3869
|
-
if (this.channel.type ===
|
|
4095
|
+
if (this.channel.type === import_types19.ChannelType.GuildForum || this.channel.type === import_types19.ChannelType.GuildMedia) {
|
|
3870
4096
|
throw new import_util4.FluxerError("Forum and media channels start posts with createPost", {
|
|
3871
4097
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
3872
4098
|
});
|
|
3873
4099
|
}
|
|
3874
4100
|
const data = await this.channel.client.rest.post(
|
|
3875
|
-
|
|
4101
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
3876
4102
|
{
|
|
3877
4103
|
body: toStartThreadBody(this.channel.type, options),
|
|
3878
4104
|
auth: true,
|
|
@@ -3886,7 +4112,7 @@ var ThreadManager = class {
|
|
|
3886
4112
|
* The post is a public thread. `message` is its first message.
|
|
3887
4113
|
*/
|
|
3888
4114
|
async createPost(options) {
|
|
3889
|
-
if (this.channel.type !==
|
|
4115
|
+
if (this.channel.type !== import_types19.ChannelType.GuildForum && this.channel.type !== import_types19.ChannelType.GuildMedia) {
|
|
3890
4116
|
throw new import_util4.FluxerError("createPost is for forum and media channels", {
|
|
3891
4117
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
3892
4118
|
});
|
|
@@ -3896,7 +4122,7 @@ var ThreadManager = class {
|
|
|
3896
4122
|
});
|
|
3897
4123
|
const body = {
|
|
3898
4124
|
name: options.name,
|
|
3899
|
-
type:
|
|
4125
|
+
type: import_types19.ChannelType.PublicThread,
|
|
3900
4126
|
message: toForumThreadMessage(prepared.body)
|
|
3901
4127
|
};
|
|
3902
4128
|
if (options.autoArchiveDuration !== void 0) {
|
|
@@ -3905,7 +4131,7 @@ var ThreadManager = class {
|
|
|
3905
4131
|
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
3906
4132
|
if (options.appliedTags !== void 0) body.applied_tags = options.appliedTags;
|
|
3907
4133
|
const data = await this.channel.client.rest.post(
|
|
3908
|
-
|
|
4134
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
3909
4135
|
{
|
|
3910
4136
|
body,
|
|
3911
4137
|
files: prepared.files,
|
|
@@ -3924,7 +4150,7 @@ var ThreadManager = class {
|
|
|
3924
4150
|
* `before` is an ISO-8601 archive timestamp.
|
|
3925
4151
|
*/
|
|
3926
4152
|
async fetchArchived(options) {
|
|
3927
|
-
const path = options.type === "private" ?
|
|
4153
|
+
const path = options.type === "private" ? import_types19.Routes.channelThreadsArchivedPrivate(this.channel.id) : import_types19.Routes.channelThreadsArchivedPublic(this.channel.id);
|
|
3928
4154
|
const data = await this.channel.client.rest.get(
|
|
3929
4155
|
withQuery(path, { before: options.before, limit: options.limit })
|
|
3930
4156
|
);
|
|
@@ -3936,7 +4162,7 @@ var ThreadManager = class {
|
|
|
3936
4162
|
*/
|
|
3937
4163
|
async fetchJoinedPrivateArchived(options) {
|
|
3938
4164
|
const data = await this.channel.client.rest.get(
|
|
3939
|
-
withQuery(
|
|
4165
|
+
withQuery(import_types19.Routes.channelJoinedArchivedPrivateThreads(this.channel.id), {
|
|
3940
4166
|
before: options?.before,
|
|
3941
4167
|
limit: options?.limit
|
|
3942
4168
|
})
|
|
@@ -3949,7 +4175,7 @@ var ThreadManager = class {
|
|
|
3949
4175
|
*/
|
|
3950
4176
|
async search(options) {
|
|
3951
4177
|
const data = await this.channel.client.rest.get(
|
|
3952
|
-
withQuery(
|
|
4178
|
+
withQuery(import_types19.Routes.channelThreadSearch(this.channel.id), {
|
|
3953
4179
|
name: options?.name,
|
|
3954
4180
|
tag: options?.tag,
|
|
3955
4181
|
tag_setting: options?.tagSetting,
|
|
@@ -3977,7 +4203,7 @@ var ThreadManager = class {
|
|
|
3977
4203
|
}
|
|
3978
4204
|
/** Set the auto-archive and slowmode defaults copied onto new threads. */
|
|
3979
4205
|
async editDefaults(options) {
|
|
3980
|
-
return this.channel.client.rest.patch(
|
|
4206
|
+
return this.channel.client.rest.patch(import_types19.Routes.channel(this.channel.id), {
|
|
3981
4207
|
body: toThreadParentEditBody(options),
|
|
3982
4208
|
auth: true,
|
|
3983
4209
|
...auditReasonHeaders(options.reason)
|
|
@@ -3995,7 +4221,7 @@ function isSearchNotReady(data) {
|
|
|
3995
4221
|
return "code" in data && data.code === "SEARCH_INDEX_NOT_READY";
|
|
3996
4222
|
}
|
|
3997
4223
|
async function fetchActiveThreads(client, guildId) {
|
|
3998
|
-
const data = await client.rest.get(
|
|
4224
|
+
const data = await client.rest.get(import_types19.Routes.guildActiveThreads(guildId));
|
|
3999
4225
|
return fetchedThreadsFrom(client, data);
|
|
4000
4226
|
}
|
|
4001
4227
|
|
|
@@ -4054,10 +4280,10 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4054
4280
|
* `defaultForumLayout` is sent only for forum channels.
|
|
4055
4281
|
*/
|
|
4056
4282
|
async edit(options) {
|
|
4057
|
-
const data = await this.client.rest.patch(
|
|
4283
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4058
4284
|
body: {
|
|
4059
4285
|
...toChannelEditBody(options),
|
|
4060
|
-
...forumParentWire(options, this.type ===
|
|
4286
|
+
...forumParentWire(options, this.type === import_types20.ChannelType.GuildForum)
|
|
4061
4287
|
},
|
|
4062
4288
|
auth: true,
|
|
4063
4289
|
...auditReasonHeaders(options.reason)
|
|
@@ -4083,7 +4309,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4083
4309
|
}
|
|
4084
4310
|
/** Set the auto-archive and slowmode defaults copied onto new posts. */
|
|
4085
4311
|
async editThreadDefaults(options) {
|
|
4086
|
-
const data = await this.client.rest.patch(
|
|
4312
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4087
4313
|
body: toThreadParentEditBody(options),
|
|
4088
4314
|
auth: true,
|
|
4089
4315
|
...auditReasonHeaders(options.reason)
|
|
@@ -4093,7 +4319,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4093
4319
|
}
|
|
4094
4320
|
/** Create a tag. The response replaces {@link availableTags}. */
|
|
4095
4321
|
async createTag(options) {
|
|
4096
|
-
const data = await this.client.rest.post(
|
|
4322
|
+
const data = await this.client.rest.post(import_types20.Routes.channelTags(this.id), {
|
|
4097
4323
|
body: toForumTagBody(options),
|
|
4098
4324
|
auth: true,
|
|
4099
4325
|
...auditReasonHeaders(options.reason)
|
|
@@ -4103,7 +4329,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4103
4329
|
}
|
|
4104
4330
|
/** Replace a tag. The response replaces {@link availableTags}. */
|
|
4105
4331
|
async editTag(tagId, options) {
|
|
4106
|
-
const data = await this.client.rest.put(
|
|
4332
|
+
const data = await this.client.rest.put(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4107
4333
|
body: toForumTagBody(options),
|
|
4108
4334
|
auth: true,
|
|
4109
4335
|
...auditReasonHeaders(options.reason)
|
|
@@ -4113,7 +4339,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4113
4339
|
}
|
|
4114
4340
|
/** Delete a tag. The response replaces {@link availableTags}. */
|
|
4115
4341
|
async deleteTag(tagId, reason) {
|
|
4116
|
-
const data = await this.client.rest.delete(
|
|
4342
|
+
const data = await this.client.rest.delete(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4117
4343
|
auth: true,
|
|
4118
4344
|
...auditReasonHeaders(reason)
|
|
4119
4345
|
});
|
|
@@ -4142,23 +4368,24 @@ var MediaChannel = class extends ThreadOnlyChannel {
|
|
|
4142
4368
|
};
|
|
4143
4369
|
|
|
4144
4370
|
// src/Domain/Channel/Factory.ts
|
|
4145
|
-
var
|
|
4371
|
+
var import_types21 = require("@fluxerjs/types");
|
|
4146
4372
|
var GUILD_FACTORIES = {
|
|
4147
|
-
[
|
|
4148
|
-
[
|
|
4149
|
-
[
|
|
4150
|
-
[
|
|
4151
|
-
[
|
|
4152
|
-
[
|
|
4153
|
-
[
|
|
4154
|
-
[
|
|
4155
|
-
[
|
|
4156
|
-
[
|
|
4373
|
+
[import_types21.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
|
|
4374
|
+
[import_types21.ChannelType.GuildAnnouncement]: (c, d) => new AnnouncementChannel(c, d),
|
|
4375
|
+
[import_types21.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
|
|
4376
|
+
[import_types21.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
|
|
4377
|
+
[import_types21.ChannelType.GuildStageVoice]: (c, d) => new StageChannel(c, d),
|
|
4378
|
+
[import_types21.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d),
|
|
4379
|
+
[import_types21.ChannelType.AnnouncementThread]: (c, d) => new ThreadChannel(c, d),
|
|
4380
|
+
[import_types21.ChannelType.PublicThread]: (c, d) => new ThreadChannel(c, d),
|
|
4381
|
+
[import_types21.ChannelType.PrivateThread]: (c, d) => new ThreadChannel(c, d),
|
|
4382
|
+
[import_types21.ChannelType.GuildForum]: (c, d) => new ForumChannel(c, d),
|
|
4383
|
+
[import_types21.ChannelType.GuildMedia]: (c, d) => new MediaChannel(c, d)
|
|
4157
4384
|
};
|
|
4158
4385
|
var DM_TYPES = /* @__PURE__ */ new Set([
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4386
|
+
import_types21.ChannelType.DM,
|
|
4387
|
+
import_types21.ChannelType.GroupDM,
|
|
4388
|
+
import_types21.ChannelType.DMPersonalNotes
|
|
4162
4389
|
]);
|
|
4163
4390
|
function createDM(client, data) {
|
|
4164
4391
|
return new DMChannel(client, data);
|
|
@@ -4269,11 +4496,11 @@ var User = class extends Base {
|
|
|
4269
4496
|
*/
|
|
4270
4497
|
/** Unix timestamp (ms) when this account was created, derived from its snowflake ID. */
|
|
4271
4498
|
get createdTimestamp() {
|
|
4272
|
-
return
|
|
4499
|
+
return import_util15.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4273
4500
|
}
|
|
4274
4501
|
/** Date when this account was created, derived from its snowflake ID. */
|
|
4275
4502
|
get createdAt() {
|
|
4276
|
-
return
|
|
4503
|
+
return import_util15.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4277
4504
|
}
|
|
4278
4505
|
toString() {
|
|
4279
4506
|
return `<@${this.id}>`;
|
|
@@ -4283,7 +4510,7 @@ var User = class extends Base {
|
|
|
4283
4510
|
* @returns DM channel instance (cached if already open)
|
|
4284
4511
|
*/
|
|
4285
4512
|
async createDM() {
|
|
4286
|
-
const data = await this.client.rest.post(
|
|
4513
|
+
const data = await this.client.rest.post(import_types22.Routes.userMeChannels(), {
|
|
4287
4514
|
body: { recipient_id: this.id },
|
|
4288
4515
|
auth: true
|
|
4289
4516
|
});
|
|
@@ -4500,14 +4727,14 @@ var CacheController = class {
|
|
|
4500
4727
|
|
|
4501
4728
|
// src/ClientCore/ChannelManager.ts
|
|
4502
4729
|
var import_collection8 = require("@fluxerjs/collection");
|
|
4503
|
-
var
|
|
4730
|
+
var import_types30 = require("@fluxerjs/types");
|
|
4504
4731
|
|
|
4505
4732
|
// src/Domain/Guild/Cache.ts
|
|
4506
|
-
var
|
|
4733
|
+
var import_types29 = require("@fluxerjs/types");
|
|
4507
4734
|
|
|
4508
4735
|
// src/Domain/Guild/GuildEmoji.ts
|
|
4509
|
-
var
|
|
4510
|
-
var
|
|
4736
|
+
var import_types23 = require("@fluxerjs/types");
|
|
4737
|
+
var import_util16 = require("@fluxerjs/util");
|
|
4511
4738
|
var GuildEmoji = class extends Base {
|
|
4512
4739
|
client;
|
|
4513
4740
|
id;
|
|
@@ -4543,11 +4770,11 @@ var GuildEmoji = class extends Base {
|
|
|
4543
4770
|
}
|
|
4544
4771
|
/** Unix timestamp (ms) when this emoji was created, derived from its snowflake ID. */
|
|
4545
4772
|
get createdTimestamp() {
|
|
4546
|
-
return
|
|
4773
|
+
return import_util16.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4547
4774
|
}
|
|
4548
4775
|
/** Date when this emoji was created, derived from its snowflake ID. */
|
|
4549
4776
|
get createdAt() {
|
|
4550
|
-
return
|
|
4777
|
+
return import_util16.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4551
4778
|
}
|
|
4552
4779
|
/** Renders this emoji for use in message content: `<:name:id>` (or `<a:name:id>` when animated). */
|
|
4553
4780
|
toString() {
|
|
@@ -4555,7 +4782,7 @@ var GuildEmoji = class extends Base {
|
|
|
4555
4782
|
}
|
|
4556
4783
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
4557
4784
|
async delete(reason) {
|
|
4558
|
-
await this.client.rest.delete(
|
|
4785
|
+
await this.client.rest.delete(import_types23.Routes.guildEmoji(this.guildId, this.id), {
|
|
4559
4786
|
auth: true,
|
|
4560
4787
|
...auditReasonHeaders(reason)
|
|
4561
4788
|
});
|
|
@@ -4568,7 +4795,7 @@ var GuildEmoji = class extends Base {
|
|
|
4568
4795
|
*/
|
|
4569
4796
|
async edit(options) {
|
|
4570
4797
|
const { reason, name } = options;
|
|
4571
|
-
const data = await this.client.rest.patch(
|
|
4798
|
+
const data = await this.client.rest.patch(import_types23.Routes.guildEmoji(this.guildId, this.id), {
|
|
4572
4799
|
body: { name },
|
|
4573
4800
|
auth: true,
|
|
4574
4801
|
...auditReasonHeaders(reason)
|
|
@@ -4579,20 +4806,20 @@ var GuildEmoji = class extends Base {
|
|
|
4579
4806
|
};
|
|
4580
4807
|
|
|
4581
4808
|
// src/Domain/Guild/GuildMember.ts
|
|
4582
|
-
var
|
|
4583
|
-
var
|
|
4809
|
+
var import_types26 = require("@fluxerjs/types");
|
|
4810
|
+
var import_util18 = require("@fluxerjs/util");
|
|
4584
4811
|
|
|
4585
4812
|
// src/Helpers/Permissions.ts
|
|
4586
|
-
var
|
|
4587
|
-
var
|
|
4813
|
+
var import_types24 = require("@fluxerjs/types");
|
|
4814
|
+
var import_util17 = require("@fluxerjs/util");
|
|
4588
4815
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
4589
|
-
if (isOwner) return
|
|
4590
|
-
if ((basePermissions &
|
|
4591
|
-
return
|
|
4816
|
+
if (isOwner) return import_util17.ALL_PERMISSIONS_BIGINT;
|
|
4817
|
+
if ((basePermissions & import_util17.PermissionFlags.Administrator) !== 0n) {
|
|
4818
|
+
return import_util17.ALL_PERMISSIONS_BIGINT;
|
|
4592
4819
|
}
|
|
4593
4820
|
let perms = basePermissions;
|
|
4594
4821
|
for (const overwrite of overwrites ?? []) {
|
|
4595
|
-
const applies = overwrite.type ===
|
|
4822
|
+
const applies = overwrite.type === import_types24.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types24.OverwriteType.Member && overwrite.id === memberId;
|
|
4596
4823
|
if (!applies) continue;
|
|
4597
4824
|
const allow = BigInt(overwrite.allow || "0");
|
|
4598
4825
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -4603,7 +4830,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
4603
4830
|
|
|
4604
4831
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
4605
4832
|
var import_collection7 = require("@fluxerjs/collection");
|
|
4606
|
-
var
|
|
4833
|
+
var import_types25 = require("@fluxerjs/types");
|
|
4607
4834
|
function roleId(roleOrId) {
|
|
4608
4835
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
4609
4836
|
}
|
|
@@ -4632,7 +4859,7 @@ var GuildMemberRoleManager = class {
|
|
|
4632
4859
|
const id = roleId(roleOrId);
|
|
4633
4860
|
if (this.ids.includes(id)) return;
|
|
4634
4861
|
await this.member.client.rest.put(
|
|
4635
|
-
|
|
4862
|
+
import_types25.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4636
4863
|
);
|
|
4637
4864
|
this.ids.push(id);
|
|
4638
4865
|
}
|
|
@@ -4641,13 +4868,13 @@ var GuildMemberRoleManager = class {
|
|
|
4641
4868
|
const idx = this.ids.indexOf(id);
|
|
4642
4869
|
if (idx === -1) return;
|
|
4643
4870
|
await this.member.client.rest.delete(
|
|
4644
|
-
|
|
4871
|
+
import_types25.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4645
4872
|
);
|
|
4646
4873
|
this.ids.splice(idx, 1);
|
|
4647
4874
|
}
|
|
4648
4875
|
async set(roleIds) {
|
|
4649
4876
|
const data = await this.member.client.rest.patch(
|
|
4650
|
-
|
|
4877
|
+
import_types25.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
4651
4878
|
{ body: { roles: roleIds }, auth: true }
|
|
4652
4879
|
);
|
|
4653
4880
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -4801,7 +5028,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4801
5028
|
*/
|
|
4802
5029
|
async edit(options) {
|
|
4803
5030
|
const isMe = this.client.user?.id === this.id;
|
|
4804
|
-
const route = isMe ?
|
|
5031
|
+
const route = isMe ? import_types26.Routes.guildMemberMe(this.guild.id) : import_types26.Routes.guildMember(this.guild.id, this.id);
|
|
4805
5032
|
const data = await this.client.rest.patch(route, {
|
|
4806
5033
|
body: toMemberEditBody(options),
|
|
4807
5034
|
auth: true,
|
|
@@ -4818,7 +5045,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4818
5045
|
* @see {@link permissionsIn} for channel-specific permissions
|
|
4819
5046
|
*/
|
|
4820
5047
|
get permissions() {
|
|
4821
|
-
return new
|
|
5048
|
+
return new import_util18.PermissionsBitField(this._effectivePermissions([], []));
|
|
4822
5049
|
}
|
|
4823
5050
|
/**
|
|
4824
5051
|
* Effective permissions in a channel (roles + overwrites).
|
|
@@ -4826,7 +5053,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4826
5053
|
* @returns Computed permissions bitfield
|
|
4827
5054
|
*/
|
|
4828
5055
|
permissionsIn(channel) {
|
|
4829
|
-
return new
|
|
5056
|
+
return new import_util18.PermissionsBitField(
|
|
4830
5057
|
this._effectivePermissions(channel.permissionOverwrites.toJSON(), [...this.roles.roleIds])
|
|
4831
5058
|
);
|
|
4832
5059
|
}
|
|
@@ -4851,19 +5078,19 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4851
5078
|
* False for the guild owner, self, or when the bot lacks Kick Members / role hierarchy.
|
|
4852
5079
|
*/
|
|
4853
5080
|
get kickable() {
|
|
4854
|
-
return this._moderatableWith(
|
|
5081
|
+
return this._moderatableWith(import_util18.PermissionFlags.KickMembers);
|
|
4855
5082
|
}
|
|
4856
5083
|
/**
|
|
4857
5084
|
* Whether the bot can ban this member (cache-only; needs `members.me`).
|
|
4858
5085
|
*/
|
|
4859
5086
|
get bannable() {
|
|
4860
|
-
return this._moderatableWith(
|
|
5087
|
+
return this._moderatableWith(import_util18.PermissionFlags.BanMembers);
|
|
4861
5088
|
}
|
|
4862
5089
|
/**
|
|
4863
5090
|
* Whether the bot can timeout this member (cache-only; needs `members.me`).
|
|
4864
5091
|
*/
|
|
4865
5092
|
get moderatable() {
|
|
4866
|
-
return this._moderatableWith(
|
|
5093
|
+
return this._moderatableWith(import_util18.PermissionFlags.ModerateMembers);
|
|
4867
5094
|
}
|
|
4868
5095
|
_moderatableWith(flag) {
|
|
4869
5096
|
const me = this.guild.members.me;
|
|
@@ -4914,8 +5141,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4914
5141
|
};
|
|
4915
5142
|
|
|
4916
5143
|
// src/Domain/Guild/GuildSticker.ts
|
|
4917
|
-
var
|
|
4918
|
-
var
|
|
5144
|
+
var import_types27 = require("@fluxerjs/types");
|
|
5145
|
+
var import_util19 = require("@fluxerjs/util");
|
|
4919
5146
|
var GuildSticker = class extends Base {
|
|
4920
5147
|
client;
|
|
4921
5148
|
id;
|
|
@@ -4957,15 +5184,15 @@ var GuildSticker = class extends Base {
|
|
|
4957
5184
|
}
|
|
4958
5185
|
/** Unix timestamp (ms) when this sticker was created, derived from its snowflake ID. */
|
|
4959
5186
|
get createdTimestamp() {
|
|
4960
|
-
return
|
|
5187
|
+
return import_util19.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4961
5188
|
}
|
|
4962
5189
|
/** Date when this sticker was created, derived from its snowflake ID. */
|
|
4963
5190
|
get createdAt() {
|
|
4964
|
-
return
|
|
5191
|
+
return import_util19.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4965
5192
|
}
|
|
4966
5193
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
4967
5194
|
async delete(reason) {
|
|
4968
|
-
await this.client.rest.delete(
|
|
5195
|
+
await this.client.rest.delete(import_types27.Routes.guildSticker(this.guildId, this.id), {
|
|
4969
5196
|
auth: true,
|
|
4970
5197
|
...auditReasonHeaders(reason)
|
|
4971
5198
|
});
|
|
@@ -4978,7 +5205,7 @@ var GuildSticker = class extends Base {
|
|
|
4978
5205
|
*/
|
|
4979
5206
|
async edit(options) {
|
|
4980
5207
|
const { reason, ...body } = options;
|
|
4981
|
-
const data = await this.client.rest.patch(
|
|
5208
|
+
const data = await this.client.rest.patch(import_types27.Routes.guildSticker(this.guildId, this.id), {
|
|
4982
5209
|
body,
|
|
4983
5210
|
auth: true,
|
|
4984
5211
|
...auditReasonHeaders(reason)
|
|
@@ -4991,8 +5218,8 @@ var GuildSticker = class extends Base {
|
|
|
4991
5218
|
};
|
|
4992
5219
|
|
|
4993
5220
|
// src/Domain/Guild/Role.ts
|
|
4994
|
-
var
|
|
4995
|
-
var
|
|
5221
|
+
var import_types28 = require("@fluxerjs/types");
|
|
5222
|
+
var import_util20 = require("@fluxerjs/util");
|
|
4996
5223
|
var Role = class _Role extends Base {
|
|
4997
5224
|
/** Parent client instance. */
|
|
4998
5225
|
client;
|
|
@@ -5043,8 +5270,8 @@ var Role = class _Role extends Base {
|
|
|
5043
5270
|
} catch {
|
|
5044
5271
|
bits = 0n;
|
|
5045
5272
|
}
|
|
5046
|
-
return new
|
|
5047
|
-
(bits &
|
|
5273
|
+
return new import_util20.PermissionsBitField(
|
|
5274
|
+
(bits & import_util20.PermissionFlags.Administrator) !== 0n ? import_util20.ALL_PERMISSIONS_BIGINT : bits
|
|
5048
5275
|
);
|
|
5049
5276
|
}
|
|
5050
5277
|
/**
|
|
@@ -5061,11 +5288,11 @@ var Role = class _Role extends Base {
|
|
|
5061
5288
|
*/
|
|
5062
5289
|
/** Unix timestamp (ms) when this role was created, derived from its snowflake ID. */
|
|
5063
5290
|
get createdTimestamp() {
|
|
5064
|
-
return
|
|
5291
|
+
return import_util20.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
5065
5292
|
}
|
|
5066
5293
|
/** Date when this role was created, derived from its snowflake ID. */
|
|
5067
5294
|
get createdAt() {
|
|
5068
|
-
return
|
|
5295
|
+
return import_util20.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
5069
5296
|
}
|
|
5070
5297
|
toString() {
|
|
5071
5298
|
return `<@&${this.id}>`;
|
|
@@ -5111,7 +5338,7 @@ var Role = class _Role extends Base {
|
|
|
5111
5338
|
*/
|
|
5112
5339
|
async edit(options) {
|
|
5113
5340
|
const body = toRoleEditBody(options);
|
|
5114
|
-
const data = await this.client.rest.patch(
|
|
5341
|
+
const data = await this.client.rest.patch(import_types28.Routes.guildRole(this.guildId, this.id), {
|
|
5115
5342
|
body: Object.keys(body).length ? body : void 0,
|
|
5116
5343
|
auth: true,
|
|
5117
5344
|
...auditReasonHeaders(options.reason)
|
|
@@ -5124,7 +5351,7 @@ var Role = class _Role extends Base {
|
|
|
5124
5351
|
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
5125
5352
|
*/
|
|
5126
5353
|
async delete(reason) {
|
|
5127
|
-
await this.client.rest.delete(
|
|
5354
|
+
await this.client.rest.delete(import_types28.Routes.guildRole(this.guildId, this.id), {
|
|
5128
5355
|
auth: true,
|
|
5129
5356
|
...auditReasonHeaders(reason)
|
|
5130
5357
|
});
|
|
@@ -5225,7 +5452,7 @@ function syncChannels(guild, channels) {
|
|
|
5225
5452
|
}
|
|
5226
5453
|
}
|
|
5227
5454
|
function isThreadChannelType(type) {
|
|
5228
|
-
return type ===
|
|
5455
|
+
return type === import_types29.ChannelType.AnnouncementThread || type === import_types29.ChannelType.PublicThread || type === import_types29.ChannelType.PrivateThread;
|
|
5229
5456
|
}
|
|
5230
5457
|
function syncThreads(guild, threads, alsoKeep = /* @__PURE__ */ new Set()) {
|
|
5231
5458
|
const keep = new Set(alsoKeep);
|
|
@@ -5314,7 +5541,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5314
5541
|
async fetchFresh(channelId) {
|
|
5315
5542
|
try {
|
|
5316
5543
|
const data = assertApiObjectWithId(
|
|
5317
|
-
await this.client.rest.get(
|
|
5544
|
+
await this.client.rest.get(import_types30.Routes.channel(channelId)),
|
|
5318
5545
|
"channels.fetch()"
|
|
5319
5546
|
);
|
|
5320
5547
|
const existing = this.get(channelId);
|
|
@@ -5367,7 +5594,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5367
5594
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
5368
5595
|
});
|
|
5369
5596
|
const data = await this.client.rest.post(
|
|
5370
|
-
|
|
5597
|
+
import_types30.Routes.channelMessages(channelId),
|
|
5371
5598
|
postPayload
|
|
5372
5599
|
);
|
|
5373
5600
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -5377,28 +5604,28 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5377
5604
|
|
|
5378
5605
|
// src/ClientCore/ClientEmoji.ts
|
|
5379
5606
|
var import_collection9 = require("@fluxerjs/collection");
|
|
5380
|
-
var
|
|
5381
|
-
var
|
|
5607
|
+
var import_types31 = require("@fluxerjs/types");
|
|
5608
|
+
var import_util21 = require("@fluxerjs/util");
|
|
5382
5609
|
async function resolveClientEmoji(client, emoji, guildId) {
|
|
5383
5610
|
if (typeof emoji === "object" && emoji.id) {
|
|
5384
|
-
return (0,
|
|
5611
|
+
return (0, import_util21.formatEmoji)({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
5385
5612
|
}
|
|
5386
|
-
const parsed = (0,
|
|
5613
|
+
const parsed = (0, import_util21.parseEmoji)(
|
|
5387
5614
|
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
5388
5615
|
);
|
|
5389
5616
|
if (!parsed) {
|
|
5390
5617
|
throw new import_util4.FluxerError("Invalid emoji", { code: import_util3.ErrorCodes.InvalidEmoji });
|
|
5391
5618
|
}
|
|
5392
5619
|
if (parsed.id) {
|
|
5393
|
-
return (0,
|
|
5620
|
+
return (0, import_util21.formatEmoji)(parsed);
|
|
5394
5621
|
}
|
|
5395
5622
|
if (!/^\w+$/.test(parsed.name)) return parsed.name;
|
|
5396
|
-
const unicodeFromShortcode = (0,
|
|
5623
|
+
const unicodeFromShortcode = (0, import_util21.getUnicodeFromShortcode)(parsed.name);
|
|
5397
5624
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
5398
5625
|
if (guildId) {
|
|
5399
|
-
const emojis = await client.rest.get(
|
|
5626
|
+
const emojis = await client.rest.get(import_types31.Routes.guildEmojis(guildId));
|
|
5400
5627
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
5401
|
-
if (found) return (0,
|
|
5628
|
+
if (found) return (0, import_util21.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
5402
5629
|
throw new import_util4.FluxerError(
|
|
5403
5630
|
`Custom emoji ":${parsed.name}:" not found in guild. Use name:id or <:name:id> format.`,
|
|
5404
5631
|
{ code: import_util3.ErrorCodes.EmojiNotFound }
|
|
@@ -5413,26 +5640,26 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
5413
5640
|
return parsed.name;
|
|
5414
5641
|
}
|
|
5415
5642
|
async function fetchInstance(client) {
|
|
5416
|
-
const raw = await client.rest.get(
|
|
5643
|
+
const raw = await client.rest.get(import_types31.Routes.instanceDiscovery(), {
|
|
5417
5644
|
auth: false,
|
|
5418
5645
|
unversioned: true
|
|
5419
5646
|
});
|
|
5420
5647
|
return parseInstanceDiscovery(raw);
|
|
5421
5648
|
}
|
|
5422
5649
|
function fetchGatewayInfo(client) {
|
|
5423
|
-
return client.rest.get(
|
|
5650
|
+
return client.rest.get(import_types31.Routes.gatewayBot());
|
|
5424
5651
|
}
|
|
5425
5652
|
function fetchEmojiMetadata(client, emojiId) {
|
|
5426
|
-
return client.rest.get(
|
|
5653
|
+
return client.rest.get(import_types31.Routes.emojiMetadata(emojiId), { auth: true });
|
|
5427
5654
|
}
|
|
5428
5655
|
function fetchStickerMetadata(client, stickerId) {
|
|
5429
|
-
return client.rest.get(
|
|
5656
|
+
return client.rest.get(import_types31.Routes.stickerMetadata(stickerId), { auth: true });
|
|
5430
5657
|
}
|
|
5431
5658
|
function fetchApplication(client) {
|
|
5432
|
-
return client.rest.get(
|
|
5659
|
+
return client.rest.get(import_types31.Routes.applicationsMe(), { auth: true });
|
|
5433
5660
|
}
|
|
5434
5661
|
async function fetchOAuthApplications(client) {
|
|
5435
|
-
const data = await client.rest.get(
|
|
5662
|
+
const data = await client.rest.get(import_types31.Routes.oauth2ApplicationsMe(), { auth: true });
|
|
5436
5663
|
if (Array.isArray(data)) return data;
|
|
5437
5664
|
if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
|
|
5438
5665
|
return data.applications;
|
|
@@ -5451,14 +5678,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
5451
5678
|
}
|
|
5452
5679
|
function preloadMessages(client, channelIds) {
|
|
5453
5680
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
5454
|
-
return client.rest.post(
|
|
5681
|
+
return client.rest.post(import_types31.Routes.preloadMessages(), {
|
|
5455
5682
|
body: { channels: channelIds },
|
|
5456
5683
|
auth: true
|
|
5457
5684
|
});
|
|
5458
5685
|
}
|
|
5459
5686
|
function preloadMessagesAlt(client, channelIds) {
|
|
5460
5687
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
5461
|
-
return client.rest.post(
|
|
5688
|
+
return client.rest.post(import_types31.Routes.preloadMessagesAlt(), {
|
|
5462
5689
|
body: { channels: channelIds },
|
|
5463
5690
|
auth: true
|
|
5464
5691
|
});
|
|
@@ -5466,7 +5693,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
5466
5693
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
5467
5694
|
validateBulkMessageFetchRequests(requests);
|
|
5468
5695
|
const wire = toBulkFetchWire(requests);
|
|
5469
|
-
const data = await client.rest.post(
|
|
5696
|
+
const data = await client.rest.post(import_types31.Routes.channelsMessagesBulk(), {
|
|
5470
5697
|
body: { requests: wire },
|
|
5471
5698
|
auth: true
|
|
5472
5699
|
});
|
|
@@ -5483,7 +5710,7 @@ async function bulkFetchMessages(client, requests, options = {}) {
|
|
|
5483
5710
|
};
|
|
5484
5711
|
}
|
|
5485
5712
|
async function searchMessages(client, options = {}) {
|
|
5486
|
-
const data = await client.rest.post(
|
|
5713
|
+
const data = await client.rest.post(import_types31.Routes.searchMessages(), {
|
|
5487
5714
|
body: toMessageSearchBody(options),
|
|
5488
5715
|
auth: true
|
|
5489
5716
|
});
|
|
@@ -5491,19 +5718,19 @@ async function searchMessages(client, options = {}) {
|
|
|
5491
5718
|
}
|
|
5492
5719
|
function fetchEmojiSource(client, emojiId) {
|
|
5493
5720
|
return client.rest.get(
|
|
5494
|
-
|
|
5721
|
+
import_types31.Routes.emojiSource(emojiId),
|
|
5495
5722
|
{ auth: true }
|
|
5496
5723
|
);
|
|
5497
5724
|
}
|
|
5498
5725
|
function fetchStickerSource(client, stickerId) {
|
|
5499
5726
|
return client.rest.get(
|
|
5500
|
-
|
|
5727
|
+
import_types31.Routes.stickerSource(stickerId),
|
|
5501
5728
|
{ auth: true }
|
|
5502
5729
|
);
|
|
5503
5730
|
}
|
|
5504
5731
|
function fetchDiscoveryCategories(client) {
|
|
5505
5732
|
return client.rest.get(
|
|
5506
|
-
|
|
5733
|
+
import_types31.Routes.discoveryCategories(),
|
|
5507
5734
|
{ auth: true }
|
|
5508
5735
|
);
|
|
5509
5736
|
}
|
|
@@ -5518,18 +5745,18 @@ function searchDiscoveryGuilds(client, options = {}) {
|
|
|
5518
5745
|
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
5519
5746
|
const qs2 = params.toString();
|
|
5520
5747
|
return client.rest.get(
|
|
5521
|
-
qs2 ? `${
|
|
5748
|
+
qs2 ? `${import_types31.Routes.discoveryGuilds()}?${qs2}` : import_types31.Routes.discoveryGuilds(),
|
|
5522
5749
|
{ auth: true }
|
|
5523
5750
|
);
|
|
5524
5751
|
}
|
|
5525
5752
|
function fetchExperiments(client) {
|
|
5526
|
-
return client.rest.get(
|
|
5753
|
+
return client.rest.get(import_types31.Routes.experiments(), {
|
|
5527
5754
|
auth: true
|
|
5528
5755
|
});
|
|
5529
5756
|
}
|
|
5530
5757
|
function refreshAttachmentUrls(client, attachmentUrls) {
|
|
5531
5758
|
return client.rest.post(
|
|
5532
|
-
|
|
5759
|
+
import_types31.Routes.attachmentsRefreshUrls(),
|
|
5533
5760
|
{ body: { attachment_urls: attachmentUrls }, auth: true }
|
|
5534
5761
|
);
|
|
5535
5762
|
}
|
|
@@ -5541,13 +5768,13 @@ function fetchInstanceBadges(client, options = {}) {
|
|
|
5541
5768
|
if (options.version !== void 0) params.set("version", options.version);
|
|
5542
5769
|
const qs2 = params.toString();
|
|
5543
5770
|
return client.rest.get(
|
|
5544
|
-
qs2 ? `${
|
|
5771
|
+
qs2 ? `${import_types31.Routes.instanceBadges()}?${qs2}` : import_types31.Routes.instanceBadges(),
|
|
5545
5772
|
{ auth: false }
|
|
5546
5773
|
);
|
|
5547
5774
|
}
|
|
5548
5775
|
function fetchChannelPostData(client, channelId, threadIds) {
|
|
5549
5776
|
return client.rest.post(
|
|
5550
|
-
|
|
5777
|
+
import_types31.Routes.channelPostData(channelId),
|
|
5551
5778
|
{ body: { thread_ids: threadIds }, auth: true }
|
|
5552
5779
|
);
|
|
5553
5780
|
}
|
|
@@ -5570,12 +5797,12 @@ var import_ws = require("@fluxerjs/ws");
|
|
|
5570
5797
|
|
|
5571
5798
|
// src/Domain/Guild/Guild.ts
|
|
5572
5799
|
var import_collection12 = require("@fluxerjs/collection");
|
|
5573
|
-
var
|
|
5574
|
-
var
|
|
5800
|
+
var import_types41 = require("@fluxerjs/types");
|
|
5801
|
+
var import_util23 = require("@fluxerjs/util");
|
|
5575
5802
|
|
|
5576
5803
|
// src/ClientCore/GuildMemberManager.ts
|
|
5577
5804
|
var import_collection10 = require("@fluxerjs/collection");
|
|
5578
|
-
var
|
|
5805
|
+
var import_types32 = require("@fluxerjs/types");
|
|
5579
5806
|
var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
5580
5807
|
constructor(guild) {
|
|
5581
5808
|
super({ maxSize: guild.client.cache.limits.members });
|
|
@@ -5636,7 +5863,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5636
5863
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
5637
5864
|
if (options?.after) params.set("after", options.after);
|
|
5638
5865
|
const qs2 = params.toString();
|
|
5639
|
-
const url =
|
|
5866
|
+
const url = import_types32.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
5640
5867
|
const data = assertApiArray(
|
|
5641
5868
|
await this.guild.client.rest.get(url, { auth: true }),
|
|
5642
5869
|
"members.fetch()"
|
|
@@ -5663,7 +5890,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5663
5890
|
*/
|
|
5664
5891
|
async search(options = {}) {
|
|
5665
5892
|
const data = await this.guild.client.rest.post(
|
|
5666
|
-
|
|
5893
|
+
import_types32.Routes.guildMembersSearch(this.guild.id),
|
|
5667
5894
|
{ body: toMemberSearchBody(options), auth: true }
|
|
5668
5895
|
);
|
|
5669
5896
|
const offset = options.offset ?? 0;
|
|
@@ -5689,7 +5916,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5689
5916
|
};
|
|
5690
5917
|
|
|
5691
5918
|
// src/Domain/Guild/Admin.ts
|
|
5692
|
-
var
|
|
5919
|
+
var import_types33 = require("@fluxerjs/types");
|
|
5693
5920
|
function toAuditLogEntryPayload(entry, guildId) {
|
|
5694
5921
|
return {
|
|
5695
5922
|
id: entry.id,
|
|
@@ -5710,7 +5937,7 @@ function toVanityPayload(data) {
|
|
|
5710
5937
|
return { code: data.code ?? null, uses: data.uses };
|
|
5711
5938
|
}
|
|
5712
5939
|
async function fetchAuditLogs(guild, options) {
|
|
5713
|
-
const url =
|
|
5940
|
+
const url = import_types33.Routes.guildAuditLogs(guild.id) + qs({
|
|
5714
5941
|
limit: options?.limit,
|
|
5715
5942
|
before: options?.before,
|
|
5716
5943
|
after: options?.after,
|
|
@@ -5734,7 +5961,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
5734
5961
|
};
|
|
5735
5962
|
}
|
|
5736
5963
|
async function editGuild(guild, options) {
|
|
5737
|
-
const data = await guild.client.rest.patch(
|
|
5964
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guild(guild.id), {
|
|
5738
5965
|
body: toGuildEditBody(options),
|
|
5739
5966
|
auth: true
|
|
5740
5967
|
});
|
|
@@ -5742,13 +5969,13 @@ async function editGuild(guild, options) {
|
|
|
5742
5969
|
return guild;
|
|
5743
5970
|
}
|
|
5744
5971
|
async function fetchVanityURL(guild) {
|
|
5745
|
-
const data = await guild.client.rest.get(
|
|
5972
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5746
5973
|
auth: true
|
|
5747
5974
|
});
|
|
5748
5975
|
return toVanityPayload(data);
|
|
5749
5976
|
}
|
|
5750
5977
|
async function editVanityURL(guild, code) {
|
|
5751
|
-
const data = await guild.client.rest.patch(
|
|
5978
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5752
5979
|
body: { code },
|
|
5753
5980
|
auth: true
|
|
5754
5981
|
});
|
|
@@ -5756,14 +5983,14 @@ async function editVanityURL(guild, code) {
|
|
|
5756
5983
|
return toVanityPayload(data);
|
|
5757
5984
|
}
|
|
5758
5985
|
async function fetchDiscoveryStatus(guild) {
|
|
5759
|
-
const data = await guild.client.rest.get(
|
|
5986
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildDiscovery(guild.id), {
|
|
5760
5987
|
auth: true
|
|
5761
5988
|
});
|
|
5762
5989
|
return toDiscoveryStatusPayload(data);
|
|
5763
5990
|
}
|
|
5764
5991
|
async function applyForDiscovery(guild, options) {
|
|
5765
5992
|
const data = await guild.client.rest.post(
|
|
5766
|
-
|
|
5993
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5767
5994
|
{
|
|
5768
5995
|
body: toDiscoveryBody(options),
|
|
5769
5996
|
auth: true
|
|
@@ -5773,7 +6000,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
5773
6000
|
}
|
|
5774
6001
|
async function editDiscoveryApplication(guild, options) {
|
|
5775
6002
|
const data = await guild.client.rest.patch(
|
|
5776
|
-
|
|
6003
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5777
6004
|
{
|
|
5778
6005
|
body: toDiscoveryBody(options),
|
|
5779
6006
|
auth: true
|
|
@@ -5782,34 +6009,34 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
5782
6009
|
return toDiscoveryApplicationPayload(data);
|
|
5783
6010
|
}
|
|
5784
6011
|
async function withdrawDiscoveryApplication(guild) {
|
|
5785
|
-
await guild.client.rest.delete(
|
|
6012
|
+
await guild.client.rest.delete(import_types33.Routes.guildDiscovery(guild.id), { auth: true });
|
|
5786
6013
|
}
|
|
5787
6014
|
async function deleteGuild(guild, options) {
|
|
5788
6015
|
const body = options ? toSudoBody(options) : {};
|
|
5789
|
-
await guild.client.rest.post(
|
|
6016
|
+
await guild.client.rest.post(import_types33.Routes.guildDelete(guild.id), {
|
|
5790
6017
|
body,
|
|
5791
6018
|
auth: true
|
|
5792
6019
|
});
|
|
5793
6020
|
guild.client.guilds.delete(guild.id);
|
|
5794
6021
|
}
|
|
5795
6022
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
5796
|
-
await guild.client.rest.post(
|
|
6023
|
+
await guild.client.rest.post(import_types33.Routes.guildTransferOwnership(guild.id), {
|
|
5797
6024
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
5798
6025
|
auth: true
|
|
5799
6026
|
});
|
|
5800
6027
|
}
|
|
5801
6028
|
|
|
5802
6029
|
// src/Domain/Guild/Channels.ts
|
|
5803
|
-
var
|
|
6030
|
+
var import_types34 = require("@fluxerjs/types");
|
|
5804
6031
|
async function createChannel(guild, options) {
|
|
5805
|
-
const created = await guild.client.rest.post(
|
|
6032
|
+
const created = await guild.client.rest.post(import_types34.Routes.guildChannels(guild.id), {
|
|
5806
6033
|
body: toChannelCreateBody(options),
|
|
5807
6034
|
auth: true
|
|
5808
6035
|
});
|
|
5809
6036
|
return cacheChannel(guild, created);
|
|
5810
6037
|
}
|
|
5811
6038
|
async function fetchChannels(guild) {
|
|
5812
|
-
const raw = await guild.client.rest.get(
|
|
6039
|
+
const raw = await guild.client.rest.get(import_types34.Routes.guildChannels(guild.id));
|
|
5813
6040
|
if (!Array.isArray(raw))
|
|
5814
6041
|
throw new TypeError(
|
|
5815
6042
|
"guild.fetchChannels() received an invalid API payload (expected an array)"
|
|
@@ -5823,17 +6050,17 @@ async function fetchChannels(guild) {
|
|
|
5823
6050
|
return channels;
|
|
5824
6051
|
}
|
|
5825
6052
|
async function setChannelPositions(guild, updates) {
|
|
5826
|
-
await guild.client.rest.patch(
|
|
6053
|
+
await guild.client.rest.patch(import_types34.Routes.guildChannels(guild.id), {
|
|
5827
6054
|
body: toChannelPositionBody(updates),
|
|
5828
6055
|
auth: true
|
|
5829
6056
|
});
|
|
5830
6057
|
}
|
|
5831
6058
|
async function fetchWebhooks(guild) {
|
|
5832
|
-
const data = await guild.client.rest.get(
|
|
6059
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildWebhooks(guild.id));
|
|
5833
6060
|
return data.map((w) => new Webhook(guild.client, w));
|
|
5834
6061
|
}
|
|
5835
6062
|
async function fetchInvites(guild) {
|
|
5836
|
-
const data = await guild.client.rest.get(
|
|
6063
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildInvites(guild.id));
|
|
5837
6064
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
5838
6065
|
}
|
|
5839
6066
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -5853,14 +6080,14 @@ function resolveGuildOnlineCount(data) {
|
|
|
5853
6080
|
}
|
|
5854
6081
|
|
|
5855
6082
|
// src/Domain/Guild/Emojis.ts
|
|
5856
|
-
var
|
|
6083
|
+
var import_types35 = require("@fluxerjs/types");
|
|
5857
6084
|
async function fetchEmojis(guild) {
|
|
5858
|
-
const data = await guild.client.rest.get(
|
|
6085
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmojis(guild.id));
|
|
5859
6086
|
return data.map((e) => cacheEmoji(guild, e));
|
|
5860
6087
|
}
|
|
5861
6088
|
async function fetchEmoji(guild, emojiId) {
|
|
5862
6089
|
try {
|
|
5863
|
-
const data = await guild.client.rest.get(
|
|
6090
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmoji(guild.id, emojiId));
|
|
5864
6091
|
return cacheEmoji(guild, data);
|
|
5865
6092
|
} catch (err) {
|
|
5866
6093
|
rethrowMapped(err, {
|
|
@@ -5871,7 +6098,7 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
5871
6098
|
}
|
|
5872
6099
|
async function createEmoji(guild, options) {
|
|
5873
6100
|
const { reason, ...body } = options;
|
|
5874
|
-
const data = await guild.client.rest.post(
|
|
6101
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojis(guild.id), {
|
|
5875
6102
|
body,
|
|
5876
6103
|
auth: true,
|
|
5877
6104
|
...auditReasonHeaders(reason)
|
|
@@ -5879,7 +6106,7 @@ async function createEmoji(guild, options) {
|
|
|
5879
6106
|
return cacheEmoji(guild, data);
|
|
5880
6107
|
}
|
|
5881
6108
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
5882
|
-
const data = await guild.client.rest.post(
|
|
6109
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojisClone(guild.id), {
|
|
5883
6110
|
body: { source_emoji_id: sourceEmojiId },
|
|
5884
6111
|
auth: true
|
|
5885
6112
|
});
|
|
@@ -5887,7 +6114,7 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
5887
6114
|
}
|
|
5888
6115
|
async function createEmojisBulk(guild, emojis) {
|
|
5889
6116
|
const data = await guild.client.rest.post(
|
|
5890
|
-
|
|
6117
|
+
import_types35.Routes.guildEmojisBulk(guild.id),
|
|
5891
6118
|
{ body: { emojis }, auth: true }
|
|
5892
6119
|
);
|
|
5893
6120
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
@@ -5907,12 +6134,12 @@ var GuildRoleManager = class extends import_collection11.LimitedCollection {
|
|
|
5907
6134
|
};
|
|
5908
6135
|
|
|
5909
6136
|
// src/Domain/Guild/MemberHttp.ts
|
|
5910
|
-
var
|
|
6137
|
+
var import_types36 = require("@fluxerjs/types");
|
|
5911
6138
|
async function fetchMember(guild, userId) {
|
|
5912
6139
|
const id = normalizeSnowflakeId(userId, "members.fetch()");
|
|
5913
6140
|
try {
|
|
5914
6141
|
const data = await guild.client.rest.get(
|
|
5915
|
-
|
|
6142
|
+
import_types36.Routes.guildMember(guild.id, id)
|
|
5916
6143
|
);
|
|
5917
6144
|
if (!data?.user?.id) {
|
|
5918
6145
|
throw new TypeError("members.fetch() received an invalid API payload (missing user.id)");
|
|
@@ -5930,7 +6157,7 @@ async function fetchMember(guild, userId) {
|
|
|
5930
6157
|
}
|
|
5931
6158
|
async function fetchMe(guild) {
|
|
5932
6159
|
const data = await guild.client.rest.get(
|
|
5933
|
-
|
|
6160
|
+
import_types36.Routes.guildMemberMe(guild.id),
|
|
5934
6161
|
{ auth: true }
|
|
5935
6162
|
);
|
|
5936
6163
|
if (!data?.user?.id) {
|
|
@@ -5940,10 +6167,10 @@ async function fetchMe(guild) {
|
|
|
5940
6167
|
}
|
|
5941
6168
|
|
|
5942
6169
|
// src/Domain/Guild/Moderation.ts
|
|
5943
|
-
var
|
|
6170
|
+
var import_types38 = require("@fluxerjs/types");
|
|
5944
6171
|
|
|
5945
6172
|
// src/Domain/Guild/GuildBan.ts
|
|
5946
|
-
var
|
|
6173
|
+
var import_types37 = require("@fluxerjs/types");
|
|
5947
6174
|
function parseOptionalDate2(value) {
|
|
5948
6175
|
if (value == null || value === "") return null;
|
|
5949
6176
|
const date = new Date(value);
|
|
@@ -5970,7 +6197,7 @@ var GuildBan = class extends Base {
|
|
|
5970
6197
|
* Requires Ban Members permission.
|
|
5971
6198
|
*/
|
|
5972
6199
|
async unban(reason) {
|
|
5973
|
-
await this.client.rest.delete(
|
|
6200
|
+
await this.client.rest.delete(import_types37.Routes.guildBan(this.guildId, this.user.id), {
|
|
5974
6201
|
auth: true,
|
|
5975
6202
|
...auditReasonHeaders(reason)
|
|
5976
6203
|
});
|
|
@@ -5980,39 +6207,39 @@ var GuildBan = class extends Base {
|
|
|
5980
6207
|
// src/Domain/Guild/Moderation.ts
|
|
5981
6208
|
async function ban(guild, userId, options) {
|
|
5982
6209
|
const body = options ? toGuildBanBody(options) : {};
|
|
5983
|
-
await guild.client.rest.put(
|
|
6210
|
+
await guild.client.rest.put(import_types38.Routes.guildBan(guild.id, userId), {
|
|
5984
6211
|
body: Object.keys(body).length ? body : void 0,
|
|
5985
6212
|
auth: true,
|
|
5986
6213
|
...auditReasonHeaders(options?.reason)
|
|
5987
6214
|
});
|
|
5988
6215
|
}
|
|
5989
6216
|
async function fetchBan(guild, userId) {
|
|
5990
|
-
const data = await guild.client.rest.get(
|
|
6217
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBan(guild.id, userId));
|
|
5991
6218
|
return new GuildBan(guild.client, { ...data, guild_id: guild.id }, guild.id);
|
|
5992
6219
|
}
|
|
5993
6220
|
async function fetchBans(guild) {
|
|
5994
|
-
const data = await guild.client.rest.get(
|
|
6221
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBans(guild.id));
|
|
5995
6222
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
5996
6223
|
}
|
|
5997
6224
|
async function unban(guild, userId, reason) {
|
|
5998
|
-
await guild.client.rest.delete(
|
|
6225
|
+
await guild.client.rest.delete(import_types38.Routes.guildBan(guild.id, userId), {
|
|
5999
6226
|
auth: true,
|
|
6000
6227
|
...auditReasonHeaders(reason)
|
|
6001
6228
|
});
|
|
6002
6229
|
}
|
|
6003
6230
|
async function kick(guild, userId, reason) {
|
|
6004
|
-
await guild.client.rest.delete(
|
|
6231
|
+
await guild.client.rest.delete(import_types38.Routes.guildMember(guild.id, userId), {
|
|
6005
6232
|
auth: true,
|
|
6006
6233
|
...auditReasonHeaders(reason)
|
|
6007
6234
|
});
|
|
6008
6235
|
}
|
|
6009
6236
|
|
|
6010
6237
|
// src/Domain/Guild/Roles.ts
|
|
6011
|
-
var
|
|
6012
|
-
var
|
|
6238
|
+
var import_types39 = require("@fluxerjs/types");
|
|
6239
|
+
var import_util22 = require("@fluxerjs/util");
|
|
6013
6240
|
async function createRole(guild, options = {}) {
|
|
6014
6241
|
const body = toRoleCreateBody(options);
|
|
6015
|
-
const data = await guild.client.rest.post(
|
|
6242
|
+
const data = await guild.client.rest.post(import_types39.Routes.guildRoles(guild.id), {
|
|
6016
6243
|
body: Object.keys(body).length ? body : void 0,
|
|
6017
6244
|
auth: true,
|
|
6018
6245
|
...auditReasonHeaders(options.reason)
|
|
@@ -6020,14 +6247,14 @@ async function createRole(guild, options = {}) {
|
|
|
6020
6247
|
return cacheRole(guild, data);
|
|
6021
6248
|
}
|
|
6022
6249
|
async function fetchRoles(guild) {
|
|
6023
|
-
const data = await guild.client.rest.get(
|
|
6250
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
6024
6251
|
if (!Array.isArray(data))
|
|
6025
6252
|
throw new TypeError("guild.fetchRoles() received an invalid API payload (expected an array)");
|
|
6026
6253
|
return data.map((r) => cacheRole(guild, r));
|
|
6027
6254
|
}
|
|
6028
6255
|
async function fetchRole(guild, roleId2) {
|
|
6029
6256
|
try {
|
|
6030
|
-
const data = await guild.client.rest.get(
|
|
6257
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRole(guild.id, roleId2));
|
|
6031
6258
|
return cacheRole(guild, data);
|
|
6032
6259
|
} catch (err) {
|
|
6033
6260
|
rethrowMapped(err, {
|
|
@@ -6037,14 +6264,14 @@ async function fetchRole(guild, roleId2) {
|
|
|
6037
6264
|
}
|
|
6038
6265
|
}
|
|
6039
6266
|
async function resolveRoleId(guild, arg) {
|
|
6040
|
-
const parsed = (0,
|
|
6267
|
+
const parsed = (0, import_util22.parseRoleMention)(arg);
|
|
6041
6268
|
if (parsed) return parsed;
|
|
6042
6269
|
const trimmed = arg.trim();
|
|
6043
6270
|
if (/^\d{17,19}$/.test(trimmed)) return trimmed;
|
|
6044
6271
|
const needle = trimmed.toLowerCase();
|
|
6045
6272
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
6046
6273
|
if (cached) return cached.id;
|
|
6047
|
-
const roles = await guild.client.rest.get(
|
|
6274
|
+
const roles = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
6048
6275
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
6049
6276
|
if (!role) return null;
|
|
6050
6277
|
cacheRole(guild, role);
|
|
@@ -6053,7 +6280,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
6053
6280
|
async function setRolePositions(guild, updates) {
|
|
6054
6281
|
return replaceRoles(
|
|
6055
6282
|
guild,
|
|
6056
|
-
await guild.client.rest.patch(
|
|
6283
|
+
await guild.client.rest.patch(import_types39.Routes.guildRoles(guild.id), {
|
|
6057
6284
|
body: updates,
|
|
6058
6285
|
auth: true
|
|
6059
6286
|
})
|
|
@@ -6062,7 +6289,7 @@ async function setRolePositions(guild, updates) {
|
|
|
6062
6289
|
async function setRoleHoistPositions(guild, updates) {
|
|
6063
6290
|
return replaceRoles(
|
|
6064
6291
|
guild,
|
|
6065
|
-
await guild.client.rest.patch(
|
|
6292
|
+
await guild.client.rest.patch(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
6066
6293
|
body: updates.map((u) => ({
|
|
6067
6294
|
id: u.id,
|
|
6068
6295
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -6074,17 +6301,17 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
6074
6301
|
async function resetRoleHoistPositions(guild) {
|
|
6075
6302
|
return replaceRoles(
|
|
6076
6303
|
guild,
|
|
6077
|
-
await guild.client.rest.delete(
|
|
6304
|
+
await guild.client.rest.delete(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
6078
6305
|
auth: true
|
|
6079
6306
|
})
|
|
6080
6307
|
);
|
|
6081
6308
|
}
|
|
6082
6309
|
|
|
6083
6310
|
// src/Domain/Guild/Stickers.ts
|
|
6084
|
-
var
|
|
6311
|
+
var import_types40 = require("@fluxerjs/types");
|
|
6085
6312
|
async function createSticker(guild, options) {
|
|
6086
6313
|
const { reason, ...body } = options;
|
|
6087
|
-
const data = await guild.client.rest.post(
|
|
6314
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickers(guild.id), {
|
|
6088
6315
|
body,
|
|
6089
6316
|
auth: true,
|
|
6090
6317
|
...auditReasonHeaders(reason)
|
|
@@ -6092,7 +6319,7 @@ async function createSticker(guild, options) {
|
|
|
6092
6319
|
return cacheSticker(guild, data);
|
|
6093
6320
|
}
|
|
6094
6321
|
async function cloneSticker(guild, sourceStickerId) {
|
|
6095
|
-
const data = await guild.client.rest.post(
|
|
6322
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickersClone(guild.id), {
|
|
6096
6323
|
body: { source_sticker_id: sourceStickerId },
|
|
6097
6324
|
auth: true
|
|
6098
6325
|
});
|
|
@@ -6100,17 +6327,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
6100
6327
|
}
|
|
6101
6328
|
async function createStickersBulk(guild, stickers) {
|
|
6102
6329
|
const data = await guild.client.rest.post(
|
|
6103
|
-
|
|
6330
|
+
import_types40.Routes.guildStickersBulk(guild.id),
|
|
6104
6331
|
{ body: { stickers }, auth: true }
|
|
6105
6332
|
);
|
|
6106
6333
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
6107
6334
|
}
|
|
6108
6335
|
async function fetchStickers(guild) {
|
|
6109
|
-
const data = await guild.client.rest.get(
|
|
6336
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildStickers(guild.id));
|
|
6110
6337
|
return data.map((s) => cacheSticker(guild, s));
|
|
6111
6338
|
}
|
|
6112
6339
|
async function fetchSticker(guild, stickerId) {
|
|
6113
|
-
const data = await guild.client.rest.get(
|
|
6340
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildSticker(guild.id, stickerId));
|
|
6114
6341
|
return cacheSticker(guild, data);
|
|
6115
6342
|
}
|
|
6116
6343
|
|
|
@@ -6199,6 +6426,10 @@ var Guild = class extends Base {
|
|
|
6199
6426
|
emojis;
|
|
6200
6427
|
/** Cached stickers in this guild. */
|
|
6201
6428
|
stickers;
|
|
6429
|
+
/** Live stages in this guild's stage channels, keyed by stage instance ID. */
|
|
6430
|
+
stageInstances;
|
|
6431
|
+
/** Most participants a stage can have while speakers use video, or null if unknown. */
|
|
6432
|
+
maxStageVideoChannelUsers;
|
|
6202
6433
|
/**
|
|
6203
6434
|
* Construct a guild from API data.
|
|
6204
6435
|
* @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE
|
|
@@ -6215,6 +6446,7 @@ var Guild = class extends Base {
|
|
|
6215
6446
|
this.roles = new GuildRoleManager(this.id, { maxSize: client.cache.limits.roles });
|
|
6216
6447
|
this.emojis = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.emojis });
|
|
6217
6448
|
this.stickers = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.stickers });
|
|
6449
|
+
this.stageInstances = new import_collection12.Collection();
|
|
6218
6450
|
this.name = data.name ?? "";
|
|
6219
6451
|
this.icon = data.icon ?? null;
|
|
6220
6452
|
this.banner = data.banner ?? null;
|
|
@@ -6232,7 +6464,7 @@ var Guild = class extends Base {
|
|
|
6232
6464
|
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
6233
6465
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6234
6466
|
this.embedSplash = data.embed_splash ?? null;
|
|
6235
|
-
this.nsfwLevel = data.nsfw_level ??
|
|
6467
|
+
this.nsfwLevel = data.nsfw_level ?? import_types41.GuildNSFWLevel.Safe;
|
|
6236
6468
|
this.nsfw = data.nsfw ?? false;
|
|
6237
6469
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
6238
6470
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
@@ -6244,6 +6476,7 @@ var Guild = class extends Base {
|
|
|
6244
6476
|
this.bannerHeight = data.banner_height ?? null;
|
|
6245
6477
|
this.splashWidth = data.splash_width ?? null;
|
|
6246
6478
|
this.splashHeight = data.splash_height ?? null;
|
|
6479
|
+
this.maxStageVideoChannelUsers = data.max_stage_video_channel_users ?? null;
|
|
6247
6480
|
this.memberCount = resolveGuildMemberCount(data) ?? null;
|
|
6248
6481
|
this.onlineCount = resolveGuildOnlineCount(data) ?? null;
|
|
6249
6482
|
for (const r of data.roles ?? []) {
|
|
@@ -6280,7 +6513,7 @@ var Guild = class extends Base {
|
|
|
6280
6513
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6281
6514
|
}
|
|
6282
6515
|
if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
|
|
6283
|
-
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ??
|
|
6516
|
+
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types41.GuildNSFWLevel.Safe;
|
|
6284
6517
|
if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
|
|
6285
6518
|
if (data.content_warning_level !== void 0) {
|
|
6286
6519
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
@@ -6300,6 +6533,9 @@ var Guild = class extends Base {
|
|
|
6300
6533
|
if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
|
|
6301
6534
|
if (data.splash_width !== void 0) this.splashWidth = data.splash_width ?? null;
|
|
6302
6535
|
if (data.splash_height !== void 0) this.splashHeight = data.splash_height ?? null;
|
|
6536
|
+
if (data.max_stage_video_channel_users !== void 0) {
|
|
6537
|
+
this.maxStageVideoChannelUsers = data.max_stage_video_channel_users ?? null;
|
|
6538
|
+
}
|
|
6303
6539
|
const memberCount = resolveGuildMemberCount(data);
|
|
6304
6540
|
if (memberCount !== void 0) this.memberCount = memberCount;
|
|
6305
6541
|
const onlineCount = resolveGuildOnlineCount(data);
|
|
@@ -6315,11 +6551,11 @@ var Guild = class extends Base {
|
|
|
6315
6551
|
}
|
|
6316
6552
|
/** Unix timestamp (ms) when this guild was created, derived from its snowflake ID. */
|
|
6317
6553
|
get createdTimestamp() {
|
|
6318
|
-
return
|
|
6554
|
+
return import_util23.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
6319
6555
|
}
|
|
6320
6556
|
/** Date when this guild was created, derived from its snowflake ID. */
|
|
6321
6557
|
get createdAt() {
|
|
6322
|
-
return
|
|
6558
|
+
return import_util23.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
6323
6559
|
}
|
|
6324
6560
|
/** The guild's name. */
|
|
6325
6561
|
toString() {
|
|
@@ -6520,7 +6756,7 @@ var Guild = class extends Base {
|
|
|
6520
6756
|
};
|
|
6521
6757
|
|
|
6522
6758
|
// src/Domain/Guild/Payload.ts
|
|
6523
|
-
var
|
|
6759
|
+
var import_util24 = require("@fluxerjs/util");
|
|
6524
6760
|
var TOP_LEVEL_COUNT_KEYS = [
|
|
6525
6761
|
"member_count",
|
|
6526
6762
|
"online_count",
|
|
@@ -6560,10 +6796,10 @@ function mergeTopLevelSnapshotFields(properties, raw) {
|
|
|
6560
6796
|
return out;
|
|
6561
6797
|
}
|
|
6562
6798
|
function normalizeGuildSnapshotPayload(raw) {
|
|
6563
|
-
if (!(0,
|
|
6799
|
+
if (!(0, import_util24.isRecord)(raw)) return null;
|
|
6564
6800
|
const flatPayload = isHydratableGuildPayload(raw) && (raw.roles === void 0 || Array.isArray(raw.roles)) ? raw : null;
|
|
6565
6801
|
let nestedPayload = null;
|
|
6566
|
-
if (Object.hasOwn(raw, "properties") && (0,
|
|
6802
|
+
if (Object.hasOwn(raw, "properties") && (0, import_util24.isRecord)(raw.properties)) {
|
|
6567
6803
|
const properties = raw.properties;
|
|
6568
6804
|
const rolesValid = raw.roles === void 0 || Array.isArray(raw.roles);
|
|
6569
6805
|
if (rolesValid && isHydratableGuildPayload(properties) && raw.id === properties.id) {
|
|
@@ -6575,7 +6811,7 @@ function normalizeGuildSnapshotPayload(raw) {
|
|
|
6575
6811
|
return flatPayload ?? nestedPayload;
|
|
6576
6812
|
}
|
|
6577
6813
|
function normalizeGuildUpdatePayload(raw) {
|
|
6578
|
-
if (!(0,
|
|
6814
|
+
if (!(0, import_util24.isRecord)(raw) || !isValidGuildPayload(raw)) return null;
|
|
6579
6815
|
return raw;
|
|
6580
6816
|
}
|
|
6581
6817
|
|
|
@@ -6605,6 +6841,8 @@ function upsertGuildFromSnapshot(client, guildData, resources = {}) {
|
|
|
6605
6841
|
if (resources.members !== void 0) mergeMembers(guild, resources.members);
|
|
6606
6842
|
if (resources.emojis !== void 0) syncEmojis(guild, resources.emojis);
|
|
6607
6843
|
if (resources.stickers !== void 0) syncStickers(guild, resources.stickers);
|
|
6844
|
+
if (resources.stageInstances !== void 0) syncStageInstances(guild, resources.stageInstances);
|
|
6845
|
+
if (resources.stageCounts !== void 0) applyStageCounts(guild, resources.stageCounts);
|
|
6608
6846
|
if (resources.channels !== void 0) guild.partial = false;
|
|
6609
6847
|
return { guild, created, recovered };
|
|
6610
6848
|
}
|
|
@@ -6619,7 +6857,9 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6619
6857
|
emojis: g.emojis,
|
|
6620
6858
|
stickers: g.stickers,
|
|
6621
6859
|
// A channel list without `threads` means this session has no viewable threads.
|
|
6622
|
-
threads: g.channels !== void 0 ? g.threads ?? [] : g.threads
|
|
6860
|
+
threads: g.channels !== void 0 ? g.threads ?? [] : g.threads,
|
|
6861
|
+
stageInstances: g.stage_instances,
|
|
6862
|
+
stageCounts: g.stage_counts
|
|
6623
6863
|
});
|
|
6624
6864
|
if (g.voice_states?.length) {
|
|
6625
6865
|
client.emit(Events.VoiceStatesSync, {
|
|
@@ -6631,23 +6871,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6631
6871
|
}
|
|
6632
6872
|
|
|
6633
6873
|
// src/ClientCore/ClientUser.ts
|
|
6634
|
-
var
|
|
6874
|
+
var import_types42 = require("@fluxerjs/types");
|
|
6635
6875
|
var ClientUser = class extends User {
|
|
6636
6876
|
/** Broadcast presence (gateway opcode 3) on all shards. */
|
|
6637
6877
|
setPresence(presence) {
|
|
6638
6878
|
this.client.options.presence = presence;
|
|
6639
6879
|
const wire = toPresenceWire(presence);
|
|
6640
|
-
this.client._sendToAllShards({ op:
|
|
6880
|
+
this.client._sendToAllShards({ op: import_types42.GatewayOpcodes.PresenceUpdate, d: wire });
|
|
6641
6881
|
}
|
|
6642
6882
|
/** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
|
|
6643
6883
|
async fetch() {
|
|
6644
|
-
const data = await this.client.rest.get(
|
|
6884
|
+
const data = await this.client.rest.get(import_types42.Routes.currentUser(), { auth: true });
|
|
6645
6885
|
this._patch(data);
|
|
6646
6886
|
return this;
|
|
6647
6887
|
}
|
|
6648
6888
|
/** GET /users/@me/guilds — returns camelCase partial guilds. */
|
|
6649
6889
|
async fetchGuilds(options) {
|
|
6650
|
-
const path =
|
|
6890
|
+
const path = import_types42.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
|
|
6651
6891
|
const data = await this.client.rest.get(path, { auth: true });
|
|
6652
6892
|
return data.map((g) => ({
|
|
6653
6893
|
id: g.id,
|
|
@@ -6671,7 +6911,7 @@ var ClientUser = class extends User {
|
|
|
6671
6911
|
*/
|
|
6672
6912
|
async leaveGuild(guildId, options) {
|
|
6673
6913
|
const body = options ? toSudoBody(options) : void 0;
|
|
6674
|
-
await this.client.rest.delete(
|
|
6914
|
+
await this.client.rest.delete(import_types42.Routes.leaveGuild(guildId), {
|
|
6675
6915
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6676
6916
|
auth: true
|
|
6677
6917
|
});
|
|
@@ -6679,7 +6919,7 @@ var ClientUser = class extends User {
|
|
|
6679
6919
|
/** Delete every message authored by the caller across a guild (sudo). */
|
|
6680
6920
|
async bulkDeleteMyMessagesInGuild(guildId, options) {
|
|
6681
6921
|
const body = options ? toSudoBody(options) : void 0;
|
|
6682
|
-
await this.client.rest.post(
|
|
6922
|
+
await this.client.rest.post(import_types42.Routes.guildBulkDeleteMine(guildId), {
|
|
6683
6923
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6684
6924
|
auth: true
|
|
6685
6925
|
});
|
|
@@ -6687,7 +6927,7 @@ var ClientUser = class extends User {
|
|
|
6687
6927
|
};
|
|
6688
6928
|
|
|
6689
6929
|
// src/ClientCore/EventHandlers/Helpers.ts
|
|
6690
|
-
var
|
|
6930
|
+
var import_util25 = require("@fluxerjs/util");
|
|
6691
6931
|
function unknownUser(id) {
|
|
6692
6932
|
return { id };
|
|
6693
6933
|
}
|
|
@@ -6994,50 +7234,50 @@ var guildHandlers = {
|
|
|
6994
7234
|
};
|
|
6995
7235
|
|
|
6996
7236
|
// src/ClientCore/EventHandlers/Invites.ts
|
|
6997
|
-
var
|
|
7237
|
+
var import_types43 = require("@fluxerjs/types");
|
|
6998
7238
|
function normalizeInviteCreate(client, payload) {
|
|
6999
|
-
const raw = (0,
|
|
7000
|
-
const code = (0,
|
|
7239
|
+
const raw = (0, import_util25.asRecord)(payload);
|
|
7240
|
+
const code = (0, import_util25.str)(raw?.code);
|
|
7001
7241
|
if (!raw || !code) return null;
|
|
7002
|
-
const typeNum = (0,
|
|
7003
|
-
const type = typeNum ===
|
|
7242
|
+
const typeNum = (0, import_util25.num)(raw.type);
|
|
7243
|
+
const type = typeNum === import_types43.InviteType.GroupDM ? import_types43.InviteType.GroupDM : import_types43.InviteType.Guild;
|
|
7004
7244
|
const shared = {
|
|
7005
7245
|
code,
|
|
7006
7246
|
inviter: raw.inviter ?? null,
|
|
7007
|
-
member_count: (0,
|
|
7247
|
+
member_count: (0, import_util25.num)(raw.member_count),
|
|
7008
7248
|
expires_at: raw.expires_at ?? void 0,
|
|
7009
7249
|
temporary: typeof raw.temporary === "boolean" ? raw.temporary : void 0,
|
|
7010
|
-
created_at: (0,
|
|
7011
|
-
uses: (0,
|
|
7012
|
-
max_uses: (0,
|
|
7013
|
-
max_age: (0,
|
|
7250
|
+
created_at: (0, import_util25.str)(raw.created_at),
|
|
7251
|
+
uses: (0, import_util25.num)(raw.uses),
|
|
7252
|
+
max_uses: (0, import_util25.num)(raw.max_uses),
|
|
7253
|
+
max_age: (0, import_util25.num)(raw.max_age)
|
|
7014
7254
|
};
|
|
7015
|
-
const guildObj = (0,
|
|
7016
|
-
const channelObj = (0,
|
|
7017
|
-
const guildId = (0,
|
|
7018
|
-
const channelId = (0,
|
|
7255
|
+
const guildObj = (0, import_util25.asRecord)(raw.guild);
|
|
7256
|
+
const channelObj = (0, import_util25.asRecord)(raw.channel);
|
|
7257
|
+
const guildId = (0, import_util25.str)(guildObj?.id) ?? (0, import_util25.str)(raw.guild_id) ?? "0";
|
|
7258
|
+
const channelId = (0, import_util25.str)(channelObj?.id) ?? (0, import_util25.str)(raw.channel_id) ?? "0";
|
|
7019
7259
|
const cachedGuild = guildId !== "0" ? client.guilds.get(guildId) : null;
|
|
7020
7260
|
const cachedChannel2 = channelId !== "0" ? client.channels.get(channelId) : null;
|
|
7021
7261
|
const channel = {
|
|
7022
7262
|
id: channelId,
|
|
7023
|
-
type: (0,
|
|
7024
|
-
name: (0,
|
|
7263
|
+
type: (0, import_util25.num)(channelObj?.type) ?? cachedChannel2?.type ?? import_types43.ChannelType.GuildText,
|
|
7264
|
+
name: (0, import_util25.str)(channelObj?.name) ?? cachedChannel2?.name ?? null,
|
|
7025
7265
|
icon: channelObj?.icon ?? null
|
|
7026
7266
|
};
|
|
7027
|
-
if (type ===
|
|
7267
|
+
if (type === import_types43.InviteType.GroupDM) return { ...shared, type, channel };
|
|
7028
7268
|
return {
|
|
7029
7269
|
...shared,
|
|
7030
|
-
type:
|
|
7270
|
+
type: import_types43.InviteType.Guild,
|
|
7031
7271
|
guild: {
|
|
7032
7272
|
id: guildId,
|
|
7033
|
-
name: (0,
|
|
7273
|
+
name: (0, import_util25.str)(guildObj?.name) ?? cachedGuild?.name ?? "Unknown Guild",
|
|
7034
7274
|
icon: guildObj?.icon ?? null,
|
|
7035
7275
|
banner: guildObj?.banner ?? null,
|
|
7036
7276
|
splash: guildObj?.splash ?? null,
|
|
7037
7277
|
features: Array.isArray(guildObj?.features) ? guildObj.features : void 0
|
|
7038
7278
|
},
|
|
7039
7279
|
channel,
|
|
7040
|
-
presence_count: (0,
|
|
7280
|
+
presence_count: (0, import_util25.num)(raw.presence_count)
|
|
7041
7281
|
};
|
|
7042
7282
|
}
|
|
7043
7283
|
var inviteHandlers = {
|
|
@@ -7148,7 +7388,7 @@ var memberHandlers = {
|
|
|
7148
7388
|
};
|
|
7149
7389
|
|
|
7150
7390
|
// src/ClientCore/EventHandlers/Messages.ts
|
|
7151
|
-
var
|
|
7391
|
+
var import_util26 = require("@fluxerjs/util");
|
|
7152
7392
|
function cachedTextChannel(client, channelId) {
|
|
7153
7393
|
const channel = client.channels.get(channelId);
|
|
7154
7394
|
return channel?.isTextBased() ? channel : null;
|
|
@@ -7164,7 +7404,7 @@ function toPartialMessage(client, args) {
|
|
|
7164
7404
|
const cached = args.cached;
|
|
7165
7405
|
const authorId = args.authorId ?? cached?.author?.id ?? null;
|
|
7166
7406
|
const author = cached?.author ? client.getOrCreateUser(cached.author) : authorId ? client.users.get(authorId) ?? null : null;
|
|
7167
|
-
const createdAt = cached?.timestamp ? new Date(cached.timestamp) :
|
|
7407
|
+
const createdAt = cached?.timestamp ? new Date(cached.timestamp) : import_util26.SnowflakeUtil.isValid(args.id) ? import_util26.SnowflakeUtil.dateFromSnowflake(args.id) : null;
|
|
7168
7408
|
return new PartialMessage(client, {
|
|
7169
7409
|
id: args.id,
|
|
7170
7410
|
channelId: args.channelId,
|
|
@@ -7428,6 +7668,46 @@ var passthroughHandlers = {
|
|
|
7428
7668
|
WEBAUTHN_CREDENTIALS_UPDATE: pass(Events.WebAuthnCredentialsUpdate)
|
|
7429
7669
|
};
|
|
7430
7670
|
|
|
7671
|
+
// src/ClientCore/EventHandlers/Stages.ts
|
|
7672
|
+
var stageHandlers = {
|
|
7673
|
+
STAGE_INSTANCE_CREATE(client, d) {
|
|
7674
|
+
const instance = cacheStageInstance(client, d);
|
|
7675
|
+
client.emit(Events.StageInstanceCreate, instance);
|
|
7676
|
+
},
|
|
7677
|
+
STAGE_INSTANCE_UPDATE(client, d) {
|
|
7678
|
+
const data = d;
|
|
7679
|
+
const cached = client.guilds.get(data.guild_id)?.stageInstances.get(data.id);
|
|
7680
|
+
const old = cached ? new StageInstance(client, cached.toJSON()) : null;
|
|
7681
|
+
const instance = cacheStageInstance(client, data);
|
|
7682
|
+
client.emit(Events.StageInstanceUpdate, old, instance);
|
|
7683
|
+
},
|
|
7684
|
+
STAGE_INSTANCE_DELETE(client, d) {
|
|
7685
|
+
const data = d;
|
|
7686
|
+
const guild = client.guilds.get(data.guild_id);
|
|
7687
|
+
const instance = guild?.stageInstances.get(data.id) ?? new StageInstance(client, data);
|
|
7688
|
+
instance._patch(data);
|
|
7689
|
+
guild?.stageInstances.delete(data.id);
|
|
7690
|
+
client.emit(Events.StageInstanceDelete, instance);
|
|
7691
|
+
},
|
|
7692
|
+
STAGE_COUNTS_UPDATE(client, d) {
|
|
7693
|
+
const data = d;
|
|
7694
|
+
const channel = client.channels.get(data.channel_id);
|
|
7695
|
+
if (channel?.isStage()) channel._patchCounts(data);
|
|
7696
|
+
const payload = {
|
|
7697
|
+
guildId: data.guild_id,
|
|
7698
|
+
channelId: data.channel_id,
|
|
7699
|
+
listenerCount: data.listener_count,
|
|
7700
|
+
speakerCount: data.speaker_count,
|
|
7701
|
+
requestCount: data.request_count,
|
|
7702
|
+
videoEnabled: data.video_enabled ?? null
|
|
7703
|
+
};
|
|
7704
|
+
client.emit(Events.StageCountsUpdate, payload);
|
|
7705
|
+
},
|
|
7706
|
+
STAGE_VOICE_STATES_SYNC: pass(Events.StageVoiceStatesSync),
|
|
7707
|
+
STAGE_AUDIENCE_LIST_UPDATE: pass(Events.StageAudienceListUpdate),
|
|
7708
|
+
VOICE_JOIN_QUEUED: pass(Events.VoiceJoinQueued)
|
|
7709
|
+
};
|
|
7710
|
+
|
|
7431
7711
|
// src/ClientCore/EventHandlers/Threads.ts
|
|
7432
7712
|
function cachedChannel(client, id) {
|
|
7433
7713
|
const direct = client.channels.get(id);
|
|
@@ -7538,7 +7818,8 @@ var eventHandlers = buildRegistry(
|
|
|
7538
7818
|
inviteHandlers,
|
|
7539
7819
|
guildResourceHandlers,
|
|
7540
7820
|
passthroughHandlers,
|
|
7541
|
-
threadHandlers
|
|
7821
|
+
threadHandlers,
|
|
7822
|
+
stageHandlers
|
|
7542
7823
|
);
|
|
7543
7824
|
|
|
7544
7825
|
// src/ClientCore/GatewayDispatch.ts
|
|
@@ -7798,7 +8079,7 @@ async function connectClientGateway(client, token, signal) {
|
|
|
7798
8079
|
|
|
7799
8080
|
// src/ClientCore/GuildManager.ts
|
|
7800
8081
|
var import_collection13 = require("@fluxerjs/collection");
|
|
7801
|
-
var
|
|
8082
|
+
var import_types44 = require("@fluxerjs/types");
|
|
7802
8083
|
var GuildManager = class extends import_collection13.LimitedCollection {
|
|
7803
8084
|
constructor(client) {
|
|
7804
8085
|
super({
|
|
@@ -7858,7 +8139,7 @@ var GuildManager = class extends import_collection13.LimitedCollection {
|
|
|
7858
8139
|
return dedupeFetch(this.pendingFetches, id, async () => {
|
|
7859
8140
|
try {
|
|
7860
8141
|
const data = assertApiObjectWithId(
|
|
7861
|
-
await this.client.rest.get(
|
|
8142
|
+
await this.client.rest.get(import_types44.Routes.guild(id)),
|
|
7862
8143
|
"guilds.fetch()"
|
|
7863
8144
|
);
|
|
7864
8145
|
let guild;
|
|
@@ -7967,7 +8248,7 @@ var MessageCache = class {
|
|
|
7967
8248
|
|
|
7968
8249
|
// src/ClientCore/UserManager.ts
|
|
7969
8250
|
var import_collection14 = require("@fluxerjs/collection");
|
|
7970
|
-
var
|
|
8251
|
+
var import_types45 = require("@fluxerjs/types");
|
|
7971
8252
|
var soft = (p) => p.catch(() => null);
|
|
7972
8253
|
var UserManager = class extends import_collection14.LimitedCollection {
|
|
7973
8254
|
constructor(client) {
|
|
@@ -8001,7 +8282,7 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
8001
8282
|
id,
|
|
8002
8283
|
async () => this.client.getOrCreateUser(
|
|
8003
8284
|
assertApiObjectWithId(
|
|
8004
|
-
await this.client.rest.get(
|
|
8285
|
+
await this.client.rest.get(import_types45.Routes.user(id)),
|
|
8005
8286
|
"users.fetch()"
|
|
8006
8287
|
)
|
|
8007
8288
|
)
|
|
@@ -8024,10 +8305,10 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
8024
8305
|
async fetchWithProfile(userId, options) {
|
|
8025
8306
|
const guildId = options?.guildId ?? void 0;
|
|
8026
8307
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
8027
|
-
this.client.rest.get(
|
|
8028
|
-
soft(this.client.rest.get(
|
|
8029
|
-
guildId ? soft(this.client.rest.get(
|
|
8030
|
-
guildId ? soft(this.client.rest.get(
|
|
8308
|
+
this.client.rest.get(import_types45.Routes.user(userId)),
|
|
8309
|
+
soft(this.client.rest.get(import_types45.Routes.userProfile(userId))),
|
|
8310
|
+
guildId ? soft(this.client.rest.get(import_types45.Routes.userProfile(userId, guildId))) : null,
|
|
8311
|
+
guildId ? soft(this.client.rest.get(import_types45.Routes.guildMember(guildId, userId))) : null
|
|
8031
8312
|
]);
|
|
8032
8313
|
const user = this.client.getOrCreateUser(userData);
|
|
8033
8314
|
let member = null;
|
|
@@ -8114,7 +8395,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8114
8395
|
cache: resolved.cache,
|
|
8115
8396
|
defaultReplyPing: options.defaultReplyPing ?? true
|
|
8116
8397
|
};
|
|
8117
|
-
this.logger = options.logger ?? (0,
|
|
8398
|
+
this.logger = options.logger ?? (0, import_util27.createLogger)({
|
|
8118
8399
|
level: options.logLevel ?? "warn"
|
|
8119
8400
|
});
|
|
8120
8401
|
this.cache = new CacheController(this, resolved.limits);
|
|
@@ -8408,7 +8689,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8408
8689
|
if (options.userIds !== void 0) data.user_ids = [...new Set(options.userIds)];
|
|
8409
8690
|
if (options.presences !== void 0) data.presences = options.presences;
|
|
8410
8691
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8411
|
-
this._sendToAllShards({ op:
|
|
8692
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildMembers, d: data });
|
|
8412
8693
|
}
|
|
8413
8694
|
/**
|
|
8414
8695
|
* Request guild member/online counts via gateway opcode 15.
|
|
@@ -8423,7 +8704,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8423
8704
|
}
|
|
8424
8705
|
const data = { guild_ids: guildIds };
|
|
8425
8706
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8426
|
-
this._sendToAllShards({ op:
|
|
8707
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildCounts, d: data });
|
|
8427
8708
|
}
|
|
8428
8709
|
/**
|
|
8429
8710
|
* Request per-channel member counts via gateway opcode 16.
|
|
@@ -8439,7 +8720,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8439
8720
|
if (options.channelId !== void 0) data.channel_id = options.channelId;
|
|
8440
8721
|
if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
|
|
8441
8722
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8442
|
-
this._sendToAllShards({ op:
|
|
8723
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestChannelMemberCounts, d: data });
|
|
8443
8724
|
}
|
|
8444
8725
|
/**
|
|
8445
8726
|
* Request unread counts for posts in one forum or media channel (opcode 28).
|
|
@@ -8475,7 +8756,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8475
8756
|
channel_id: options.channelId,
|
|
8476
8757
|
threads
|
|
8477
8758
|
};
|
|
8478
|
-
this._sendToAllShards({ op:
|
|
8759
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestForumUnreads, d: data });
|
|
8479
8760
|
}
|
|
8480
8761
|
/**
|
|
8481
8762
|
* Subscribe to thread traffic in a guild (opcode 14).
|
|
@@ -8505,7 +8786,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8505
8786
|
subscription.thread_member_lists = threadIds;
|
|
8506
8787
|
}
|
|
8507
8788
|
const data = { subscriptions: { [options.guildId]: subscription } };
|
|
8508
|
-
this._sendToAllShards({ op:
|
|
8789
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.LazyRequest, d: data });
|
|
8509
8790
|
}
|
|
8510
8791
|
/**
|
|
8511
8792
|
* Broadcast a gateway payload to all shards.
|
|
@@ -8610,7 +8891,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8610
8891
|
* @see {@link Routes}
|
|
8611
8892
|
*/
|
|
8612
8893
|
static get Routes() {
|
|
8613
|
-
return
|
|
8894
|
+
return import_types46.Routes;
|
|
8614
8895
|
}
|
|
8615
8896
|
};
|
|
8616
8897
|
// Annotate the CommonJS export names for ESM import in node:
|