@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/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(src_exports, {
|
|
|
24
24
|
AnnouncementChannel: () => AnnouncementChannel,
|
|
25
25
|
AttachmentBuilder: () => import_builders5.AttachmentBuilder,
|
|
26
26
|
AttachmentMeta: () => import_builders5.AttachmentMeta,
|
|
27
|
-
AuditLogActionType: () =>
|
|
27
|
+
AuditLogActionType: () => import_types47.AuditLogActionType,
|
|
28
28
|
BETA_CLIENT_CLUSTER_WARNING: () => BETA_CLIENT_CLUSTER_WARNING,
|
|
29
29
|
Base: () => Base,
|
|
30
30
|
CDN_URL: () => CDN_URL,
|
|
@@ -32,12 +32,12 @@ __export(src_exports, {
|
|
|
32
32
|
CategoryChannel: () => CategoryChannel,
|
|
33
33
|
Channel: () => Channel,
|
|
34
34
|
ChannelManager: () => ChannelManager,
|
|
35
|
-
ChannelType: () =>
|
|
35
|
+
ChannelType: () => import_types47.ChannelType,
|
|
36
36
|
Client: () => Client,
|
|
37
37
|
ClientCluster: () => ClientCluster,
|
|
38
38
|
ClientClusterEvents: () => ClientClusterEvents,
|
|
39
39
|
ClientUser: () => ClientUser,
|
|
40
|
-
ContentWarningLevel: () =>
|
|
40
|
+
ContentWarningLevel: () => import_types47.ContentWarningLevel,
|
|
41
41
|
DEFAULT_CACHE_LIMITS: () => DEFAULT_CACHE_LIMITS,
|
|
42
42
|
DEFAULT_INSTANCE_ENDPOINTS: () => DEFAULT_INSTANCE_ENDPOINTS,
|
|
43
43
|
DMChannel: () => DMChannel,
|
|
@@ -46,10 +46,10 @@ __export(src_exports, {
|
|
|
46
46
|
Events: () => Events,
|
|
47
47
|
FluxerError: () => import_util4.FluxerError,
|
|
48
48
|
ForumChannel: () => ForumChannel,
|
|
49
|
-
ForumLayout: () =>
|
|
50
|
-
ForumSortOrder: () =>
|
|
51
|
-
ForumTagSetting: () =>
|
|
52
|
-
GatewayOpcodes: () =>
|
|
49
|
+
ForumLayout: () => import_types47.ForumLayout,
|
|
50
|
+
ForumSortOrder: () => import_types47.ForumSortOrder,
|
|
51
|
+
ForumTagSetting: () => import_types47.ForumTagSetting,
|
|
52
|
+
GatewayOpcodes: () => import_types47.GatewayOpcodes,
|
|
53
53
|
Guild: () => Guild,
|
|
54
54
|
GuildBan: () => GuildBan,
|
|
55
55
|
GuildChannel: () => GuildChannel,
|
|
@@ -57,55 +57,57 @@ __export(src_exports, {
|
|
|
57
57
|
GuildManager: () => GuildManager,
|
|
58
58
|
GuildMember: () => GuildMember,
|
|
59
59
|
GuildMemberManager: () => GuildMemberManager,
|
|
60
|
-
GuildMemberProfileFlags: () =>
|
|
60
|
+
GuildMemberProfileFlags: () => import_types47.GuildMemberProfileFlags,
|
|
61
61
|
GuildMemberRoleManager: () => GuildMemberRoleManager,
|
|
62
|
-
GuildNSFWLevel: () =>
|
|
63
|
-
GuildOperations: () =>
|
|
62
|
+
GuildNSFWLevel: () => import_types47.GuildNSFWLevel,
|
|
63
|
+
GuildOperations: () => import_types47.GuildOperations,
|
|
64
64
|
GuildRoleManager: () => GuildRoleManager,
|
|
65
65
|
GuildSticker: () => GuildSticker,
|
|
66
66
|
INSTANCE_DISCOVERY_PATH: () => INSTANCE_DISCOVERY_PATH,
|
|
67
67
|
Invite: () => Invite,
|
|
68
|
-
InviteType: () =>
|
|
68
|
+
InviteType: () => import_types47.InviteType,
|
|
69
69
|
LinkChannel: () => LinkChannel,
|
|
70
70
|
MediaChannel: () => MediaChannel,
|
|
71
71
|
Message: () => Message,
|
|
72
|
-
MessageAttachmentFlags: () =>
|
|
72
|
+
MessageAttachmentFlags: () => import_types47.MessageAttachmentFlags,
|
|
73
73
|
MessageCollector: () => MessageCollector,
|
|
74
|
-
MessageFlags: () =>
|
|
75
|
-
MessageFlagsBitField: () =>
|
|
76
|
-
MessageFlagsBits: () =>
|
|
74
|
+
MessageFlags: () => import_types47.MessageFlags,
|
|
75
|
+
MessageFlagsBitField: () => import_util28.MessageFlagsBitField,
|
|
76
|
+
MessageFlagsBits: () => import_util28.MessageFlagsBits,
|
|
77
77
|
MessageManager: () => MessageManager,
|
|
78
78
|
MessagePayload: () => import_builders5.MessagePayload,
|
|
79
79
|
MessageReaction: () => MessageReaction,
|
|
80
80
|
MessageReactionManager: () => MessageReactionManager,
|
|
81
|
-
MessageReferenceType: () =>
|
|
81
|
+
MessageReferenceType: () => import_types47.MessageReferenceType,
|
|
82
82
|
MessageSticker: () => MessageSticker,
|
|
83
|
-
MessageType: () =>
|
|
84
|
-
OverwriteType: () =>
|
|
83
|
+
MessageType: () => import_types47.MessageType,
|
|
84
|
+
OverwriteType: () => import_types47.OverwriteType,
|
|
85
85
|
PartialGuildMember: () => PartialGuildMember,
|
|
86
86
|
PartialMessage: () => PartialMessage,
|
|
87
|
-
PermissionFlags: () =>
|
|
87
|
+
PermissionFlags: () => import_util28.PermissionFlags,
|
|
88
88
|
PermissionOverwrite: () => PermissionOverwrite,
|
|
89
89
|
PermissionOverwriteManager: () => PermissionOverwriteManager,
|
|
90
|
-
PermissionsBitField: () =>
|
|
91
|
-
PublicUserFlags: () =>
|
|
90
|
+
PermissionsBitField: () => import_util28.PermissionsBitField,
|
|
91
|
+
PublicUserFlags: () => import_types47.PublicUserFlags,
|
|
92
92
|
ReactionCollector: () => ReactionCollector,
|
|
93
|
-
RelationshipType: () =>
|
|
93
|
+
RelationshipType: () => import_types47.RelationshipType,
|
|
94
94
|
Role: () => Role,
|
|
95
|
-
Routes: () =>
|
|
95
|
+
Routes: () => import_types47.Routes,
|
|
96
96
|
STATIC_CDN_URL: () => STATIC_CDN_URL,
|
|
97
|
-
SplashCardAlignment: () =>
|
|
98
|
-
|
|
97
|
+
SplashCardAlignment: () => import_types47.SplashCardAlignment,
|
|
98
|
+
StageChannel: () => StageChannel,
|
|
99
|
+
StageInstance: () => StageInstance,
|
|
100
|
+
SystemChannelFlags: () => import_types47.SystemChannelFlags,
|
|
99
101
|
TextChannel: () => TextChannel,
|
|
100
|
-
ThreadAutoArchiveDuration: () =>
|
|
102
|
+
ThreadAutoArchiveDuration: () => import_types47.ThreadAutoArchiveDuration,
|
|
101
103
|
ThreadChannel: () => ThreadChannel,
|
|
102
104
|
ThreadManager: () => ThreadManager,
|
|
103
105
|
ThreadMember: () => ThreadMember,
|
|
104
|
-
ThreadMemberFlags: () =>
|
|
106
|
+
ThreadMemberFlags: () => import_types47.ThreadMemberFlags,
|
|
105
107
|
ThreadMemberManager: () => ThreadMemberManager,
|
|
106
108
|
User: () => User,
|
|
107
|
-
UserFlagsBitField: () =>
|
|
108
|
-
UserFlagsBits: () =>
|
|
109
|
+
UserFlagsBitField: () => import_util28.UserFlagsBitField,
|
|
110
|
+
UserFlagsBits: () => import_util28.UserFlagsBits,
|
|
109
111
|
UserManager: () => UserManager,
|
|
110
112
|
VoiceChannel: () => VoiceChannel,
|
|
111
113
|
Webhook: () => Webhook,
|
|
@@ -118,25 +120,25 @@ __export(src_exports, {
|
|
|
118
120
|
cdnMemberAvatarURL: () => cdnMemberAvatarURL,
|
|
119
121
|
cdnMemberBannerURL: () => cdnMemberBannerURL,
|
|
120
122
|
cdnStickerURL: () => cdnStickerURL,
|
|
121
|
-
createLogger: () =>
|
|
123
|
+
createLogger: () => import_util28.createLogger,
|
|
122
124
|
fetchActiveThreads: () => fetchActiveThreads,
|
|
123
125
|
instanceDiscoveryUrl: () => instanceDiscoveryUrl,
|
|
124
126
|
inviteUrl: () => inviteUrl,
|
|
125
127
|
normalizeApiOrigin: () => normalizeApiOrigin,
|
|
126
128
|
normalizeCacheLimit: () => normalizeCacheLimit,
|
|
127
129
|
parseInstanceDiscovery: () => parseInstanceDiscovery,
|
|
128
|
-
parsePrefixCommand: () =>
|
|
129
|
-
parseUserMention: () =>
|
|
130
|
+
parsePrefixCommand: () => import_util28.parsePrefixCommand,
|
|
131
|
+
parseUserMention: () => import_util28.parseUserMention,
|
|
130
132
|
resolveCacheLimits: () => resolveCacheLimits,
|
|
131
133
|
resolveInstanceEndpoints: () => resolveInstanceEndpoints,
|
|
132
|
-
resolveKlipyToImageUrl: () =>
|
|
133
|
-
resolvePermissionsToBitfield: () =>
|
|
134
|
-
serializeError: () =>
|
|
134
|
+
resolveKlipyToImageUrl: () => import_util28.resolveKlipyToImageUrl,
|
|
135
|
+
resolvePermissionsToBitfield: () => import_util28.resolvePermissionsToBitfield,
|
|
136
|
+
serializeError: () => import_util28.serializeError
|
|
135
137
|
});
|
|
136
138
|
module.exports = __toCommonJS(src_exports);
|
|
137
139
|
var import_builders5 = require("@fluxerjs/builders");
|
|
138
|
-
var
|
|
139
|
-
var
|
|
140
|
+
var import_types47 = require("@fluxerjs/types");
|
|
141
|
+
var import_util28 = require("@fluxerjs/util");
|
|
140
142
|
|
|
141
143
|
// src/ClientCore/CacheController.ts
|
|
142
144
|
var CacheController = class {
|
|
@@ -279,7 +281,7 @@ var CacheController = class {
|
|
|
279
281
|
|
|
280
282
|
// src/ClientCore/ChannelManager.ts
|
|
281
283
|
var import_collection8 = require("@fluxerjs/collection");
|
|
282
|
-
var
|
|
284
|
+
var import_types29 = require("@fluxerjs/types");
|
|
283
285
|
|
|
284
286
|
// src/Domain/Channel/Base.ts
|
|
285
287
|
var import_types10 = require("@fluxerjs/types");
|
|
@@ -1272,6 +1274,13 @@ var Events = {
|
|
|
1272
1274
|
VoiceSignal: "voiceSignal",
|
|
1273
1275
|
OperatorPassUpdate: "operatorPassUpdate",
|
|
1274
1276
|
VoiceStatesSync: "voiceStatesSync",
|
|
1277
|
+
VoiceJoinQueued: "voiceJoinQueued",
|
|
1278
|
+
StageInstanceCreate: "stageInstanceCreate",
|
|
1279
|
+
StageInstanceUpdate: "stageInstanceUpdate",
|
|
1280
|
+
StageInstanceDelete: "stageInstanceDelete",
|
|
1281
|
+
StageCountsUpdate: "stageCountsUpdate",
|
|
1282
|
+
StageVoiceStatesSync: "stageVoiceStatesSync",
|
|
1283
|
+
StageAudienceListUpdate: "stageAudienceListUpdate",
|
|
1275
1284
|
WebhooksUpdate: "webhooksUpdate",
|
|
1276
1285
|
Resumed: "resumed",
|
|
1277
1286
|
Error: "error",
|
|
@@ -2662,11 +2671,11 @@ var Channel = class extends Base {
|
|
|
2662
2671
|
* Checks {@link ChannelType}, not whether `send` exists on the instance.
|
|
2663
2672
|
*/
|
|
2664
2673
|
isTextBased() {
|
|
2665
|
-
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
|
|
2674
|
+
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildStageVoice || this.type === import_types10.ChannelType.DM || this.type === import_types10.ChannelType.GroupDM || this.type === import_types10.ChannelType.DMPersonalNotes || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread;
|
|
2666
2675
|
}
|
|
2667
2676
|
/** Check if this is a guild channel, including threads, forums, and media channels. */
|
|
2668
2677
|
isGuild() {
|
|
2669
|
-
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildCategory || this.type === import_types10.ChannelType.GuildLink || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread || this.type === import_types10.ChannelType.GuildForum || this.type === import_types10.ChannelType.GuildMedia;
|
|
2678
|
+
return this.type === import_types10.ChannelType.GuildText || this.type === import_types10.ChannelType.GuildAnnouncement || this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildStageVoice || this.type === import_types10.ChannelType.GuildCategory || this.type === import_types10.ChannelType.GuildLink || this.type === import_types10.ChannelType.AnnouncementThread || this.type === import_types10.ChannelType.PublicThread || this.type === import_types10.ChannelType.PrivateThread || this.type === import_types10.ChannelType.GuildForum || this.type === import_types10.ChannelType.GuildMedia;
|
|
2670
2679
|
}
|
|
2671
2680
|
/** Check if this is a thread (public, private, or announcement). */
|
|
2672
2681
|
isThread() {
|
|
@@ -2700,10 +2709,18 @@ var Channel = class extends Base {
|
|
|
2700
2709
|
isPersonalNotes() {
|
|
2701
2710
|
return this.type === import_types10.ChannelType.DMPersonalNotes;
|
|
2702
2711
|
}
|
|
2703
|
-
/** Check if this is a voice channel. */
|
|
2712
|
+
/** Check if this is a voice channel (type 2 only; see {@link isVoiceBased} to include stages). */
|
|
2704
2713
|
isVoice() {
|
|
2705
2714
|
return this.type === import_types10.ChannelType.GuildVoice;
|
|
2706
2715
|
}
|
|
2716
|
+
/** Check if this is a stage channel (type 13). */
|
|
2717
|
+
isStage() {
|
|
2718
|
+
return this.type === import_types10.ChannelType.GuildStageVoice;
|
|
2719
|
+
}
|
|
2720
|
+
/** Check if this is a voice or stage channel, i.e. one `@fluxerjs/voice` can join. */
|
|
2721
|
+
isVoiceBased() {
|
|
2722
|
+
return this.type === import_types10.ChannelType.GuildVoice || this.type === import_types10.ChannelType.GuildStageVoice;
|
|
2723
|
+
}
|
|
2707
2724
|
/** Check if this is a link channel. */
|
|
2708
2725
|
isLink() {
|
|
2709
2726
|
return this.type === import_types10.ChannelType.GuildLink;
|
|
@@ -3014,11 +3031,11 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
3014
3031
|
};
|
|
3015
3032
|
|
|
3016
3033
|
// src/Domain/Channel/Forum.ts
|
|
3017
|
-
var
|
|
3034
|
+
var import_types20 = require("@fluxerjs/types");
|
|
3018
3035
|
|
|
3019
3036
|
// src/Domain/Channel/Guild.ts
|
|
3020
|
-
var
|
|
3021
|
-
var
|
|
3037
|
+
var import_types17 = require("@fluxerjs/types");
|
|
3038
|
+
var import_util14 = require("@fluxerjs/util");
|
|
3022
3039
|
|
|
3023
3040
|
// src/Domain/Invite.ts
|
|
3024
3041
|
var import_types13 = require("@fluxerjs/types");
|
|
@@ -3608,6 +3625,127 @@ var PermissionOverwriteManager = class {
|
|
|
3608
3625
|
}
|
|
3609
3626
|
};
|
|
3610
3627
|
|
|
3628
|
+
// src/Domain/StageInstance.ts
|
|
3629
|
+
var import_types16 = require("@fluxerjs/types");
|
|
3630
|
+
var import_util13 = require("@fluxerjs/util");
|
|
3631
|
+
var StageInstance = class extends Base {
|
|
3632
|
+
client;
|
|
3633
|
+
id;
|
|
3634
|
+
guildId;
|
|
3635
|
+
channelId;
|
|
3636
|
+
topic;
|
|
3637
|
+
/** Always {@link StageInstancePrivacyLevel.GuildOnly} on Fluxer. */
|
|
3638
|
+
privacyLevel;
|
|
3639
|
+
/** Always `true` on Fluxer. */
|
|
3640
|
+
discoverableDisabled;
|
|
3641
|
+
/** Always null on Fluxer. */
|
|
3642
|
+
guildScheduledEventId;
|
|
3643
|
+
constructor(client, data) {
|
|
3644
|
+
super();
|
|
3645
|
+
this.client = client;
|
|
3646
|
+
this.id = data.id;
|
|
3647
|
+
this.guildId = data.guild_id;
|
|
3648
|
+
this.channelId = data.channel_id;
|
|
3649
|
+
this.topic = data.topic;
|
|
3650
|
+
this.privacyLevel = data.privacy_level ?? import_types16.StageInstancePrivacyLevel.GuildOnly;
|
|
3651
|
+
this.discoverableDisabled = data.discoverable_disabled ?? true;
|
|
3652
|
+
this.guildScheduledEventId = data.guild_scheduled_event_id ?? null;
|
|
3653
|
+
}
|
|
3654
|
+
/** @internal Patch in place from a newer payload. */
|
|
3655
|
+
_patch(data) {
|
|
3656
|
+
if (data.topic !== void 0) this.topic = data.topic;
|
|
3657
|
+
if (data.privacy_level !== void 0) this.privacyLevel = data.privacy_level;
|
|
3658
|
+
if (data.discoverable_disabled !== void 0) {
|
|
3659
|
+
this.discoverableDisabled = data.discoverable_disabled;
|
|
3660
|
+
}
|
|
3661
|
+
if (data.guild_scheduled_event_id !== void 0) {
|
|
3662
|
+
this.guildScheduledEventId = data.guild_scheduled_event_id ?? null;
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
get guild() {
|
|
3666
|
+
return this.client.guilds.get(this.guildId) ?? null;
|
|
3667
|
+
}
|
|
3668
|
+
get channel() {
|
|
3669
|
+
const channel = this.client.channels.get(this.channelId);
|
|
3670
|
+
return channel?.isStage() ? channel : null;
|
|
3671
|
+
}
|
|
3672
|
+
/** Unix timestamp (ms) when the stage started, from its snowflake ID. */
|
|
3673
|
+
get createdTimestamp() {
|
|
3674
|
+
return import_util13.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
3675
|
+
}
|
|
3676
|
+
get createdAt() {
|
|
3677
|
+
return import_util13.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
3678
|
+
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Change the live stage. Needs a stage moderator.
|
|
3681
|
+
* Fires `STAGE_INSTANCE_UPDATE`.
|
|
3682
|
+
*/
|
|
3683
|
+
async edit(options) {
|
|
3684
|
+
const body = {};
|
|
3685
|
+
if (options.topic !== void 0) body.topic = options.topic;
|
|
3686
|
+
const data = await this.client.rest.patch(
|
|
3687
|
+
import_types16.Routes.stageInstance(this.channelId),
|
|
3688
|
+
{ body, auth: true, ...auditReasonHeaders(options.reason) }
|
|
3689
|
+
);
|
|
3690
|
+
this._patch(data);
|
|
3691
|
+
return this;
|
|
3692
|
+
}
|
|
3693
|
+
/** Change the stage topic. Shorthand for {@link edit}. */
|
|
3694
|
+
async setTopic(topic, reason) {
|
|
3695
|
+
return this.edit({ topic, reason });
|
|
3696
|
+
}
|
|
3697
|
+
/**
|
|
3698
|
+
* End the stage. Needs a stage moderator. Speakers move to the audience, raised hands are
|
|
3699
|
+
* lowered, and everyone stays connected unless `disconnectAll` is set.
|
|
3700
|
+
*/
|
|
3701
|
+
async delete(options = {}) {
|
|
3702
|
+
const route = import_types16.Routes.stageInstance(this.channelId) + (options.disconnectAll ? "?disconnect_all=true" : "");
|
|
3703
|
+
await this.client.rest.delete(route, { auth: true, ...auditReasonHeaders(options.reason) });
|
|
3704
|
+
}
|
|
3705
|
+
toJSON() {
|
|
3706
|
+
return {
|
|
3707
|
+
id: this.id,
|
|
3708
|
+
guild_id: this.guildId,
|
|
3709
|
+
channel_id: this.channelId,
|
|
3710
|
+
topic: this.topic,
|
|
3711
|
+
privacy_level: this.privacyLevel,
|
|
3712
|
+
discoverable_disabled: this.discoverableDisabled,
|
|
3713
|
+
guild_scheduled_event_id: this.guildScheduledEventId
|
|
3714
|
+
};
|
|
3715
|
+
}
|
|
3716
|
+
};
|
|
3717
|
+
|
|
3718
|
+
// src/Domain/Channel/StageSync.ts
|
|
3719
|
+
function syncStageInstances(guild, instances) {
|
|
3720
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3721
|
+
for (const data of instances) {
|
|
3722
|
+
seen.add(data.id);
|
|
3723
|
+
const existing = guild.stageInstances.get(data.id);
|
|
3724
|
+
if (existing) existing._patch(data);
|
|
3725
|
+
else guild.stageInstances.set(data.id, new StageInstance(guild.client, data));
|
|
3726
|
+
}
|
|
3727
|
+
for (const id of [...guild.stageInstances.keys()]) {
|
|
3728
|
+
if (!seen.has(id)) guild.stageInstances.delete(id);
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
function applyStageCounts(guild, counts) {
|
|
3732
|
+
for (const count of counts) {
|
|
3733
|
+
const channel = guild.channels.get(count.channel_id);
|
|
3734
|
+
if (channel?.isStage()) channel._patchCounts(count);
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
function cacheStageInstance(client, data) {
|
|
3738
|
+
const guild = client.guilds.get(data.guild_id);
|
|
3739
|
+
const existing = guild?.stageInstances.get(data.id);
|
|
3740
|
+
if (existing) {
|
|
3741
|
+
existing._patch(data);
|
|
3742
|
+
return existing;
|
|
3743
|
+
}
|
|
3744
|
+
const instance = new StageInstance(client, data);
|
|
3745
|
+
guild?.stageInstances.set(instance.id, instance);
|
|
3746
|
+
return instance;
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3611
3749
|
// src/Domain/Channel/ThreadBind.ts
|
|
3612
3750
|
var factory;
|
|
3613
3751
|
var managers = /* @__PURE__ */ new WeakMap();
|
|
@@ -3662,7 +3800,7 @@ var GuildChannel = class extends Channel {
|
|
|
3662
3800
|
}
|
|
3663
3801
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
3664
3802
|
async createWebhook(options) {
|
|
3665
|
-
const data = await this.client.rest.post(
|
|
3803
|
+
const data = await this.client.rest.post(import_types17.Routes.channelWebhooks(this.id), {
|
|
3666
3804
|
body: options,
|
|
3667
3805
|
auth: true
|
|
3668
3806
|
});
|
|
@@ -3670,13 +3808,13 @@ var GuildChannel = class extends Channel {
|
|
|
3670
3808
|
}
|
|
3671
3809
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
3672
3810
|
async fetchWebhooks() {
|
|
3673
|
-
const data = await this.client.rest.get(
|
|
3811
|
+
const data = await this.client.rest.get(import_types17.Routes.channelWebhooks(this.id));
|
|
3674
3812
|
return data.map((w) => new Webhook(this.client, w));
|
|
3675
3813
|
}
|
|
3676
3814
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
3677
3815
|
async createInvite(options) {
|
|
3678
3816
|
const body = options ? toChannelInviteBody(options) : {};
|
|
3679
|
-
const data = await this.client.rest.post(
|
|
3817
|
+
const data = await this.client.rest.post(import_types17.Routes.channelInvites(this.id), {
|
|
3680
3818
|
body: Object.keys(body).length ? body : void 0,
|
|
3681
3819
|
auth: true
|
|
3682
3820
|
});
|
|
@@ -3684,7 +3822,7 @@ var GuildChannel = class extends Channel {
|
|
|
3684
3822
|
}
|
|
3685
3823
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
3686
3824
|
async fetchInvites() {
|
|
3687
|
-
const data = await this.client.rest.get(
|
|
3825
|
+
const data = await this.client.rest.get(import_types17.Routes.channelInvites(this.id));
|
|
3688
3826
|
return data.map((i) => new Invite(this.client, i));
|
|
3689
3827
|
}
|
|
3690
3828
|
/** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
|
|
@@ -3693,7 +3831,7 @@ var GuildChannel = class extends Channel {
|
|
|
3693
3831
|
const me = this.client.guilds.get(this.guildId)?.members.me;
|
|
3694
3832
|
if (!me) return false;
|
|
3695
3833
|
const perms = me.permissionsIn(this);
|
|
3696
|
-
return perms.has(
|
|
3834
|
+
return perms.has(import_util14.PermissionFlags.ViewChannel) && perms.has(import_util14.PermissionFlags.SendMessages);
|
|
3697
3835
|
}
|
|
3698
3836
|
/**
|
|
3699
3837
|
* Like {@link canSendMessage}, but hydrates `members.me` via REST when missing.
|
|
@@ -3714,7 +3852,7 @@ var GuildChannel = class extends Channel {
|
|
|
3714
3852
|
}
|
|
3715
3853
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
3716
3854
|
async edit(options) {
|
|
3717
|
-
const data = await this.client.rest.patch(
|
|
3855
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3718
3856
|
body: toChannelEditBody(options),
|
|
3719
3857
|
auth: true,
|
|
3720
3858
|
...auditReasonHeaders(options.reason)
|
|
@@ -3796,7 +3934,7 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3796
3934
|
* Sends only those fields. The thread-parent update body does not accept a channel rename.
|
|
3797
3935
|
*/
|
|
3798
3936
|
async editThreadDefaults(options) {
|
|
3799
|
-
const data = await this.client.rest.patch(
|
|
3937
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3800
3938
|
body: toThreadParentEditBody(options),
|
|
3801
3939
|
auth: true,
|
|
3802
3940
|
...auditReasonHeaders(options.reason)
|
|
@@ -3812,14 +3950,14 @@ var AnnouncementChannel = class extends TextChannel {
|
|
|
3812
3950
|
*/
|
|
3813
3951
|
async follow(webhookChannelId) {
|
|
3814
3952
|
return this.client.rest.post(
|
|
3815
|
-
|
|
3953
|
+
import_types17.Routes.channelFollowers(this.id),
|
|
3816
3954
|
{ body: { webhook_channel_id: webhookChannelId }, auth: true }
|
|
3817
3955
|
);
|
|
3818
3956
|
}
|
|
3819
3957
|
/** Fetch follower counts for this announcement channel. */
|
|
3820
3958
|
async fetchFollowerStats() {
|
|
3821
3959
|
return this.client.rest.get(
|
|
3822
|
-
|
|
3960
|
+
import_types17.Routes.channelFollowerStats(this.id),
|
|
3823
3961
|
{ auth: true }
|
|
3824
3962
|
);
|
|
3825
3963
|
}
|
|
@@ -3894,6 +4032,96 @@ var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
|
3894
4032
|
if ("rtc_p2p" in data) this.rtcP2p = data.rtc_p2p ?? false;
|
|
3895
4033
|
}
|
|
3896
4034
|
};
|
|
4035
|
+
var StageChannel = class extends VoiceChannel {
|
|
4036
|
+
/** Last known stage counts, or null until Fluxer sends them. */
|
|
4037
|
+
counts = null;
|
|
4038
|
+
/** The cached live stage of this channel, or null when the stage isn't live (or not cached). */
|
|
4039
|
+
get stageInstance() {
|
|
4040
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
4041
|
+
if (!guild) return null;
|
|
4042
|
+
for (const instance of guild.stageInstances.values()) {
|
|
4043
|
+
if (instance.channelId === this.id) return instance;
|
|
4044
|
+
}
|
|
4045
|
+
return null;
|
|
4046
|
+
}
|
|
4047
|
+
/** Whether the stage is live according to the cache. */
|
|
4048
|
+
get isLive() {
|
|
4049
|
+
return this.stageInstance !== null;
|
|
4050
|
+
}
|
|
4051
|
+
/**
|
|
4052
|
+
* Start a stage in this channel. Needs a stage moderator (`MANAGE_CHANNELS`, `MUTE_MEMBERS` and
|
|
4053
|
+
* `MOVE_MEMBERS`). When the caller is connected to the stage, they become a speaker.
|
|
4054
|
+
*/
|
|
4055
|
+
async createStageInstance(options) {
|
|
4056
|
+
const body = { channel_id: this.id, topic: options.topic };
|
|
4057
|
+
if (options.sendStartNotification !== void 0) {
|
|
4058
|
+
body.send_start_notification = options.sendStartNotification;
|
|
4059
|
+
}
|
|
4060
|
+
const data = await this.client.rest.post(import_types17.Routes.stageInstances(), {
|
|
4061
|
+
body,
|
|
4062
|
+
auth: true,
|
|
4063
|
+
...auditReasonHeaders(options.reason)
|
|
4064
|
+
});
|
|
4065
|
+
return cacheStageInstance(this.client, data);
|
|
4066
|
+
}
|
|
4067
|
+
/** Fetch the live stage of this channel. Rejects with `UNKNOWN_STAGE_INSTANCE` when not live. */
|
|
4068
|
+
async fetchStageInstance() {
|
|
4069
|
+
const data = await this.client.rest.get(import_types17.Routes.stageInstance(this.id), {
|
|
4070
|
+
auth: true
|
|
4071
|
+
});
|
|
4072
|
+
return cacheStageInstance(this.client, data);
|
|
4073
|
+
}
|
|
4074
|
+
/**
|
|
4075
|
+
* Move a member (or yourself when `user` is omitted) between the audience and the speakers.
|
|
4076
|
+
*
|
|
4077
|
+
* - Yourself, `false`: become a speaker (needs `MUTE_MEMBERS`), or accept an open invite.
|
|
4078
|
+
* - Yourself, `true`: move to the audience, or decline an invite.
|
|
4079
|
+
* - Another member, `false`: invite them to speak (a bot becomes a speaker at once). Needs `MUTE_MEMBERS`.
|
|
4080
|
+
* - Another member, `true`: move them to the audience and clear a raised hand or invite.
|
|
4081
|
+
*/
|
|
4082
|
+
async setSuppressed(suppressed, user) {
|
|
4083
|
+
const userId = user === void 0 ? "@me" : typeof user === "string" ? user : user.id;
|
|
4084
|
+
const body = {
|
|
4085
|
+
channel_id: this.id,
|
|
4086
|
+
suppress: suppressed
|
|
4087
|
+
};
|
|
4088
|
+
await this.client.rest.patch(import_types17.Routes.guildVoiceState(this.guildId, userId), {
|
|
4089
|
+
body,
|
|
4090
|
+
auth: true
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
/** Invite a member to speak (a bot becomes a speaker at once). Needs `MUTE_MEMBERS`. */
|
|
4094
|
+
async inviteToSpeak(user) {
|
|
4095
|
+
await this.setSuppressed(false, user);
|
|
4096
|
+
}
|
|
4097
|
+
/** Move a speaker (or yourself when `user` is omitted) to the audience. */
|
|
4098
|
+
async moveToAudience(user) {
|
|
4099
|
+
await this.setSuppressed(true, user);
|
|
4100
|
+
}
|
|
4101
|
+
/**
|
|
4102
|
+
* Raise (`true`) or lower (`false`) your hand. Raising needs a live stage and
|
|
4103
|
+
* `REQUEST_TO_SPEAK`; lowering also accepts an open invite to speak.
|
|
4104
|
+
*/
|
|
4105
|
+
async setRequestToSpeak(raised = true) {
|
|
4106
|
+
const body = {
|
|
4107
|
+
channel_id: this.id,
|
|
4108
|
+
request_to_speak_timestamp: raised ? (/* @__PURE__ */ new Date()).toISOString() : null
|
|
4109
|
+
};
|
|
4110
|
+
await this.client.rest.patch(import_types17.Routes.guildVoiceState(this.guildId, "@me"), {
|
|
4111
|
+
body,
|
|
4112
|
+
auth: true
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
/** @internal Apply a stage count object. */
|
|
4116
|
+
_patchCounts(data) {
|
|
4117
|
+
this.counts = {
|
|
4118
|
+
listenerCount: data.listener_count,
|
|
4119
|
+
speakerCount: data.speaker_count,
|
|
4120
|
+
requestCount: data.request_count,
|
|
4121
|
+
videoEnabled: data.video_enabled ?? null
|
|
4122
|
+
};
|
|
4123
|
+
}
|
|
4124
|
+
};
|
|
3897
4125
|
var LinkChannel = class extends GuildChannel {
|
|
3898
4126
|
/** External URL this channel links to. */
|
|
3899
4127
|
url;
|
|
@@ -3907,10 +4135,10 @@ var LinkChannel = class extends GuildChannel {
|
|
|
3907
4135
|
};
|
|
3908
4136
|
|
|
3909
4137
|
// src/Domain/Channel/ThreadManager.ts
|
|
3910
|
-
var
|
|
4138
|
+
var import_types19 = require("@fluxerjs/types");
|
|
3911
4139
|
|
|
3912
4140
|
// src/Domain/Channel/ThreadChannel.ts
|
|
3913
|
-
var
|
|
4141
|
+
var import_types18 = require("@fluxerjs/types");
|
|
3914
4142
|
var ThreadMember = class {
|
|
3915
4143
|
/** Thread ID. */
|
|
3916
4144
|
id;
|
|
@@ -4037,7 +4265,7 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
4037
4265
|
* `appliedTags` is sent for public and announcement threads. `invitable` is sent for private threads.
|
|
4038
4266
|
*/
|
|
4039
4267
|
async edit(options) {
|
|
4040
|
-
const data = await this.client.rest.patch(
|
|
4268
|
+
const data = await this.client.rest.patch(import_types18.Routes.channel(this.id), {
|
|
4041
4269
|
body: toThreadEditBody(this.type, threadEditFields(options)),
|
|
4042
4270
|
auth: true,
|
|
4043
4271
|
...auditReasonHeaders(options.reason)
|
|
@@ -4055,16 +4283,16 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
4055
4283
|
}
|
|
4056
4284
|
/** Join this thread. */
|
|
4057
4285
|
async join() {
|
|
4058
|
-
await this.client.rest.put(
|
|
4286
|
+
await this.client.rest.put(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
4059
4287
|
}
|
|
4060
4288
|
/** Leave this thread. */
|
|
4061
4289
|
async leave() {
|
|
4062
|
-
await this.client.rest.delete(
|
|
4290
|
+
await this.client.rest.delete(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
4063
4291
|
}
|
|
4064
4292
|
/** Update the current user's notification settings for this thread. */
|
|
4065
4293
|
async editSelf(options) {
|
|
4066
4294
|
const data = await this.client.rest.patch(
|
|
4067
|
-
|
|
4295
|
+
import_types18.Routes.channelThreadMemberMeSettings(this.id),
|
|
4068
4296
|
{ body: toThreadMemberSettingsBody(options), auth: true }
|
|
4069
4297
|
);
|
|
4070
4298
|
this.member = data ? new ThreadMember(data) : null;
|
|
@@ -4078,7 +4306,7 @@ var ThreadMemberManager = class {
|
|
|
4078
4306
|
/** List members of this thread. */
|
|
4079
4307
|
async fetch(options) {
|
|
4080
4308
|
const data = await this.thread.client.rest.get(
|
|
4081
|
-
withQuery(
|
|
4309
|
+
withQuery(import_types18.Routes.channelThreadMembers(this.thread.id), {
|
|
4082
4310
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember),
|
|
4083
4311
|
after: options?.after,
|
|
4084
4312
|
limit: options?.limit
|
|
@@ -4089,7 +4317,7 @@ var ThreadMemberManager = class {
|
|
|
4089
4317
|
/** Fetch one member of this thread. */
|
|
4090
4318
|
async fetchOne(userId, options) {
|
|
4091
4319
|
const data = await this.thread.client.rest.get(
|
|
4092
|
-
withQuery(
|
|
4320
|
+
withQuery(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
4093
4321
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember)
|
|
4094
4322
|
})
|
|
4095
4323
|
);
|
|
@@ -4097,19 +4325,19 @@ var ThreadMemberManager = class {
|
|
|
4097
4325
|
}
|
|
4098
4326
|
/** Add a user to this thread. Private threads only, unless the caller can manage the parent. */
|
|
4099
4327
|
async add(userId) {
|
|
4100
|
-
await this.thread.client.rest.put(
|
|
4328
|
+
await this.thread.client.rest.put(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
4101
4329
|
auth: true
|
|
4102
4330
|
});
|
|
4103
4331
|
}
|
|
4104
4332
|
/** Remove a user from this thread. */
|
|
4105
4333
|
async remove(userId) {
|
|
4106
|
-
await this.thread.client.rest.delete(
|
|
4334
|
+
await this.thread.client.rest.delete(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
4107
4335
|
auth: true
|
|
4108
4336
|
});
|
|
4109
4337
|
}
|
|
4110
4338
|
};
|
|
4111
4339
|
function isThreadType(type) {
|
|
4112
|
-
return type ===
|
|
4340
|
+
return type === import_types18.ChannelType.AnnouncementThread || type === import_types18.ChannelType.PublicThread || type === import_types18.ChannelType.PrivateThread;
|
|
4113
4341
|
}
|
|
4114
4342
|
|
|
4115
4343
|
// src/Domain/Channel/ThreadManager.ts
|
|
@@ -4122,13 +4350,13 @@ var ThreadManager = class {
|
|
|
4122
4350
|
* Forum and media channels must use {@link createPost}.
|
|
4123
4351
|
*/
|
|
4124
4352
|
async create(options) {
|
|
4125
|
-
if (this.channel.type ===
|
|
4353
|
+
if (this.channel.type === import_types19.ChannelType.GuildForum || this.channel.type === import_types19.ChannelType.GuildMedia) {
|
|
4126
4354
|
throw new import_util4.FluxerError("Forum and media channels start posts with createPost", {
|
|
4127
4355
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
4128
4356
|
});
|
|
4129
4357
|
}
|
|
4130
4358
|
const data = await this.channel.client.rest.post(
|
|
4131
|
-
|
|
4359
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
4132
4360
|
{
|
|
4133
4361
|
body: toStartThreadBody(this.channel.type, options),
|
|
4134
4362
|
auth: true,
|
|
@@ -4142,7 +4370,7 @@ var ThreadManager = class {
|
|
|
4142
4370
|
* The post is a public thread. `message` is its first message.
|
|
4143
4371
|
*/
|
|
4144
4372
|
async createPost(options) {
|
|
4145
|
-
if (this.channel.type !==
|
|
4373
|
+
if (this.channel.type !== import_types19.ChannelType.GuildForum && this.channel.type !== import_types19.ChannelType.GuildMedia) {
|
|
4146
4374
|
throw new import_util4.FluxerError("createPost is for forum and media channels", {
|
|
4147
4375
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
4148
4376
|
});
|
|
@@ -4152,7 +4380,7 @@ var ThreadManager = class {
|
|
|
4152
4380
|
});
|
|
4153
4381
|
const body = {
|
|
4154
4382
|
name: options.name,
|
|
4155
|
-
type:
|
|
4383
|
+
type: import_types19.ChannelType.PublicThread,
|
|
4156
4384
|
message: toForumThreadMessage(prepared.body)
|
|
4157
4385
|
};
|
|
4158
4386
|
if (options.autoArchiveDuration !== void 0) {
|
|
@@ -4161,7 +4389,7 @@ var ThreadManager = class {
|
|
|
4161
4389
|
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
4162
4390
|
if (options.appliedTags !== void 0) body.applied_tags = options.appliedTags;
|
|
4163
4391
|
const data = await this.channel.client.rest.post(
|
|
4164
|
-
|
|
4392
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
4165
4393
|
{
|
|
4166
4394
|
body,
|
|
4167
4395
|
files: prepared.files,
|
|
@@ -4180,7 +4408,7 @@ var ThreadManager = class {
|
|
|
4180
4408
|
* `before` is an ISO-8601 archive timestamp.
|
|
4181
4409
|
*/
|
|
4182
4410
|
async fetchArchived(options) {
|
|
4183
|
-
const path = options.type === "private" ?
|
|
4411
|
+
const path = options.type === "private" ? import_types19.Routes.channelThreadsArchivedPrivate(this.channel.id) : import_types19.Routes.channelThreadsArchivedPublic(this.channel.id);
|
|
4184
4412
|
const data = await this.channel.client.rest.get(
|
|
4185
4413
|
withQuery(path, { before: options.before, limit: options.limit })
|
|
4186
4414
|
);
|
|
@@ -4192,7 +4420,7 @@ var ThreadManager = class {
|
|
|
4192
4420
|
*/
|
|
4193
4421
|
async fetchJoinedPrivateArchived(options) {
|
|
4194
4422
|
const data = await this.channel.client.rest.get(
|
|
4195
|
-
withQuery(
|
|
4423
|
+
withQuery(import_types19.Routes.channelJoinedArchivedPrivateThreads(this.channel.id), {
|
|
4196
4424
|
before: options?.before,
|
|
4197
4425
|
limit: options?.limit
|
|
4198
4426
|
})
|
|
@@ -4205,7 +4433,7 @@ var ThreadManager = class {
|
|
|
4205
4433
|
*/
|
|
4206
4434
|
async search(options) {
|
|
4207
4435
|
const data = await this.channel.client.rest.get(
|
|
4208
|
-
withQuery(
|
|
4436
|
+
withQuery(import_types19.Routes.channelThreadSearch(this.channel.id), {
|
|
4209
4437
|
name: options?.name,
|
|
4210
4438
|
tag: options?.tag,
|
|
4211
4439
|
tag_setting: options?.tagSetting,
|
|
@@ -4233,7 +4461,7 @@ var ThreadManager = class {
|
|
|
4233
4461
|
}
|
|
4234
4462
|
/** Set the auto-archive and slowmode defaults copied onto new threads. */
|
|
4235
4463
|
async editDefaults(options) {
|
|
4236
|
-
return this.channel.client.rest.patch(
|
|
4464
|
+
return this.channel.client.rest.patch(import_types19.Routes.channel(this.channel.id), {
|
|
4237
4465
|
body: toThreadParentEditBody(options),
|
|
4238
4466
|
auth: true,
|
|
4239
4467
|
...auditReasonHeaders(options.reason)
|
|
@@ -4251,7 +4479,7 @@ function isSearchNotReady(data) {
|
|
|
4251
4479
|
return "code" in data && data.code === "SEARCH_INDEX_NOT_READY";
|
|
4252
4480
|
}
|
|
4253
4481
|
async function fetchActiveThreads(client, guildId) {
|
|
4254
|
-
const data = await client.rest.get(
|
|
4482
|
+
const data = await client.rest.get(import_types19.Routes.guildActiveThreads(guildId));
|
|
4255
4483
|
return fetchedThreadsFrom(client, data);
|
|
4256
4484
|
}
|
|
4257
4485
|
|
|
@@ -4310,10 +4538,10 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4310
4538
|
* `defaultForumLayout` is sent only for forum channels.
|
|
4311
4539
|
*/
|
|
4312
4540
|
async edit(options) {
|
|
4313
|
-
const data = await this.client.rest.patch(
|
|
4541
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4314
4542
|
body: {
|
|
4315
4543
|
...toChannelEditBody(options),
|
|
4316
|
-
...forumParentWire(options, this.type ===
|
|
4544
|
+
...forumParentWire(options, this.type === import_types20.ChannelType.GuildForum)
|
|
4317
4545
|
},
|
|
4318
4546
|
auth: true,
|
|
4319
4547
|
...auditReasonHeaders(options.reason)
|
|
@@ -4339,7 +4567,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4339
4567
|
}
|
|
4340
4568
|
/** Set the auto-archive and slowmode defaults copied onto new posts. */
|
|
4341
4569
|
async editThreadDefaults(options) {
|
|
4342
|
-
const data = await this.client.rest.patch(
|
|
4570
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4343
4571
|
body: toThreadParentEditBody(options),
|
|
4344
4572
|
auth: true,
|
|
4345
4573
|
...auditReasonHeaders(options.reason)
|
|
@@ -4349,7 +4577,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4349
4577
|
}
|
|
4350
4578
|
/** Create a tag. The response replaces {@link availableTags}. */
|
|
4351
4579
|
async createTag(options) {
|
|
4352
|
-
const data = await this.client.rest.post(
|
|
4580
|
+
const data = await this.client.rest.post(import_types20.Routes.channelTags(this.id), {
|
|
4353
4581
|
body: toForumTagBody(options),
|
|
4354
4582
|
auth: true,
|
|
4355
4583
|
...auditReasonHeaders(options.reason)
|
|
@@ -4359,7 +4587,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4359
4587
|
}
|
|
4360
4588
|
/** Replace a tag. The response replaces {@link availableTags}. */
|
|
4361
4589
|
async editTag(tagId, options) {
|
|
4362
|
-
const data = await this.client.rest.put(
|
|
4590
|
+
const data = await this.client.rest.put(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4363
4591
|
body: toForumTagBody(options),
|
|
4364
4592
|
auth: true,
|
|
4365
4593
|
...auditReasonHeaders(options.reason)
|
|
@@ -4369,7 +4597,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4369
4597
|
}
|
|
4370
4598
|
/** Delete a tag. The response replaces {@link availableTags}. */
|
|
4371
4599
|
async deleteTag(tagId, reason) {
|
|
4372
|
-
const data = await this.client.rest.delete(
|
|
4600
|
+
const data = await this.client.rest.delete(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4373
4601
|
auth: true,
|
|
4374
4602
|
...auditReasonHeaders(reason)
|
|
4375
4603
|
});
|
|
@@ -4398,23 +4626,24 @@ var MediaChannel = class extends ThreadOnlyChannel {
|
|
|
4398
4626
|
};
|
|
4399
4627
|
|
|
4400
4628
|
// src/Domain/Channel/Factory.ts
|
|
4401
|
-
var
|
|
4629
|
+
var import_types21 = require("@fluxerjs/types");
|
|
4402
4630
|
var GUILD_FACTORIES = {
|
|
4403
|
-
[
|
|
4404
|
-
[
|
|
4405
|
-
[
|
|
4406
|
-
[
|
|
4407
|
-
[
|
|
4408
|
-
[
|
|
4409
|
-
[
|
|
4410
|
-
[
|
|
4411
|
-
[
|
|
4412
|
-
[
|
|
4631
|
+
[import_types21.ChannelType.GuildText]: (c, d) => new TextChannel(c, d),
|
|
4632
|
+
[import_types21.ChannelType.GuildAnnouncement]: (c, d) => new AnnouncementChannel(c, d),
|
|
4633
|
+
[import_types21.ChannelType.GuildCategory]: (c, d) => new CategoryChannel(c, d),
|
|
4634
|
+
[import_types21.ChannelType.GuildVoice]: (c, d) => new VoiceChannel(c, d),
|
|
4635
|
+
[import_types21.ChannelType.GuildStageVoice]: (c, d) => new StageChannel(c, d),
|
|
4636
|
+
[import_types21.ChannelType.GuildLink]: (c, d) => new LinkChannel(c, d),
|
|
4637
|
+
[import_types21.ChannelType.AnnouncementThread]: (c, d) => new ThreadChannel(c, d),
|
|
4638
|
+
[import_types21.ChannelType.PublicThread]: (c, d) => new ThreadChannel(c, d),
|
|
4639
|
+
[import_types21.ChannelType.PrivateThread]: (c, d) => new ThreadChannel(c, d),
|
|
4640
|
+
[import_types21.ChannelType.GuildForum]: (c, d) => new ForumChannel(c, d),
|
|
4641
|
+
[import_types21.ChannelType.GuildMedia]: (c, d) => new MediaChannel(c, d)
|
|
4413
4642
|
};
|
|
4414
4643
|
var DM_TYPES = /* @__PURE__ */ new Set([
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4644
|
+
import_types21.ChannelType.DM,
|
|
4645
|
+
import_types21.ChannelType.GroupDM,
|
|
4646
|
+
import_types21.ChannelType.DMPersonalNotes
|
|
4418
4647
|
]);
|
|
4419
4648
|
function createDM(client, data) {
|
|
4420
4649
|
return new DMChannel(client, data);
|
|
@@ -4434,11 +4663,11 @@ Channel.createDM = createDM;
|
|
|
4434
4663
|
bindThreadManager((channel) => new ThreadManager(channel));
|
|
4435
4664
|
|
|
4436
4665
|
// src/Domain/Guild/Cache.ts
|
|
4437
|
-
var
|
|
4666
|
+
var import_types28 = require("@fluxerjs/types");
|
|
4438
4667
|
|
|
4439
4668
|
// src/Domain/Guild/GuildEmoji.ts
|
|
4440
|
-
var
|
|
4441
|
-
var
|
|
4669
|
+
var import_types22 = require("@fluxerjs/types");
|
|
4670
|
+
var import_util15 = require("@fluxerjs/util");
|
|
4442
4671
|
var GuildEmoji = class extends Base {
|
|
4443
4672
|
client;
|
|
4444
4673
|
id;
|
|
@@ -4474,11 +4703,11 @@ var GuildEmoji = class extends Base {
|
|
|
4474
4703
|
}
|
|
4475
4704
|
/** Unix timestamp (ms) when this emoji was created, derived from its snowflake ID. */
|
|
4476
4705
|
get createdTimestamp() {
|
|
4477
|
-
return
|
|
4706
|
+
return import_util15.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4478
4707
|
}
|
|
4479
4708
|
/** Date when this emoji was created, derived from its snowflake ID. */
|
|
4480
4709
|
get createdAt() {
|
|
4481
|
-
return
|
|
4710
|
+
return import_util15.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4482
4711
|
}
|
|
4483
4712
|
/** Renders this emoji for use in message content: `<:name:id>` (or `<a:name:id>` when animated). */
|
|
4484
4713
|
toString() {
|
|
@@ -4486,7 +4715,7 @@ var GuildEmoji = class extends Base {
|
|
|
4486
4715
|
}
|
|
4487
4716
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
4488
4717
|
async delete(reason) {
|
|
4489
|
-
await this.client.rest.delete(
|
|
4718
|
+
await this.client.rest.delete(import_types22.Routes.guildEmoji(this.guildId, this.id), {
|
|
4490
4719
|
auth: true,
|
|
4491
4720
|
...auditReasonHeaders(reason)
|
|
4492
4721
|
});
|
|
@@ -4499,7 +4728,7 @@ var GuildEmoji = class extends Base {
|
|
|
4499
4728
|
*/
|
|
4500
4729
|
async edit(options) {
|
|
4501
4730
|
const { reason, name } = options;
|
|
4502
|
-
const data = await this.client.rest.patch(
|
|
4731
|
+
const data = await this.client.rest.patch(import_types22.Routes.guildEmoji(this.guildId, this.id), {
|
|
4503
4732
|
body: { name },
|
|
4504
4733
|
auth: true,
|
|
4505
4734
|
...auditReasonHeaders(reason)
|
|
@@ -4510,20 +4739,20 @@ var GuildEmoji = class extends Base {
|
|
|
4510
4739
|
};
|
|
4511
4740
|
|
|
4512
4741
|
// src/Domain/Guild/GuildMember.ts
|
|
4513
|
-
var
|
|
4514
|
-
var
|
|
4742
|
+
var import_types25 = require("@fluxerjs/types");
|
|
4743
|
+
var import_util17 = require("@fluxerjs/util");
|
|
4515
4744
|
|
|
4516
4745
|
// src/Helpers/Permissions.ts
|
|
4517
|
-
var
|
|
4518
|
-
var
|
|
4746
|
+
var import_types23 = require("@fluxerjs/types");
|
|
4747
|
+
var import_util16 = require("@fluxerjs/util");
|
|
4519
4748
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
4520
|
-
if (isOwner) return
|
|
4521
|
-
if ((basePermissions &
|
|
4522
|
-
return
|
|
4749
|
+
if (isOwner) return import_util16.ALL_PERMISSIONS_BIGINT;
|
|
4750
|
+
if ((basePermissions & import_util16.PermissionFlags.Administrator) !== 0n) {
|
|
4751
|
+
return import_util16.ALL_PERMISSIONS_BIGINT;
|
|
4523
4752
|
}
|
|
4524
4753
|
let perms = basePermissions;
|
|
4525
4754
|
for (const overwrite of overwrites ?? []) {
|
|
4526
|
-
const applies = overwrite.type ===
|
|
4755
|
+
const applies = overwrite.type === import_types23.OverwriteType.Role && memberRoles.includes(overwrite.id) || overwrite.type === import_types23.OverwriteType.Member && overwrite.id === memberId;
|
|
4527
4756
|
if (!applies) continue;
|
|
4528
4757
|
const allow = BigInt(overwrite.allow || "0");
|
|
4529
4758
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -4534,7 +4763,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
4534
4763
|
|
|
4535
4764
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
4536
4765
|
var import_collection7 = require("@fluxerjs/collection");
|
|
4537
|
-
var
|
|
4766
|
+
var import_types24 = require("@fluxerjs/types");
|
|
4538
4767
|
function roleId(roleOrId) {
|
|
4539
4768
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
4540
4769
|
}
|
|
@@ -4563,7 +4792,7 @@ var GuildMemberRoleManager = class {
|
|
|
4563
4792
|
const id = roleId(roleOrId);
|
|
4564
4793
|
if (this.ids.includes(id)) return;
|
|
4565
4794
|
await this.member.client.rest.put(
|
|
4566
|
-
|
|
4795
|
+
import_types24.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4567
4796
|
);
|
|
4568
4797
|
this.ids.push(id);
|
|
4569
4798
|
}
|
|
@@ -4572,13 +4801,13 @@ var GuildMemberRoleManager = class {
|
|
|
4572
4801
|
const idx = this.ids.indexOf(id);
|
|
4573
4802
|
if (idx === -1) return;
|
|
4574
4803
|
await this.member.client.rest.delete(
|
|
4575
|
-
|
|
4804
|
+
import_types24.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4576
4805
|
);
|
|
4577
4806
|
this.ids.splice(idx, 1);
|
|
4578
4807
|
}
|
|
4579
4808
|
async set(roleIds) {
|
|
4580
4809
|
const data = await this.member.client.rest.patch(
|
|
4581
|
-
|
|
4810
|
+
import_types24.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
4582
4811
|
{ body: { roles: roleIds }, auth: true }
|
|
4583
4812
|
);
|
|
4584
4813
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -4732,7 +4961,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4732
4961
|
*/
|
|
4733
4962
|
async edit(options) {
|
|
4734
4963
|
const isMe = this.client.user?.id === this.id;
|
|
4735
|
-
const route = isMe ?
|
|
4964
|
+
const route = isMe ? import_types25.Routes.guildMemberMe(this.guild.id) : import_types25.Routes.guildMember(this.guild.id, this.id);
|
|
4736
4965
|
const data = await this.client.rest.patch(route, {
|
|
4737
4966
|
body: toMemberEditBody(options),
|
|
4738
4967
|
auth: true,
|
|
@@ -4749,7 +4978,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4749
4978
|
* @see {@link permissionsIn} for channel-specific permissions
|
|
4750
4979
|
*/
|
|
4751
4980
|
get permissions() {
|
|
4752
|
-
return new
|
|
4981
|
+
return new import_util17.PermissionsBitField(this._effectivePermissions([], []));
|
|
4753
4982
|
}
|
|
4754
4983
|
/**
|
|
4755
4984
|
* Effective permissions in a channel (roles + overwrites).
|
|
@@ -4757,7 +4986,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4757
4986
|
* @returns Computed permissions bitfield
|
|
4758
4987
|
*/
|
|
4759
4988
|
permissionsIn(channel) {
|
|
4760
|
-
return new
|
|
4989
|
+
return new import_util17.PermissionsBitField(
|
|
4761
4990
|
this._effectivePermissions(channel.permissionOverwrites.toJSON(), [...this.roles.roleIds])
|
|
4762
4991
|
);
|
|
4763
4992
|
}
|
|
@@ -4782,19 +5011,19 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4782
5011
|
* False for the guild owner, self, or when the bot lacks Kick Members / role hierarchy.
|
|
4783
5012
|
*/
|
|
4784
5013
|
get kickable() {
|
|
4785
|
-
return this._moderatableWith(
|
|
5014
|
+
return this._moderatableWith(import_util17.PermissionFlags.KickMembers);
|
|
4786
5015
|
}
|
|
4787
5016
|
/**
|
|
4788
5017
|
* Whether the bot can ban this member (cache-only; needs `members.me`).
|
|
4789
5018
|
*/
|
|
4790
5019
|
get bannable() {
|
|
4791
|
-
return this._moderatableWith(
|
|
5020
|
+
return this._moderatableWith(import_util17.PermissionFlags.BanMembers);
|
|
4792
5021
|
}
|
|
4793
5022
|
/**
|
|
4794
5023
|
* Whether the bot can timeout this member (cache-only; needs `members.me`).
|
|
4795
5024
|
*/
|
|
4796
5025
|
get moderatable() {
|
|
4797
|
-
return this._moderatableWith(
|
|
5026
|
+
return this._moderatableWith(import_util17.PermissionFlags.ModerateMembers);
|
|
4798
5027
|
}
|
|
4799
5028
|
_moderatableWith(flag) {
|
|
4800
5029
|
const me = this.guild.members.me;
|
|
@@ -4845,8 +5074,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4845
5074
|
};
|
|
4846
5075
|
|
|
4847
5076
|
// src/Domain/Guild/GuildSticker.ts
|
|
4848
|
-
var
|
|
4849
|
-
var
|
|
5077
|
+
var import_types26 = require("@fluxerjs/types");
|
|
5078
|
+
var import_util18 = require("@fluxerjs/util");
|
|
4850
5079
|
var GuildSticker = class extends Base {
|
|
4851
5080
|
client;
|
|
4852
5081
|
id;
|
|
@@ -4888,15 +5117,15 @@ var GuildSticker = class extends Base {
|
|
|
4888
5117
|
}
|
|
4889
5118
|
/** Unix timestamp (ms) when this sticker was created, derived from its snowflake ID. */
|
|
4890
5119
|
get createdTimestamp() {
|
|
4891
|
-
return
|
|
5120
|
+
return import_util18.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4892
5121
|
}
|
|
4893
5122
|
/** Date when this sticker was created, derived from its snowflake ID. */
|
|
4894
5123
|
get createdAt() {
|
|
4895
|
-
return
|
|
5124
|
+
return import_util18.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4896
5125
|
}
|
|
4897
5126
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
4898
5127
|
async delete(reason) {
|
|
4899
|
-
await this.client.rest.delete(
|
|
5128
|
+
await this.client.rest.delete(import_types26.Routes.guildSticker(this.guildId, this.id), {
|
|
4900
5129
|
auth: true,
|
|
4901
5130
|
...auditReasonHeaders(reason)
|
|
4902
5131
|
});
|
|
@@ -4909,7 +5138,7 @@ var GuildSticker = class extends Base {
|
|
|
4909
5138
|
*/
|
|
4910
5139
|
async edit(options) {
|
|
4911
5140
|
const { reason, ...body } = options;
|
|
4912
|
-
const data = await this.client.rest.patch(
|
|
5141
|
+
const data = await this.client.rest.patch(import_types26.Routes.guildSticker(this.guildId, this.id), {
|
|
4913
5142
|
body,
|
|
4914
5143
|
auth: true,
|
|
4915
5144
|
...auditReasonHeaders(reason)
|
|
@@ -4922,8 +5151,8 @@ var GuildSticker = class extends Base {
|
|
|
4922
5151
|
};
|
|
4923
5152
|
|
|
4924
5153
|
// src/Domain/Guild/Role.ts
|
|
4925
|
-
var
|
|
4926
|
-
var
|
|
5154
|
+
var import_types27 = require("@fluxerjs/types");
|
|
5155
|
+
var import_util19 = require("@fluxerjs/util");
|
|
4927
5156
|
var Role = class _Role extends Base {
|
|
4928
5157
|
/** Parent client instance. */
|
|
4929
5158
|
client;
|
|
@@ -4974,8 +5203,8 @@ var Role = class _Role extends Base {
|
|
|
4974
5203
|
} catch {
|
|
4975
5204
|
bits = 0n;
|
|
4976
5205
|
}
|
|
4977
|
-
return new
|
|
4978
|
-
(bits &
|
|
5206
|
+
return new import_util19.PermissionsBitField(
|
|
5207
|
+
(bits & import_util19.PermissionFlags.Administrator) !== 0n ? import_util19.ALL_PERMISSIONS_BIGINT : bits
|
|
4979
5208
|
);
|
|
4980
5209
|
}
|
|
4981
5210
|
/**
|
|
@@ -4992,11 +5221,11 @@ var Role = class _Role extends Base {
|
|
|
4992
5221
|
*/
|
|
4993
5222
|
/** Unix timestamp (ms) when this role was created, derived from its snowflake ID. */
|
|
4994
5223
|
get createdTimestamp() {
|
|
4995
|
-
return
|
|
5224
|
+
return import_util19.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4996
5225
|
}
|
|
4997
5226
|
/** Date when this role was created, derived from its snowflake ID. */
|
|
4998
5227
|
get createdAt() {
|
|
4999
|
-
return
|
|
5228
|
+
return import_util19.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
5000
5229
|
}
|
|
5001
5230
|
toString() {
|
|
5002
5231
|
return `<@&${this.id}>`;
|
|
@@ -5042,7 +5271,7 @@ var Role = class _Role extends Base {
|
|
|
5042
5271
|
*/
|
|
5043
5272
|
async edit(options) {
|
|
5044
5273
|
const body = toRoleEditBody(options);
|
|
5045
|
-
const data = await this.client.rest.patch(
|
|
5274
|
+
const data = await this.client.rest.patch(import_types27.Routes.guildRole(this.guildId, this.id), {
|
|
5046
5275
|
body: Object.keys(body).length ? body : void 0,
|
|
5047
5276
|
auth: true,
|
|
5048
5277
|
...auditReasonHeaders(options.reason)
|
|
@@ -5055,7 +5284,7 @@ var Role = class _Role extends Base {
|
|
|
5055
5284
|
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
5056
5285
|
*/
|
|
5057
5286
|
async delete(reason) {
|
|
5058
|
-
await this.client.rest.delete(
|
|
5287
|
+
await this.client.rest.delete(import_types27.Routes.guildRole(this.guildId, this.id), {
|
|
5059
5288
|
auth: true,
|
|
5060
5289
|
...auditReasonHeaders(reason)
|
|
5061
5290
|
});
|
|
@@ -5156,7 +5385,7 @@ function syncChannels(guild, channels) {
|
|
|
5156
5385
|
}
|
|
5157
5386
|
}
|
|
5158
5387
|
function isThreadChannelType(type) {
|
|
5159
|
-
return type ===
|
|
5388
|
+
return type === import_types28.ChannelType.AnnouncementThread || type === import_types28.ChannelType.PublicThread || type === import_types28.ChannelType.PrivateThread;
|
|
5160
5389
|
}
|
|
5161
5390
|
function syncThreads(guild, threads, alsoKeep = /* @__PURE__ */ new Set()) {
|
|
5162
5391
|
const keep = new Set(alsoKeep);
|
|
@@ -5245,7 +5474,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5245
5474
|
async fetchFresh(channelId) {
|
|
5246
5475
|
try {
|
|
5247
5476
|
const data = assertApiObjectWithId(
|
|
5248
|
-
await this.client.rest.get(
|
|
5477
|
+
await this.client.rest.get(import_types29.Routes.channel(channelId)),
|
|
5249
5478
|
"channels.fetch()"
|
|
5250
5479
|
);
|
|
5251
5480
|
const existing = this.get(channelId);
|
|
@@ -5298,7 +5527,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5298
5527
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
5299
5528
|
});
|
|
5300
5529
|
const data = await this.client.rest.post(
|
|
5301
|
-
|
|
5530
|
+
import_types29.Routes.channelMessages(channelId),
|
|
5302
5531
|
postPayload
|
|
5303
5532
|
);
|
|
5304
5533
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -5309,12 +5538,12 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5309
5538
|
// src/ClientCore/Client.ts
|
|
5310
5539
|
var import_node_events3 = require("events");
|
|
5311
5540
|
var import_rest3 = require("@fluxerjs/rest");
|
|
5312
|
-
var
|
|
5313
|
-
var
|
|
5541
|
+
var import_types46 = require("@fluxerjs/types");
|
|
5542
|
+
var import_util27 = require("@fluxerjs/util");
|
|
5314
5543
|
|
|
5315
5544
|
// src/Domain/User.ts
|
|
5316
|
-
var
|
|
5317
|
-
var
|
|
5545
|
+
var import_types30 = require("@fluxerjs/types");
|
|
5546
|
+
var import_util20 = require("@fluxerjs/util");
|
|
5318
5547
|
var User = class extends Base {
|
|
5319
5548
|
/** Parent client instance. */
|
|
5320
5549
|
client;
|
|
@@ -5406,11 +5635,11 @@ var User = class extends Base {
|
|
|
5406
5635
|
*/
|
|
5407
5636
|
/** Unix timestamp (ms) when this account was created, derived from its snowflake ID. */
|
|
5408
5637
|
get createdTimestamp() {
|
|
5409
|
-
return
|
|
5638
|
+
return import_util20.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
5410
5639
|
}
|
|
5411
5640
|
/** Date when this account was created, derived from its snowflake ID. */
|
|
5412
5641
|
get createdAt() {
|
|
5413
|
-
return
|
|
5642
|
+
return import_util20.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
5414
5643
|
}
|
|
5415
5644
|
toString() {
|
|
5416
5645
|
return `<@${this.id}>`;
|
|
@@ -5420,7 +5649,7 @@ var User = class extends Base {
|
|
|
5420
5649
|
* @returns DM channel instance (cached if already open)
|
|
5421
5650
|
*/
|
|
5422
5651
|
async createDM() {
|
|
5423
|
-
const data = await this.client.rest.post(
|
|
5652
|
+
const data = await this.client.rest.post(import_types30.Routes.userMeChannels(), {
|
|
5424
5653
|
body: { recipient_id: this.id },
|
|
5425
5654
|
auth: true
|
|
5426
5655
|
});
|
|
@@ -5498,28 +5727,28 @@ function resolveCacheLimits(input) {
|
|
|
5498
5727
|
|
|
5499
5728
|
// src/ClientCore/ClientEmoji.ts
|
|
5500
5729
|
var import_collection9 = require("@fluxerjs/collection");
|
|
5501
|
-
var
|
|
5502
|
-
var
|
|
5730
|
+
var import_types31 = require("@fluxerjs/types");
|
|
5731
|
+
var import_util21 = require("@fluxerjs/util");
|
|
5503
5732
|
async function resolveClientEmoji(client, emoji, guildId) {
|
|
5504
5733
|
if (typeof emoji === "object" && emoji.id) {
|
|
5505
|
-
return (0,
|
|
5734
|
+
return (0, import_util21.formatEmoji)({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
5506
5735
|
}
|
|
5507
|
-
const parsed = (0,
|
|
5736
|
+
const parsed = (0, import_util21.parseEmoji)(
|
|
5508
5737
|
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
5509
5738
|
);
|
|
5510
5739
|
if (!parsed) {
|
|
5511
5740
|
throw new import_util4.FluxerError("Invalid emoji", { code: import_util3.ErrorCodes.InvalidEmoji });
|
|
5512
5741
|
}
|
|
5513
5742
|
if (parsed.id) {
|
|
5514
|
-
return (0,
|
|
5743
|
+
return (0, import_util21.formatEmoji)(parsed);
|
|
5515
5744
|
}
|
|
5516
5745
|
if (!/^\w+$/.test(parsed.name)) return parsed.name;
|
|
5517
|
-
const unicodeFromShortcode = (0,
|
|
5746
|
+
const unicodeFromShortcode = (0, import_util21.getUnicodeFromShortcode)(parsed.name);
|
|
5518
5747
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
5519
5748
|
if (guildId) {
|
|
5520
|
-
const emojis = await client.rest.get(
|
|
5749
|
+
const emojis = await client.rest.get(import_types31.Routes.guildEmojis(guildId));
|
|
5521
5750
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
5522
|
-
if (found) return (0,
|
|
5751
|
+
if (found) return (0, import_util21.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
5523
5752
|
throw new import_util4.FluxerError(
|
|
5524
5753
|
`Custom emoji ":${parsed.name}:" not found in guild. Use name:id or <:name:id> format.`,
|
|
5525
5754
|
{ code: import_util3.ErrorCodes.EmojiNotFound }
|
|
@@ -5534,26 +5763,26 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
5534
5763
|
return parsed.name;
|
|
5535
5764
|
}
|
|
5536
5765
|
async function fetchInstance(client) {
|
|
5537
|
-
const raw = await client.rest.get(
|
|
5766
|
+
const raw = await client.rest.get(import_types31.Routes.instanceDiscovery(), {
|
|
5538
5767
|
auth: false,
|
|
5539
5768
|
unversioned: true
|
|
5540
5769
|
});
|
|
5541
5770
|
return parseInstanceDiscovery(raw);
|
|
5542
5771
|
}
|
|
5543
5772
|
function fetchGatewayInfo(client) {
|
|
5544
|
-
return client.rest.get(
|
|
5773
|
+
return client.rest.get(import_types31.Routes.gatewayBot());
|
|
5545
5774
|
}
|
|
5546
5775
|
function fetchEmojiMetadata(client, emojiId) {
|
|
5547
|
-
return client.rest.get(
|
|
5776
|
+
return client.rest.get(import_types31.Routes.emojiMetadata(emojiId), { auth: true });
|
|
5548
5777
|
}
|
|
5549
5778
|
function fetchStickerMetadata(client, stickerId) {
|
|
5550
|
-
return client.rest.get(
|
|
5779
|
+
return client.rest.get(import_types31.Routes.stickerMetadata(stickerId), { auth: true });
|
|
5551
5780
|
}
|
|
5552
5781
|
function fetchApplication(client) {
|
|
5553
|
-
return client.rest.get(
|
|
5782
|
+
return client.rest.get(import_types31.Routes.applicationsMe(), { auth: true });
|
|
5554
5783
|
}
|
|
5555
5784
|
async function fetchOAuthApplications(client) {
|
|
5556
|
-
const data = await client.rest.get(
|
|
5785
|
+
const data = await client.rest.get(import_types31.Routes.oauth2ApplicationsMe(), { auth: true });
|
|
5557
5786
|
if (Array.isArray(data)) return data;
|
|
5558
5787
|
if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
|
|
5559
5788
|
return data.applications;
|
|
@@ -5572,14 +5801,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
5572
5801
|
}
|
|
5573
5802
|
function preloadMessages(client, channelIds) {
|
|
5574
5803
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
5575
|
-
return client.rest.post(
|
|
5804
|
+
return client.rest.post(import_types31.Routes.preloadMessages(), {
|
|
5576
5805
|
body: { channels: channelIds },
|
|
5577
5806
|
auth: true
|
|
5578
5807
|
});
|
|
5579
5808
|
}
|
|
5580
5809
|
function preloadMessagesAlt(client, channelIds) {
|
|
5581
5810
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
5582
|
-
return client.rest.post(
|
|
5811
|
+
return client.rest.post(import_types31.Routes.preloadMessagesAlt(), {
|
|
5583
5812
|
body: { channels: channelIds },
|
|
5584
5813
|
auth: true
|
|
5585
5814
|
});
|
|
@@ -5587,7 +5816,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
5587
5816
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
5588
5817
|
validateBulkMessageFetchRequests(requests);
|
|
5589
5818
|
const wire = toBulkFetchWire(requests);
|
|
5590
|
-
const data = await client.rest.post(
|
|
5819
|
+
const data = await client.rest.post(import_types31.Routes.channelsMessagesBulk(), {
|
|
5591
5820
|
body: { requests: wire },
|
|
5592
5821
|
auth: true
|
|
5593
5822
|
});
|
|
@@ -5604,7 +5833,7 @@ async function bulkFetchMessages(client, requests, options = {}) {
|
|
|
5604
5833
|
};
|
|
5605
5834
|
}
|
|
5606
5835
|
async function searchMessages(client, options = {}) {
|
|
5607
|
-
const data = await client.rest.post(
|
|
5836
|
+
const data = await client.rest.post(import_types31.Routes.searchMessages(), {
|
|
5608
5837
|
body: toMessageSearchBody(options),
|
|
5609
5838
|
auth: true
|
|
5610
5839
|
});
|
|
@@ -5612,19 +5841,19 @@ async function searchMessages(client, options = {}) {
|
|
|
5612
5841
|
}
|
|
5613
5842
|
function fetchEmojiSource(client, emojiId) {
|
|
5614
5843
|
return client.rest.get(
|
|
5615
|
-
|
|
5844
|
+
import_types31.Routes.emojiSource(emojiId),
|
|
5616
5845
|
{ auth: true }
|
|
5617
5846
|
);
|
|
5618
5847
|
}
|
|
5619
5848
|
function fetchStickerSource(client, stickerId) {
|
|
5620
5849
|
return client.rest.get(
|
|
5621
|
-
|
|
5850
|
+
import_types31.Routes.stickerSource(stickerId),
|
|
5622
5851
|
{ auth: true }
|
|
5623
5852
|
);
|
|
5624
5853
|
}
|
|
5625
5854
|
function fetchDiscoveryCategories(client) {
|
|
5626
5855
|
return client.rest.get(
|
|
5627
|
-
|
|
5856
|
+
import_types31.Routes.discoveryCategories(),
|
|
5628
5857
|
{ auth: true }
|
|
5629
5858
|
);
|
|
5630
5859
|
}
|
|
@@ -5639,18 +5868,18 @@ function searchDiscoveryGuilds(client, options = {}) {
|
|
|
5639
5868
|
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
5640
5869
|
const qs2 = params.toString();
|
|
5641
5870
|
return client.rest.get(
|
|
5642
|
-
qs2 ? `${
|
|
5871
|
+
qs2 ? `${import_types31.Routes.discoveryGuilds()}?${qs2}` : import_types31.Routes.discoveryGuilds(),
|
|
5643
5872
|
{ auth: true }
|
|
5644
5873
|
);
|
|
5645
5874
|
}
|
|
5646
5875
|
function fetchExperiments(client) {
|
|
5647
|
-
return client.rest.get(
|
|
5876
|
+
return client.rest.get(import_types31.Routes.experiments(), {
|
|
5648
5877
|
auth: true
|
|
5649
5878
|
});
|
|
5650
5879
|
}
|
|
5651
5880
|
function refreshAttachmentUrls(client, attachmentUrls) {
|
|
5652
5881
|
return client.rest.post(
|
|
5653
|
-
|
|
5882
|
+
import_types31.Routes.attachmentsRefreshUrls(),
|
|
5654
5883
|
{ body: { attachment_urls: attachmentUrls }, auth: true }
|
|
5655
5884
|
);
|
|
5656
5885
|
}
|
|
@@ -5662,13 +5891,13 @@ function fetchInstanceBadges(client, options = {}) {
|
|
|
5662
5891
|
if (options.version !== void 0) params.set("version", options.version);
|
|
5663
5892
|
const qs2 = params.toString();
|
|
5664
5893
|
return client.rest.get(
|
|
5665
|
-
qs2 ? `${
|
|
5894
|
+
qs2 ? `${import_types31.Routes.instanceBadges()}?${qs2}` : import_types31.Routes.instanceBadges(),
|
|
5666
5895
|
{ auth: false }
|
|
5667
5896
|
);
|
|
5668
5897
|
}
|
|
5669
5898
|
function fetchChannelPostData(client, channelId, threadIds) {
|
|
5670
5899
|
return client.rest.post(
|
|
5671
|
-
|
|
5900
|
+
import_types31.Routes.channelPostData(channelId),
|
|
5672
5901
|
{ body: { thread_ids: threadIds }, auth: true }
|
|
5673
5902
|
);
|
|
5674
5903
|
}
|
|
@@ -5691,12 +5920,12 @@ var import_ws = require("@fluxerjs/ws");
|
|
|
5691
5920
|
|
|
5692
5921
|
// src/Domain/Guild/Guild.ts
|
|
5693
5922
|
var import_collection12 = require("@fluxerjs/collection");
|
|
5694
|
-
var
|
|
5695
|
-
var
|
|
5923
|
+
var import_types41 = require("@fluxerjs/types");
|
|
5924
|
+
var import_util23 = require("@fluxerjs/util");
|
|
5696
5925
|
|
|
5697
5926
|
// src/ClientCore/GuildMemberManager.ts
|
|
5698
5927
|
var import_collection10 = require("@fluxerjs/collection");
|
|
5699
|
-
var
|
|
5928
|
+
var import_types32 = require("@fluxerjs/types");
|
|
5700
5929
|
var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
5701
5930
|
constructor(guild) {
|
|
5702
5931
|
super({ maxSize: guild.client.cache.limits.members });
|
|
@@ -5757,7 +5986,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5757
5986
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
5758
5987
|
if (options?.after) params.set("after", options.after);
|
|
5759
5988
|
const qs2 = params.toString();
|
|
5760
|
-
const url =
|
|
5989
|
+
const url = import_types32.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
5761
5990
|
const data = assertApiArray(
|
|
5762
5991
|
await this.guild.client.rest.get(url, { auth: true }),
|
|
5763
5992
|
"members.fetch()"
|
|
@@ -5784,7 +6013,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5784
6013
|
*/
|
|
5785
6014
|
async search(options = {}) {
|
|
5786
6015
|
const data = await this.guild.client.rest.post(
|
|
5787
|
-
|
|
6016
|
+
import_types32.Routes.guildMembersSearch(this.guild.id),
|
|
5788
6017
|
{ body: toMemberSearchBody(options), auth: true }
|
|
5789
6018
|
);
|
|
5790
6019
|
const offset = options.offset ?? 0;
|
|
@@ -5810,7 +6039,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5810
6039
|
};
|
|
5811
6040
|
|
|
5812
6041
|
// src/Domain/Guild/Admin.ts
|
|
5813
|
-
var
|
|
6042
|
+
var import_types33 = require("@fluxerjs/types");
|
|
5814
6043
|
function toAuditLogEntryPayload(entry, guildId) {
|
|
5815
6044
|
return {
|
|
5816
6045
|
id: entry.id,
|
|
@@ -5831,7 +6060,7 @@ function toVanityPayload(data) {
|
|
|
5831
6060
|
return { code: data.code ?? null, uses: data.uses };
|
|
5832
6061
|
}
|
|
5833
6062
|
async function fetchAuditLogs(guild, options) {
|
|
5834
|
-
const url =
|
|
6063
|
+
const url = import_types33.Routes.guildAuditLogs(guild.id) + qs({
|
|
5835
6064
|
limit: options?.limit,
|
|
5836
6065
|
before: options?.before,
|
|
5837
6066
|
after: options?.after,
|
|
@@ -5855,7 +6084,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
5855
6084
|
};
|
|
5856
6085
|
}
|
|
5857
6086
|
async function editGuild(guild, options) {
|
|
5858
|
-
const data = await guild.client.rest.patch(
|
|
6087
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guild(guild.id), {
|
|
5859
6088
|
body: toGuildEditBody(options),
|
|
5860
6089
|
auth: true
|
|
5861
6090
|
});
|
|
@@ -5863,13 +6092,13 @@ async function editGuild(guild, options) {
|
|
|
5863
6092
|
return guild;
|
|
5864
6093
|
}
|
|
5865
6094
|
async function fetchVanityURL(guild) {
|
|
5866
|
-
const data = await guild.client.rest.get(
|
|
6095
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5867
6096
|
auth: true
|
|
5868
6097
|
});
|
|
5869
6098
|
return toVanityPayload(data);
|
|
5870
6099
|
}
|
|
5871
6100
|
async function editVanityURL(guild, code) {
|
|
5872
|
-
const data = await guild.client.rest.patch(
|
|
6101
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5873
6102
|
body: { code },
|
|
5874
6103
|
auth: true
|
|
5875
6104
|
});
|
|
@@ -5877,14 +6106,14 @@ async function editVanityURL(guild, code) {
|
|
|
5877
6106
|
return toVanityPayload(data);
|
|
5878
6107
|
}
|
|
5879
6108
|
async function fetchDiscoveryStatus(guild) {
|
|
5880
|
-
const data = await guild.client.rest.get(
|
|
6109
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildDiscovery(guild.id), {
|
|
5881
6110
|
auth: true
|
|
5882
6111
|
});
|
|
5883
6112
|
return toDiscoveryStatusPayload(data);
|
|
5884
6113
|
}
|
|
5885
6114
|
async function applyForDiscovery(guild, options) {
|
|
5886
6115
|
const data = await guild.client.rest.post(
|
|
5887
|
-
|
|
6116
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5888
6117
|
{
|
|
5889
6118
|
body: toDiscoveryBody(options),
|
|
5890
6119
|
auth: true
|
|
@@ -5894,7 +6123,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
5894
6123
|
}
|
|
5895
6124
|
async function editDiscoveryApplication(guild, options) {
|
|
5896
6125
|
const data = await guild.client.rest.patch(
|
|
5897
|
-
|
|
6126
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5898
6127
|
{
|
|
5899
6128
|
body: toDiscoveryBody(options),
|
|
5900
6129
|
auth: true
|
|
@@ -5903,34 +6132,34 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
5903
6132
|
return toDiscoveryApplicationPayload(data);
|
|
5904
6133
|
}
|
|
5905
6134
|
async function withdrawDiscoveryApplication(guild) {
|
|
5906
|
-
await guild.client.rest.delete(
|
|
6135
|
+
await guild.client.rest.delete(import_types33.Routes.guildDiscovery(guild.id), { auth: true });
|
|
5907
6136
|
}
|
|
5908
6137
|
async function deleteGuild(guild, options) {
|
|
5909
6138
|
const body = options ? toSudoBody(options) : {};
|
|
5910
|
-
await guild.client.rest.post(
|
|
6139
|
+
await guild.client.rest.post(import_types33.Routes.guildDelete(guild.id), {
|
|
5911
6140
|
body,
|
|
5912
6141
|
auth: true
|
|
5913
6142
|
});
|
|
5914
6143
|
guild.client.guilds.delete(guild.id);
|
|
5915
6144
|
}
|
|
5916
6145
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
5917
|
-
await guild.client.rest.post(
|
|
6146
|
+
await guild.client.rest.post(import_types33.Routes.guildTransferOwnership(guild.id), {
|
|
5918
6147
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
5919
6148
|
auth: true
|
|
5920
6149
|
});
|
|
5921
6150
|
}
|
|
5922
6151
|
|
|
5923
6152
|
// src/Domain/Guild/Channels.ts
|
|
5924
|
-
var
|
|
6153
|
+
var import_types34 = require("@fluxerjs/types");
|
|
5925
6154
|
async function createChannel(guild, options) {
|
|
5926
|
-
const created = await guild.client.rest.post(
|
|
6155
|
+
const created = await guild.client.rest.post(import_types34.Routes.guildChannels(guild.id), {
|
|
5927
6156
|
body: toChannelCreateBody(options),
|
|
5928
6157
|
auth: true
|
|
5929
6158
|
});
|
|
5930
6159
|
return cacheChannel(guild, created);
|
|
5931
6160
|
}
|
|
5932
6161
|
async function fetchChannels(guild) {
|
|
5933
|
-
const raw = await guild.client.rest.get(
|
|
6162
|
+
const raw = await guild.client.rest.get(import_types34.Routes.guildChannels(guild.id));
|
|
5934
6163
|
if (!Array.isArray(raw))
|
|
5935
6164
|
throw new TypeError(
|
|
5936
6165
|
"guild.fetchChannels() received an invalid API payload (expected an array)"
|
|
@@ -5944,17 +6173,17 @@ async function fetchChannels(guild) {
|
|
|
5944
6173
|
return channels;
|
|
5945
6174
|
}
|
|
5946
6175
|
async function setChannelPositions(guild, updates) {
|
|
5947
|
-
await guild.client.rest.patch(
|
|
6176
|
+
await guild.client.rest.patch(import_types34.Routes.guildChannels(guild.id), {
|
|
5948
6177
|
body: toChannelPositionBody(updates),
|
|
5949
6178
|
auth: true
|
|
5950
6179
|
});
|
|
5951
6180
|
}
|
|
5952
6181
|
async function fetchWebhooks(guild) {
|
|
5953
|
-
const data = await guild.client.rest.get(
|
|
6182
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildWebhooks(guild.id));
|
|
5954
6183
|
return data.map((w) => new Webhook(guild.client, w));
|
|
5955
6184
|
}
|
|
5956
6185
|
async function fetchInvites(guild) {
|
|
5957
|
-
const data = await guild.client.rest.get(
|
|
6186
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildInvites(guild.id));
|
|
5958
6187
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
5959
6188
|
}
|
|
5960
6189
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -5974,14 +6203,14 @@ function resolveGuildOnlineCount(data) {
|
|
|
5974
6203
|
}
|
|
5975
6204
|
|
|
5976
6205
|
// src/Domain/Guild/Emojis.ts
|
|
5977
|
-
var
|
|
6206
|
+
var import_types35 = require("@fluxerjs/types");
|
|
5978
6207
|
async function fetchEmojis(guild) {
|
|
5979
|
-
const data = await guild.client.rest.get(
|
|
6208
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmojis(guild.id));
|
|
5980
6209
|
return data.map((e) => cacheEmoji(guild, e));
|
|
5981
6210
|
}
|
|
5982
6211
|
async function fetchEmoji(guild, emojiId) {
|
|
5983
6212
|
try {
|
|
5984
|
-
const data = await guild.client.rest.get(
|
|
6213
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmoji(guild.id, emojiId));
|
|
5985
6214
|
return cacheEmoji(guild, data);
|
|
5986
6215
|
} catch (err) {
|
|
5987
6216
|
rethrowMapped(err, {
|
|
@@ -5992,7 +6221,7 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
5992
6221
|
}
|
|
5993
6222
|
async function createEmoji(guild, options) {
|
|
5994
6223
|
const { reason, ...body } = options;
|
|
5995
|
-
const data = await guild.client.rest.post(
|
|
6224
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojis(guild.id), {
|
|
5996
6225
|
body,
|
|
5997
6226
|
auth: true,
|
|
5998
6227
|
...auditReasonHeaders(reason)
|
|
@@ -6000,7 +6229,7 @@ async function createEmoji(guild, options) {
|
|
|
6000
6229
|
return cacheEmoji(guild, data);
|
|
6001
6230
|
}
|
|
6002
6231
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
6003
|
-
const data = await guild.client.rest.post(
|
|
6232
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojisClone(guild.id), {
|
|
6004
6233
|
body: { source_emoji_id: sourceEmojiId },
|
|
6005
6234
|
auth: true
|
|
6006
6235
|
});
|
|
@@ -6008,7 +6237,7 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
6008
6237
|
}
|
|
6009
6238
|
async function createEmojisBulk(guild, emojis) {
|
|
6010
6239
|
const data = await guild.client.rest.post(
|
|
6011
|
-
|
|
6240
|
+
import_types35.Routes.guildEmojisBulk(guild.id),
|
|
6012
6241
|
{ body: { emojis }, auth: true }
|
|
6013
6242
|
);
|
|
6014
6243
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
@@ -6028,12 +6257,12 @@ var GuildRoleManager = class extends import_collection11.LimitedCollection {
|
|
|
6028
6257
|
};
|
|
6029
6258
|
|
|
6030
6259
|
// src/Domain/Guild/MemberHttp.ts
|
|
6031
|
-
var
|
|
6260
|
+
var import_types36 = require("@fluxerjs/types");
|
|
6032
6261
|
async function fetchMember(guild, userId) {
|
|
6033
6262
|
const id = normalizeSnowflakeId(userId, "members.fetch()");
|
|
6034
6263
|
try {
|
|
6035
6264
|
const data = await guild.client.rest.get(
|
|
6036
|
-
|
|
6265
|
+
import_types36.Routes.guildMember(guild.id, id)
|
|
6037
6266
|
);
|
|
6038
6267
|
if (!data?.user?.id) {
|
|
6039
6268
|
throw new TypeError("members.fetch() received an invalid API payload (missing user.id)");
|
|
@@ -6051,7 +6280,7 @@ async function fetchMember(guild, userId) {
|
|
|
6051
6280
|
}
|
|
6052
6281
|
async function fetchMe(guild) {
|
|
6053
6282
|
const data = await guild.client.rest.get(
|
|
6054
|
-
|
|
6283
|
+
import_types36.Routes.guildMemberMe(guild.id),
|
|
6055
6284
|
{ auth: true }
|
|
6056
6285
|
);
|
|
6057
6286
|
if (!data?.user?.id) {
|
|
@@ -6061,10 +6290,10 @@ async function fetchMe(guild) {
|
|
|
6061
6290
|
}
|
|
6062
6291
|
|
|
6063
6292
|
// src/Domain/Guild/Moderation.ts
|
|
6064
|
-
var
|
|
6293
|
+
var import_types38 = require("@fluxerjs/types");
|
|
6065
6294
|
|
|
6066
6295
|
// src/Domain/Guild/GuildBan.ts
|
|
6067
|
-
var
|
|
6296
|
+
var import_types37 = require("@fluxerjs/types");
|
|
6068
6297
|
function parseOptionalDate2(value) {
|
|
6069
6298
|
if (value == null || value === "") return null;
|
|
6070
6299
|
const date = new Date(value);
|
|
@@ -6091,7 +6320,7 @@ var GuildBan = class extends Base {
|
|
|
6091
6320
|
* Requires Ban Members permission.
|
|
6092
6321
|
*/
|
|
6093
6322
|
async unban(reason) {
|
|
6094
|
-
await this.client.rest.delete(
|
|
6323
|
+
await this.client.rest.delete(import_types37.Routes.guildBan(this.guildId, this.user.id), {
|
|
6095
6324
|
auth: true,
|
|
6096
6325
|
...auditReasonHeaders(reason)
|
|
6097
6326
|
});
|
|
@@ -6101,39 +6330,39 @@ var GuildBan = class extends Base {
|
|
|
6101
6330
|
// src/Domain/Guild/Moderation.ts
|
|
6102
6331
|
async function ban(guild, userId, options) {
|
|
6103
6332
|
const body = options ? toGuildBanBody(options) : {};
|
|
6104
|
-
await guild.client.rest.put(
|
|
6333
|
+
await guild.client.rest.put(import_types38.Routes.guildBan(guild.id, userId), {
|
|
6105
6334
|
body: Object.keys(body).length ? body : void 0,
|
|
6106
6335
|
auth: true,
|
|
6107
6336
|
...auditReasonHeaders(options?.reason)
|
|
6108
6337
|
});
|
|
6109
6338
|
}
|
|
6110
6339
|
async function fetchBan(guild, userId) {
|
|
6111
|
-
const data = await guild.client.rest.get(
|
|
6340
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBan(guild.id, userId));
|
|
6112
6341
|
return new GuildBan(guild.client, { ...data, guild_id: guild.id }, guild.id);
|
|
6113
6342
|
}
|
|
6114
6343
|
async function fetchBans(guild) {
|
|
6115
|
-
const data = await guild.client.rest.get(
|
|
6344
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBans(guild.id));
|
|
6116
6345
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
6117
6346
|
}
|
|
6118
6347
|
async function unban(guild, userId, reason) {
|
|
6119
|
-
await guild.client.rest.delete(
|
|
6348
|
+
await guild.client.rest.delete(import_types38.Routes.guildBan(guild.id, userId), {
|
|
6120
6349
|
auth: true,
|
|
6121
6350
|
...auditReasonHeaders(reason)
|
|
6122
6351
|
});
|
|
6123
6352
|
}
|
|
6124
6353
|
async function kick(guild, userId, reason) {
|
|
6125
|
-
await guild.client.rest.delete(
|
|
6354
|
+
await guild.client.rest.delete(import_types38.Routes.guildMember(guild.id, userId), {
|
|
6126
6355
|
auth: true,
|
|
6127
6356
|
...auditReasonHeaders(reason)
|
|
6128
6357
|
});
|
|
6129
6358
|
}
|
|
6130
6359
|
|
|
6131
6360
|
// src/Domain/Guild/Roles.ts
|
|
6132
|
-
var
|
|
6133
|
-
var
|
|
6361
|
+
var import_types39 = require("@fluxerjs/types");
|
|
6362
|
+
var import_util22 = require("@fluxerjs/util");
|
|
6134
6363
|
async function createRole(guild, options = {}) {
|
|
6135
6364
|
const body = toRoleCreateBody(options);
|
|
6136
|
-
const data = await guild.client.rest.post(
|
|
6365
|
+
const data = await guild.client.rest.post(import_types39.Routes.guildRoles(guild.id), {
|
|
6137
6366
|
body: Object.keys(body).length ? body : void 0,
|
|
6138
6367
|
auth: true,
|
|
6139
6368
|
...auditReasonHeaders(options.reason)
|
|
@@ -6141,14 +6370,14 @@ async function createRole(guild, options = {}) {
|
|
|
6141
6370
|
return cacheRole(guild, data);
|
|
6142
6371
|
}
|
|
6143
6372
|
async function fetchRoles(guild) {
|
|
6144
|
-
const data = await guild.client.rest.get(
|
|
6373
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
6145
6374
|
if (!Array.isArray(data))
|
|
6146
6375
|
throw new TypeError("guild.fetchRoles() received an invalid API payload (expected an array)");
|
|
6147
6376
|
return data.map((r) => cacheRole(guild, r));
|
|
6148
6377
|
}
|
|
6149
6378
|
async function fetchRole(guild, roleId2) {
|
|
6150
6379
|
try {
|
|
6151
|
-
const data = await guild.client.rest.get(
|
|
6380
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRole(guild.id, roleId2));
|
|
6152
6381
|
return cacheRole(guild, data);
|
|
6153
6382
|
} catch (err) {
|
|
6154
6383
|
rethrowMapped(err, {
|
|
@@ -6158,14 +6387,14 @@ async function fetchRole(guild, roleId2) {
|
|
|
6158
6387
|
}
|
|
6159
6388
|
}
|
|
6160
6389
|
async function resolveRoleId(guild, arg) {
|
|
6161
|
-
const parsed = (0,
|
|
6390
|
+
const parsed = (0, import_util22.parseRoleMention)(arg);
|
|
6162
6391
|
if (parsed) return parsed;
|
|
6163
6392
|
const trimmed = arg.trim();
|
|
6164
6393
|
if (/^\d{17,19}$/.test(trimmed)) return trimmed;
|
|
6165
6394
|
const needle = trimmed.toLowerCase();
|
|
6166
6395
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
6167
6396
|
if (cached) return cached.id;
|
|
6168
|
-
const roles = await guild.client.rest.get(
|
|
6397
|
+
const roles = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
6169
6398
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
6170
6399
|
if (!role) return null;
|
|
6171
6400
|
cacheRole(guild, role);
|
|
@@ -6174,7 +6403,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
6174
6403
|
async function setRolePositions(guild, updates) {
|
|
6175
6404
|
return replaceRoles(
|
|
6176
6405
|
guild,
|
|
6177
|
-
await guild.client.rest.patch(
|
|
6406
|
+
await guild.client.rest.patch(import_types39.Routes.guildRoles(guild.id), {
|
|
6178
6407
|
body: updates,
|
|
6179
6408
|
auth: true
|
|
6180
6409
|
})
|
|
@@ -6183,7 +6412,7 @@ async function setRolePositions(guild, updates) {
|
|
|
6183
6412
|
async function setRoleHoistPositions(guild, updates) {
|
|
6184
6413
|
return replaceRoles(
|
|
6185
6414
|
guild,
|
|
6186
|
-
await guild.client.rest.patch(
|
|
6415
|
+
await guild.client.rest.patch(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
6187
6416
|
body: updates.map((u) => ({
|
|
6188
6417
|
id: u.id,
|
|
6189
6418
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -6195,17 +6424,17 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
6195
6424
|
async function resetRoleHoistPositions(guild) {
|
|
6196
6425
|
return replaceRoles(
|
|
6197
6426
|
guild,
|
|
6198
|
-
await guild.client.rest.delete(
|
|
6427
|
+
await guild.client.rest.delete(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
6199
6428
|
auth: true
|
|
6200
6429
|
})
|
|
6201
6430
|
);
|
|
6202
6431
|
}
|
|
6203
6432
|
|
|
6204
6433
|
// src/Domain/Guild/Stickers.ts
|
|
6205
|
-
var
|
|
6434
|
+
var import_types40 = require("@fluxerjs/types");
|
|
6206
6435
|
async function createSticker(guild, options) {
|
|
6207
6436
|
const { reason, ...body } = options;
|
|
6208
|
-
const data = await guild.client.rest.post(
|
|
6437
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickers(guild.id), {
|
|
6209
6438
|
body,
|
|
6210
6439
|
auth: true,
|
|
6211
6440
|
...auditReasonHeaders(reason)
|
|
@@ -6213,7 +6442,7 @@ async function createSticker(guild, options) {
|
|
|
6213
6442
|
return cacheSticker(guild, data);
|
|
6214
6443
|
}
|
|
6215
6444
|
async function cloneSticker(guild, sourceStickerId) {
|
|
6216
|
-
const data = await guild.client.rest.post(
|
|
6445
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickersClone(guild.id), {
|
|
6217
6446
|
body: { source_sticker_id: sourceStickerId },
|
|
6218
6447
|
auth: true
|
|
6219
6448
|
});
|
|
@@ -6221,17 +6450,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
6221
6450
|
}
|
|
6222
6451
|
async function createStickersBulk(guild, stickers) {
|
|
6223
6452
|
const data = await guild.client.rest.post(
|
|
6224
|
-
|
|
6453
|
+
import_types40.Routes.guildStickersBulk(guild.id),
|
|
6225
6454
|
{ body: { stickers }, auth: true }
|
|
6226
6455
|
);
|
|
6227
6456
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
6228
6457
|
}
|
|
6229
6458
|
async function fetchStickers(guild) {
|
|
6230
|
-
const data = await guild.client.rest.get(
|
|
6459
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildStickers(guild.id));
|
|
6231
6460
|
return data.map((s) => cacheSticker(guild, s));
|
|
6232
6461
|
}
|
|
6233
6462
|
async function fetchSticker(guild, stickerId) {
|
|
6234
|
-
const data = await guild.client.rest.get(
|
|
6463
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildSticker(guild.id, stickerId));
|
|
6235
6464
|
return cacheSticker(guild, data);
|
|
6236
6465
|
}
|
|
6237
6466
|
|
|
@@ -6320,6 +6549,10 @@ var Guild = class extends Base {
|
|
|
6320
6549
|
emojis;
|
|
6321
6550
|
/** Cached stickers in this guild. */
|
|
6322
6551
|
stickers;
|
|
6552
|
+
/** Live stages in this guild's stage channels, keyed by stage instance ID. */
|
|
6553
|
+
stageInstances;
|
|
6554
|
+
/** Most participants a stage can have while speakers use video, or null if unknown. */
|
|
6555
|
+
maxStageVideoChannelUsers;
|
|
6323
6556
|
/**
|
|
6324
6557
|
* Construct a guild from API data.
|
|
6325
6558
|
* @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE
|
|
@@ -6336,6 +6569,7 @@ var Guild = class extends Base {
|
|
|
6336
6569
|
this.roles = new GuildRoleManager(this.id, { maxSize: client.cache.limits.roles });
|
|
6337
6570
|
this.emojis = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.emojis });
|
|
6338
6571
|
this.stickers = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.stickers });
|
|
6572
|
+
this.stageInstances = new import_collection12.Collection();
|
|
6339
6573
|
this.name = data.name ?? "";
|
|
6340
6574
|
this.icon = data.icon ?? null;
|
|
6341
6575
|
this.banner = data.banner ?? null;
|
|
@@ -6353,7 +6587,7 @@ var Guild = class extends Base {
|
|
|
6353
6587
|
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
6354
6588
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6355
6589
|
this.embedSplash = data.embed_splash ?? null;
|
|
6356
|
-
this.nsfwLevel = data.nsfw_level ??
|
|
6590
|
+
this.nsfwLevel = data.nsfw_level ?? import_types41.GuildNSFWLevel.Safe;
|
|
6357
6591
|
this.nsfw = data.nsfw ?? false;
|
|
6358
6592
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
6359
6593
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
@@ -6365,6 +6599,7 @@ var Guild = class extends Base {
|
|
|
6365
6599
|
this.bannerHeight = data.banner_height ?? null;
|
|
6366
6600
|
this.splashWidth = data.splash_width ?? null;
|
|
6367
6601
|
this.splashHeight = data.splash_height ?? null;
|
|
6602
|
+
this.maxStageVideoChannelUsers = data.max_stage_video_channel_users ?? null;
|
|
6368
6603
|
this.memberCount = resolveGuildMemberCount(data) ?? null;
|
|
6369
6604
|
this.onlineCount = resolveGuildOnlineCount(data) ?? null;
|
|
6370
6605
|
for (const r of data.roles ?? []) {
|
|
@@ -6401,7 +6636,7 @@ var Guild = class extends Base {
|
|
|
6401
6636
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6402
6637
|
}
|
|
6403
6638
|
if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
|
|
6404
|
-
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ??
|
|
6639
|
+
if (data.nsfw_level !== void 0) this.nsfwLevel = data.nsfw_level ?? import_types41.GuildNSFWLevel.Safe;
|
|
6405
6640
|
if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
|
|
6406
6641
|
if (data.content_warning_level !== void 0) {
|
|
6407
6642
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
@@ -6421,6 +6656,9 @@ var Guild = class extends Base {
|
|
|
6421
6656
|
if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
|
|
6422
6657
|
if (data.splash_width !== void 0) this.splashWidth = data.splash_width ?? null;
|
|
6423
6658
|
if (data.splash_height !== void 0) this.splashHeight = data.splash_height ?? null;
|
|
6659
|
+
if (data.max_stage_video_channel_users !== void 0) {
|
|
6660
|
+
this.maxStageVideoChannelUsers = data.max_stage_video_channel_users ?? null;
|
|
6661
|
+
}
|
|
6424
6662
|
const memberCount = resolveGuildMemberCount(data);
|
|
6425
6663
|
if (memberCount !== void 0) this.memberCount = memberCount;
|
|
6426
6664
|
const onlineCount = resolveGuildOnlineCount(data);
|
|
@@ -6436,11 +6674,11 @@ var Guild = class extends Base {
|
|
|
6436
6674
|
}
|
|
6437
6675
|
/** Unix timestamp (ms) when this guild was created, derived from its snowflake ID. */
|
|
6438
6676
|
get createdTimestamp() {
|
|
6439
|
-
return
|
|
6677
|
+
return import_util23.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
6440
6678
|
}
|
|
6441
6679
|
/** Date when this guild was created, derived from its snowflake ID. */
|
|
6442
6680
|
get createdAt() {
|
|
6443
|
-
return
|
|
6681
|
+
return import_util23.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
6444
6682
|
}
|
|
6445
6683
|
/** The guild's name. */
|
|
6446
6684
|
toString() {
|
|
@@ -6641,7 +6879,7 @@ var Guild = class extends Base {
|
|
|
6641
6879
|
};
|
|
6642
6880
|
|
|
6643
6881
|
// src/Domain/Guild/Payload.ts
|
|
6644
|
-
var
|
|
6882
|
+
var import_util24 = require("@fluxerjs/util");
|
|
6645
6883
|
var TOP_LEVEL_COUNT_KEYS = [
|
|
6646
6884
|
"member_count",
|
|
6647
6885
|
"online_count",
|
|
@@ -6681,10 +6919,10 @@ function mergeTopLevelSnapshotFields(properties, raw) {
|
|
|
6681
6919
|
return out;
|
|
6682
6920
|
}
|
|
6683
6921
|
function normalizeGuildSnapshotPayload(raw) {
|
|
6684
|
-
if (!(0,
|
|
6922
|
+
if (!(0, import_util24.isRecord)(raw)) return null;
|
|
6685
6923
|
const flatPayload = isHydratableGuildPayload(raw) && (raw.roles === void 0 || Array.isArray(raw.roles)) ? raw : null;
|
|
6686
6924
|
let nestedPayload = null;
|
|
6687
|
-
if (Object.hasOwn(raw, "properties") && (0,
|
|
6925
|
+
if (Object.hasOwn(raw, "properties") && (0, import_util24.isRecord)(raw.properties)) {
|
|
6688
6926
|
const properties = raw.properties;
|
|
6689
6927
|
const rolesValid = raw.roles === void 0 || Array.isArray(raw.roles);
|
|
6690
6928
|
if (rolesValid && isHydratableGuildPayload(properties) && raw.id === properties.id) {
|
|
@@ -6696,7 +6934,7 @@ function normalizeGuildSnapshotPayload(raw) {
|
|
|
6696
6934
|
return flatPayload ?? nestedPayload;
|
|
6697
6935
|
}
|
|
6698
6936
|
function normalizeGuildUpdatePayload(raw) {
|
|
6699
|
-
if (!(0,
|
|
6937
|
+
if (!(0, import_util24.isRecord)(raw) || !isValidGuildPayload(raw)) return null;
|
|
6700
6938
|
return raw;
|
|
6701
6939
|
}
|
|
6702
6940
|
|
|
@@ -6726,6 +6964,8 @@ function upsertGuildFromSnapshot(client, guildData, resources = {}) {
|
|
|
6726
6964
|
if (resources.members !== void 0) mergeMembers(guild, resources.members);
|
|
6727
6965
|
if (resources.emojis !== void 0) syncEmojis(guild, resources.emojis);
|
|
6728
6966
|
if (resources.stickers !== void 0) syncStickers(guild, resources.stickers);
|
|
6967
|
+
if (resources.stageInstances !== void 0) syncStageInstances(guild, resources.stageInstances);
|
|
6968
|
+
if (resources.stageCounts !== void 0) applyStageCounts(guild, resources.stageCounts);
|
|
6729
6969
|
if (resources.channels !== void 0) guild.partial = false;
|
|
6730
6970
|
return { guild, created, recovered };
|
|
6731
6971
|
}
|
|
@@ -6740,7 +6980,9 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6740
6980
|
emojis: g.emojis,
|
|
6741
6981
|
stickers: g.stickers,
|
|
6742
6982
|
// A channel list without `threads` means this session has no viewable threads.
|
|
6743
|
-
threads: g.channels !== void 0 ? g.threads ?? [] : g.threads
|
|
6983
|
+
threads: g.channels !== void 0 ? g.threads ?? [] : g.threads,
|
|
6984
|
+
stageInstances: g.stage_instances,
|
|
6985
|
+
stageCounts: g.stage_counts
|
|
6744
6986
|
});
|
|
6745
6987
|
if (g.voice_states?.length) {
|
|
6746
6988
|
client.emit(Events.VoiceStatesSync, {
|
|
@@ -6752,23 +6994,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6752
6994
|
}
|
|
6753
6995
|
|
|
6754
6996
|
// src/ClientCore/ClientUser.ts
|
|
6755
|
-
var
|
|
6997
|
+
var import_types42 = require("@fluxerjs/types");
|
|
6756
6998
|
var ClientUser = class extends User {
|
|
6757
6999
|
/** Broadcast presence (gateway opcode 3) on all shards. */
|
|
6758
7000
|
setPresence(presence) {
|
|
6759
7001
|
this.client.options.presence = presence;
|
|
6760
7002
|
const wire = toPresenceWire(presence);
|
|
6761
|
-
this.client._sendToAllShards({ op:
|
|
7003
|
+
this.client._sendToAllShards({ op: import_types42.GatewayOpcodes.PresenceUpdate, d: wire });
|
|
6762
7004
|
}
|
|
6763
7005
|
/** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
|
|
6764
7006
|
async fetch() {
|
|
6765
|
-
const data = await this.client.rest.get(
|
|
7007
|
+
const data = await this.client.rest.get(import_types42.Routes.currentUser(), { auth: true });
|
|
6766
7008
|
this._patch(data);
|
|
6767
7009
|
return this;
|
|
6768
7010
|
}
|
|
6769
7011
|
/** GET /users/@me/guilds — returns camelCase partial guilds. */
|
|
6770
7012
|
async fetchGuilds(options) {
|
|
6771
|
-
const path =
|
|
7013
|
+
const path = import_types42.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
|
|
6772
7014
|
const data = await this.client.rest.get(path, { auth: true });
|
|
6773
7015
|
return data.map((g) => ({
|
|
6774
7016
|
id: g.id,
|
|
@@ -6792,7 +7034,7 @@ var ClientUser = class extends User {
|
|
|
6792
7034
|
*/
|
|
6793
7035
|
async leaveGuild(guildId, options) {
|
|
6794
7036
|
const body = options ? toSudoBody(options) : void 0;
|
|
6795
|
-
await this.client.rest.delete(
|
|
7037
|
+
await this.client.rest.delete(import_types42.Routes.leaveGuild(guildId), {
|
|
6796
7038
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6797
7039
|
auth: true
|
|
6798
7040
|
});
|
|
@@ -6800,7 +7042,7 @@ var ClientUser = class extends User {
|
|
|
6800
7042
|
/** Delete every message authored by the caller across a guild (sudo). */
|
|
6801
7043
|
async bulkDeleteMyMessagesInGuild(guildId, options) {
|
|
6802
7044
|
const body = options ? toSudoBody(options) : void 0;
|
|
6803
|
-
await this.client.rest.post(
|
|
7045
|
+
await this.client.rest.post(import_types42.Routes.guildBulkDeleteMine(guildId), {
|
|
6804
7046
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6805
7047
|
auth: true
|
|
6806
7048
|
});
|
|
@@ -6808,7 +7050,7 @@ var ClientUser = class extends User {
|
|
|
6808
7050
|
};
|
|
6809
7051
|
|
|
6810
7052
|
// src/ClientCore/EventHandlers/Helpers.ts
|
|
6811
|
-
var
|
|
7053
|
+
var import_util25 = require("@fluxerjs/util");
|
|
6812
7054
|
function unknownUser(id) {
|
|
6813
7055
|
return { id };
|
|
6814
7056
|
}
|
|
@@ -7115,50 +7357,50 @@ var guildHandlers = {
|
|
|
7115
7357
|
};
|
|
7116
7358
|
|
|
7117
7359
|
// src/ClientCore/EventHandlers/Invites.ts
|
|
7118
|
-
var
|
|
7360
|
+
var import_types43 = require("@fluxerjs/types");
|
|
7119
7361
|
function normalizeInviteCreate(client, payload) {
|
|
7120
|
-
const raw = (0,
|
|
7121
|
-
const code = (0,
|
|
7362
|
+
const raw = (0, import_util25.asRecord)(payload);
|
|
7363
|
+
const code = (0, import_util25.str)(raw?.code);
|
|
7122
7364
|
if (!raw || !code) return null;
|
|
7123
|
-
const typeNum = (0,
|
|
7124
|
-
const type = typeNum ===
|
|
7365
|
+
const typeNum = (0, import_util25.num)(raw.type);
|
|
7366
|
+
const type = typeNum === import_types43.InviteType.GroupDM ? import_types43.InviteType.GroupDM : import_types43.InviteType.Guild;
|
|
7125
7367
|
const shared = {
|
|
7126
7368
|
code,
|
|
7127
7369
|
inviter: raw.inviter ?? null,
|
|
7128
|
-
member_count: (0,
|
|
7370
|
+
member_count: (0, import_util25.num)(raw.member_count),
|
|
7129
7371
|
expires_at: raw.expires_at ?? void 0,
|
|
7130
7372
|
temporary: typeof raw.temporary === "boolean" ? raw.temporary : void 0,
|
|
7131
|
-
created_at: (0,
|
|
7132
|
-
uses: (0,
|
|
7133
|
-
max_uses: (0,
|
|
7134
|
-
max_age: (0,
|
|
7373
|
+
created_at: (0, import_util25.str)(raw.created_at),
|
|
7374
|
+
uses: (0, import_util25.num)(raw.uses),
|
|
7375
|
+
max_uses: (0, import_util25.num)(raw.max_uses),
|
|
7376
|
+
max_age: (0, import_util25.num)(raw.max_age)
|
|
7135
7377
|
};
|
|
7136
|
-
const guildObj = (0,
|
|
7137
|
-
const channelObj = (0,
|
|
7138
|
-
const guildId = (0,
|
|
7139
|
-
const channelId = (0,
|
|
7378
|
+
const guildObj = (0, import_util25.asRecord)(raw.guild);
|
|
7379
|
+
const channelObj = (0, import_util25.asRecord)(raw.channel);
|
|
7380
|
+
const guildId = (0, import_util25.str)(guildObj?.id) ?? (0, import_util25.str)(raw.guild_id) ?? "0";
|
|
7381
|
+
const channelId = (0, import_util25.str)(channelObj?.id) ?? (0, import_util25.str)(raw.channel_id) ?? "0";
|
|
7140
7382
|
const cachedGuild = guildId !== "0" ? client.guilds.get(guildId) : null;
|
|
7141
7383
|
const cachedChannel2 = channelId !== "0" ? client.channels.get(channelId) : null;
|
|
7142
7384
|
const channel = {
|
|
7143
7385
|
id: channelId,
|
|
7144
|
-
type: (0,
|
|
7145
|
-
name: (0,
|
|
7386
|
+
type: (0, import_util25.num)(channelObj?.type) ?? cachedChannel2?.type ?? import_types43.ChannelType.GuildText,
|
|
7387
|
+
name: (0, import_util25.str)(channelObj?.name) ?? cachedChannel2?.name ?? null,
|
|
7146
7388
|
icon: channelObj?.icon ?? null
|
|
7147
7389
|
};
|
|
7148
|
-
if (type ===
|
|
7390
|
+
if (type === import_types43.InviteType.GroupDM) return { ...shared, type, channel };
|
|
7149
7391
|
return {
|
|
7150
7392
|
...shared,
|
|
7151
|
-
type:
|
|
7393
|
+
type: import_types43.InviteType.Guild,
|
|
7152
7394
|
guild: {
|
|
7153
7395
|
id: guildId,
|
|
7154
|
-
name: (0,
|
|
7396
|
+
name: (0, import_util25.str)(guildObj?.name) ?? cachedGuild?.name ?? "Unknown Guild",
|
|
7155
7397
|
icon: guildObj?.icon ?? null,
|
|
7156
7398
|
banner: guildObj?.banner ?? null,
|
|
7157
7399
|
splash: guildObj?.splash ?? null,
|
|
7158
7400
|
features: Array.isArray(guildObj?.features) ? guildObj.features : void 0
|
|
7159
7401
|
},
|
|
7160
7402
|
channel,
|
|
7161
|
-
presence_count: (0,
|
|
7403
|
+
presence_count: (0, import_util25.num)(raw.presence_count)
|
|
7162
7404
|
};
|
|
7163
7405
|
}
|
|
7164
7406
|
var inviteHandlers = {
|
|
@@ -7269,7 +7511,7 @@ var memberHandlers = {
|
|
|
7269
7511
|
};
|
|
7270
7512
|
|
|
7271
7513
|
// src/ClientCore/EventHandlers/Messages.ts
|
|
7272
|
-
var
|
|
7514
|
+
var import_util26 = require("@fluxerjs/util");
|
|
7273
7515
|
function cachedTextChannel(client, channelId) {
|
|
7274
7516
|
const channel = client.channels.get(channelId);
|
|
7275
7517
|
return channel?.isTextBased() ? channel : null;
|
|
@@ -7285,7 +7527,7 @@ function toPartialMessage(client, args) {
|
|
|
7285
7527
|
const cached = args.cached;
|
|
7286
7528
|
const authorId = args.authorId ?? cached?.author?.id ?? null;
|
|
7287
7529
|
const author = cached?.author ? client.getOrCreateUser(cached.author) : authorId ? client.users.get(authorId) ?? null : null;
|
|
7288
|
-
const createdAt = cached?.timestamp ? new Date(cached.timestamp) :
|
|
7530
|
+
const createdAt = cached?.timestamp ? new Date(cached.timestamp) : import_util26.SnowflakeUtil.isValid(args.id) ? import_util26.SnowflakeUtil.dateFromSnowflake(args.id) : null;
|
|
7289
7531
|
return new PartialMessage(client, {
|
|
7290
7532
|
id: args.id,
|
|
7291
7533
|
channelId: args.channelId,
|
|
@@ -7549,6 +7791,46 @@ var passthroughHandlers = {
|
|
|
7549
7791
|
WEBAUTHN_CREDENTIALS_UPDATE: pass(Events.WebAuthnCredentialsUpdate)
|
|
7550
7792
|
};
|
|
7551
7793
|
|
|
7794
|
+
// src/ClientCore/EventHandlers/Stages.ts
|
|
7795
|
+
var stageHandlers = {
|
|
7796
|
+
STAGE_INSTANCE_CREATE(client, d) {
|
|
7797
|
+
const instance = cacheStageInstance(client, d);
|
|
7798
|
+
client.emit(Events.StageInstanceCreate, instance);
|
|
7799
|
+
},
|
|
7800
|
+
STAGE_INSTANCE_UPDATE(client, d) {
|
|
7801
|
+
const data = d;
|
|
7802
|
+
const cached = client.guilds.get(data.guild_id)?.stageInstances.get(data.id);
|
|
7803
|
+
const old = cached ? new StageInstance(client, cached.toJSON()) : null;
|
|
7804
|
+
const instance = cacheStageInstance(client, data);
|
|
7805
|
+
client.emit(Events.StageInstanceUpdate, old, instance);
|
|
7806
|
+
},
|
|
7807
|
+
STAGE_INSTANCE_DELETE(client, d) {
|
|
7808
|
+
const data = d;
|
|
7809
|
+
const guild = client.guilds.get(data.guild_id);
|
|
7810
|
+
const instance = guild?.stageInstances.get(data.id) ?? new StageInstance(client, data);
|
|
7811
|
+
instance._patch(data);
|
|
7812
|
+
guild?.stageInstances.delete(data.id);
|
|
7813
|
+
client.emit(Events.StageInstanceDelete, instance);
|
|
7814
|
+
},
|
|
7815
|
+
STAGE_COUNTS_UPDATE(client, d) {
|
|
7816
|
+
const data = d;
|
|
7817
|
+
const channel = client.channels.get(data.channel_id);
|
|
7818
|
+
if (channel?.isStage()) channel._patchCounts(data);
|
|
7819
|
+
const payload = {
|
|
7820
|
+
guildId: data.guild_id,
|
|
7821
|
+
channelId: data.channel_id,
|
|
7822
|
+
listenerCount: data.listener_count,
|
|
7823
|
+
speakerCount: data.speaker_count,
|
|
7824
|
+
requestCount: data.request_count,
|
|
7825
|
+
videoEnabled: data.video_enabled ?? null
|
|
7826
|
+
};
|
|
7827
|
+
client.emit(Events.StageCountsUpdate, payload);
|
|
7828
|
+
},
|
|
7829
|
+
STAGE_VOICE_STATES_SYNC: pass(Events.StageVoiceStatesSync),
|
|
7830
|
+
STAGE_AUDIENCE_LIST_UPDATE: pass(Events.StageAudienceListUpdate),
|
|
7831
|
+
VOICE_JOIN_QUEUED: pass(Events.VoiceJoinQueued)
|
|
7832
|
+
};
|
|
7833
|
+
|
|
7552
7834
|
// src/ClientCore/EventHandlers/Threads.ts
|
|
7553
7835
|
function cachedChannel(client, id) {
|
|
7554
7836
|
const direct = client.channels.get(id);
|
|
@@ -7659,7 +7941,8 @@ var eventHandlers = buildRegistry(
|
|
|
7659
7941
|
inviteHandlers,
|
|
7660
7942
|
guildResourceHandlers,
|
|
7661
7943
|
passthroughHandlers,
|
|
7662
|
-
threadHandlers
|
|
7944
|
+
threadHandlers,
|
|
7945
|
+
stageHandlers
|
|
7663
7946
|
);
|
|
7664
7947
|
|
|
7665
7948
|
// src/ClientCore/GatewayDispatch.ts
|
|
@@ -7919,7 +8202,7 @@ async function connectClientGateway(client, token, signal) {
|
|
|
7919
8202
|
|
|
7920
8203
|
// src/ClientCore/GuildManager.ts
|
|
7921
8204
|
var import_collection13 = require("@fluxerjs/collection");
|
|
7922
|
-
var
|
|
8205
|
+
var import_types44 = require("@fluxerjs/types");
|
|
7923
8206
|
var GuildManager = class extends import_collection13.LimitedCollection {
|
|
7924
8207
|
constructor(client) {
|
|
7925
8208
|
super({
|
|
@@ -7979,7 +8262,7 @@ var GuildManager = class extends import_collection13.LimitedCollection {
|
|
|
7979
8262
|
return dedupeFetch(this.pendingFetches, id, async () => {
|
|
7980
8263
|
try {
|
|
7981
8264
|
const data = assertApiObjectWithId(
|
|
7982
|
-
await this.client.rest.get(
|
|
8265
|
+
await this.client.rest.get(import_types44.Routes.guild(id)),
|
|
7983
8266
|
"guilds.fetch()"
|
|
7984
8267
|
);
|
|
7985
8268
|
let guild;
|
|
@@ -8088,7 +8371,7 @@ var MessageCache = class {
|
|
|
8088
8371
|
|
|
8089
8372
|
// src/ClientCore/UserManager.ts
|
|
8090
8373
|
var import_collection14 = require("@fluxerjs/collection");
|
|
8091
|
-
var
|
|
8374
|
+
var import_types45 = require("@fluxerjs/types");
|
|
8092
8375
|
var soft = (p) => p.catch(() => null);
|
|
8093
8376
|
var UserManager = class extends import_collection14.LimitedCollection {
|
|
8094
8377
|
constructor(client) {
|
|
@@ -8122,7 +8405,7 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
8122
8405
|
id,
|
|
8123
8406
|
async () => this.client.getOrCreateUser(
|
|
8124
8407
|
assertApiObjectWithId(
|
|
8125
|
-
await this.client.rest.get(
|
|
8408
|
+
await this.client.rest.get(import_types45.Routes.user(id)),
|
|
8126
8409
|
"users.fetch()"
|
|
8127
8410
|
)
|
|
8128
8411
|
)
|
|
@@ -8145,10 +8428,10 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
8145
8428
|
async fetchWithProfile(userId, options) {
|
|
8146
8429
|
const guildId = options?.guildId ?? void 0;
|
|
8147
8430
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
8148
|
-
this.client.rest.get(
|
|
8149
|
-
soft(this.client.rest.get(
|
|
8150
|
-
guildId ? soft(this.client.rest.get(
|
|
8151
|
-
guildId ? soft(this.client.rest.get(
|
|
8431
|
+
this.client.rest.get(import_types45.Routes.user(userId)),
|
|
8432
|
+
soft(this.client.rest.get(import_types45.Routes.userProfile(userId))),
|
|
8433
|
+
guildId ? soft(this.client.rest.get(import_types45.Routes.userProfile(userId, guildId))) : null,
|
|
8434
|
+
guildId ? soft(this.client.rest.get(import_types45.Routes.guildMember(guildId, userId))) : null
|
|
8152
8435
|
]);
|
|
8153
8436
|
const user = this.client.getOrCreateUser(userData);
|
|
8154
8437
|
let member = null;
|
|
@@ -8235,7 +8518,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8235
8518
|
cache: resolved.cache,
|
|
8236
8519
|
defaultReplyPing: options.defaultReplyPing ?? true
|
|
8237
8520
|
};
|
|
8238
|
-
this.logger = options.logger ?? (0,
|
|
8521
|
+
this.logger = options.logger ?? (0, import_util27.createLogger)({
|
|
8239
8522
|
level: options.logLevel ?? "warn"
|
|
8240
8523
|
});
|
|
8241
8524
|
this.cache = new CacheController(this, resolved.limits);
|
|
@@ -8529,7 +8812,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8529
8812
|
if (options.userIds !== void 0) data.user_ids = [...new Set(options.userIds)];
|
|
8530
8813
|
if (options.presences !== void 0) data.presences = options.presences;
|
|
8531
8814
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8532
|
-
this._sendToAllShards({ op:
|
|
8815
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildMembers, d: data });
|
|
8533
8816
|
}
|
|
8534
8817
|
/**
|
|
8535
8818
|
* Request guild member/online counts via gateway opcode 15.
|
|
@@ -8544,7 +8827,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8544
8827
|
}
|
|
8545
8828
|
const data = { guild_ids: guildIds };
|
|
8546
8829
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8547
|
-
this._sendToAllShards({ op:
|
|
8830
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildCounts, d: data });
|
|
8548
8831
|
}
|
|
8549
8832
|
/**
|
|
8550
8833
|
* Request per-channel member counts via gateway opcode 16.
|
|
@@ -8560,7 +8843,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8560
8843
|
if (options.channelId !== void 0) data.channel_id = options.channelId;
|
|
8561
8844
|
if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
|
|
8562
8845
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8563
|
-
this._sendToAllShards({ op:
|
|
8846
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestChannelMemberCounts, d: data });
|
|
8564
8847
|
}
|
|
8565
8848
|
/**
|
|
8566
8849
|
* Request unread counts for posts in one forum or media channel (opcode 28).
|
|
@@ -8596,7 +8879,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8596
8879
|
channel_id: options.channelId,
|
|
8597
8880
|
threads
|
|
8598
8881
|
};
|
|
8599
|
-
this._sendToAllShards({ op:
|
|
8882
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestForumUnreads, d: data });
|
|
8600
8883
|
}
|
|
8601
8884
|
/**
|
|
8602
8885
|
* Subscribe to thread traffic in a guild (opcode 14).
|
|
@@ -8626,7 +8909,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8626
8909
|
subscription.thread_member_lists = threadIds;
|
|
8627
8910
|
}
|
|
8628
8911
|
const data = { subscriptions: { [options.guildId]: subscription } };
|
|
8629
|
-
this._sendToAllShards({ op:
|
|
8912
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.LazyRequest, d: data });
|
|
8630
8913
|
}
|
|
8631
8914
|
/**
|
|
8632
8915
|
* Broadcast a gateway payload to all shards.
|
|
@@ -8731,7 +9014,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8731
9014
|
* @see {@link Routes}
|
|
8732
9015
|
*/
|
|
8733
9016
|
static get Routes() {
|
|
8734
|
-
return
|
|
9017
|
+
return import_types46.Routes;
|
|
8735
9018
|
}
|
|
8736
9019
|
};
|
|
8737
9020
|
|
|
@@ -9148,6 +9431,8 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
9148
9431
|
Routes,
|
|
9149
9432
|
STATIC_CDN_URL,
|
|
9150
9433
|
SplashCardAlignment,
|
|
9434
|
+
StageChannel,
|
|
9435
|
+
StageInstance,
|
|
9151
9436
|
SystemChannelFlags,
|
|
9152
9437
|
TextChannel,
|
|
9153
9438
|
ThreadAutoArchiveDuration,
|