@fluxerjs/core 3.3.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-CNJlnR6y.d.mts → SubpathMessage-3ykAJr_F.d.mts} +250 -12
- package/dist/{SubpathMessage-DjLo6il5.d.ts → SubpathMessage-nY2WQ8V1.d.ts} +250 -12
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1039 -358
- package/dist/client.mjs +959 -278
- package/dist/cluster.d.mts +1 -1
- package/dist/cluster.d.ts +1 -1
- package/dist/cluster.js +1039 -358
- package/dist/cluster.mjs +959 -278
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1078 -395
- package/dist/index.mjs +961 -280
- package/dist/message.d.mts +1 -1
- package/dist/message.d.ts +1 -1
- package/dist/message.js +159 -44
- package/dist/message.mjs +159 -44
- 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");
|
|
@@ -1234,6 +1236,7 @@ var Events = {
|
|
|
1234
1236
|
GuildEmojisUpdate: "guildEmojisUpdate",
|
|
1235
1237
|
GuildStickersUpdate: "guildStickersUpdate",
|
|
1236
1238
|
GuildCountsUpdate: "guildCountsUpdate",
|
|
1239
|
+
GuildHealthUpdate: "guildHealthUpdate",
|
|
1237
1240
|
ChannelMemberCountsUpdate: "channelMemberCountsUpdate",
|
|
1238
1241
|
GuildMemberAdd: "guildMemberAdd",
|
|
1239
1242
|
GuildMemberUpdate: "guildMemberUpdate",
|
|
@@ -1268,7 +1271,16 @@ var Events = {
|
|
|
1268
1271
|
VoiceStateAck: "voiceStateAck",
|
|
1269
1272
|
VoiceServerUpdate: "voiceServerUpdate",
|
|
1270
1273
|
EntranceSoundPlay: "entranceSoundPlay",
|
|
1274
|
+
VoiceSignal: "voiceSignal",
|
|
1275
|
+
OperatorPassUpdate: "operatorPassUpdate",
|
|
1271
1276
|
VoiceStatesSync: "voiceStatesSync",
|
|
1277
|
+
VoiceJoinQueued: "voiceJoinQueued",
|
|
1278
|
+
StageInstanceCreate: "stageInstanceCreate",
|
|
1279
|
+
StageInstanceUpdate: "stageInstanceUpdate",
|
|
1280
|
+
StageInstanceDelete: "stageInstanceDelete",
|
|
1281
|
+
StageCountsUpdate: "stageCountsUpdate",
|
|
1282
|
+
StageVoiceStatesSync: "stageVoiceStatesSync",
|
|
1283
|
+
StageAudienceListUpdate: "stageAudienceListUpdate",
|
|
1272
1284
|
WebhooksUpdate: "webhooksUpdate",
|
|
1273
1285
|
Resumed: "resumed",
|
|
1274
1286
|
Error: "error",
|
|
@@ -1934,10 +1946,10 @@ var Message = class _Message extends Base {
|
|
|
1934
1946
|
this.channelId = data.channel_id;
|
|
1935
1947
|
this.guildId = data.guild_id ?? null;
|
|
1936
1948
|
this.author = client.getOrCreateUser(data.author);
|
|
1937
|
-
this.content = data.content;
|
|
1938
|
-
this.createdAt = new Date(data.timestamp);
|
|
1949
|
+
this.content = data.content ?? "";
|
|
1950
|
+
this.createdAt = data.timestamp ? new Date(data.timestamp) : /* @__PURE__ */ new Date(0);
|
|
1939
1951
|
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
1940
|
-
this.pinned = data.pinned;
|
|
1952
|
+
this.pinned = data.pinned ?? false;
|
|
1941
1953
|
this.attachments = new import_collection3.Collection();
|
|
1942
1954
|
for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
|
|
1943
1955
|
this.type = data.type ?? import_types7.MessageType.Default;
|
|
@@ -1969,33 +1981,47 @@ var Message = class _Message extends Base {
|
|
|
1969
1981
|
* @internal
|
|
1970
1982
|
*/
|
|
1971
1983
|
_patch(data) {
|
|
1972
|
-
this.content = data.content;
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
this.
|
|
1983
|
-
this.
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1984
|
+
if (data.content !== void 0) this.content = data.content ?? "";
|
|
1985
|
+
if (data.edited_timestamp !== void 0) {
|
|
1986
|
+
this.editedAt = data.edited_timestamp ? new Date(data.edited_timestamp) : null;
|
|
1987
|
+
}
|
|
1988
|
+
if (data.pinned !== void 0) this.pinned = data.pinned;
|
|
1989
|
+
if (data.attachments !== void 0) {
|
|
1990
|
+
this.attachments.clear();
|
|
1991
|
+
for (const a of data.attachments ?? []) this.attachments.set(a.id, toMessageAttachment(a));
|
|
1992
|
+
}
|
|
1993
|
+
if (data.flags !== void 0) this.flags = new import_util6.MessageFlagsBitField(BigInt(data.flags ?? 0));
|
|
1994
|
+
if (data.mention_everyone !== void 0) this.mentionEveryone = data.mention_everyone;
|
|
1995
|
+
if (data.tts !== void 0) this.tts = data.tts;
|
|
1996
|
+
if (data.embeds !== void 0) this.embeds = (data.embeds ?? []).map(toMessageEmbed);
|
|
1997
|
+
if (data.stickers !== void 0) {
|
|
1998
|
+
this.stickers = (data.stickers ?? []).map((s) => new MessageSticker(this.client, s));
|
|
1999
|
+
}
|
|
2000
|
+
if (data.reactions !== void 0) this.reactions._patch(data.reactions);
|
|
2001
|
+
if (data.message_reference !== void 0) {
|
|
2002
|
+
this.messageReference = data.message_reference ? {
|
|
2003
|
+
channelId: data.message_reference.channel_id,
|
|
2004
|
+
messageId: data.message_reference.message_id,
|
|
2005
|
+
guildId: data.message_reference.guild_id ?? null,
|
|
2006
|
+
...data.message_reference.type !== void 0 ? { type: data.message_reference.type } : {}
|
|
2007
|
+
} : null;
|
|
2008
|
+
}
|
|
2009
|
+
if (data.message_snapshots !== void 0) {
|
|
2010
|
+
this.messageSnapshots = (data.message_snapshots ?? []).map(
|
|
2011
|
+
(s) => toMessageSnapshot(this.client, s)
|
|
2012
|
+
);
|
|
2013
|
+
}
|
|
2014
|
+
if (data.call !== void 0) this.call = data.call ? toMessageCall(data.call) : null;
|
|
2015
|
+
if (data.referenced_message !== void 0) {
|
|
2016
|
+
this.referencedMessage = data.referenced_message ? new _Message(this.client, data.referenced_message) : null;
|
|
2017
|
+
}
|
|
2018
|
+
if (data.webhook_id !== void 0) this.webhookId = data.webhook_id ?? null;
|
|
2019
|
+
if (data.mentions !== void 0) {
|
|
2020
|
+
this.mentions = (data.mentions ?? []).map((u) => this.client.getOrCreateUser(u));
|
|
2021
|
+
}
|
|
2022
|
+
if (data.mention_roles !== void 0) this.mentionRoles = data.mention_roles ?? [];
|
|
2023
|
+
if (data.nonce !== void 0) this.nonce = data.nonce ?? null;
|
|
2024
|
+
if (data.nsfw_emojis !== void 0) this.nsfwEmojis = data.nsfw_emojis ?? [];
|
|
1999
2025
|
if (data.thread) this.thread = cacheThread(this.client, data.thread);
|
|
2000
2026
|
}
|
|
2001
2027
|
/**
|
|
@@ -2096,6 +2122,23 @@ var Message = class _Message extends Base {
|
|
|
2096
2122
|
async fetch() {
|
|
2097
2123
|
return this.client.channels.fetchMessage(this.channelId, this.id);
|
|
2098
2124
|
}
|
|
2125
|
+
/** Publish this announcement message to channels following its channel. */
|
|
2126
|
+
async crosspost() {
|
|
2127
|
+
const data = await this.client.rest.post(
|
|
2128
|
+
import_types7.Routes.channelMessageCrosspost(this.channelId, this.id),
|
|
2129
|
+
{ auth: true }
|
|
2130
|
+
);
|
|
2131
|
+
const published = new _Message(this.client, data);
|
|
2132
|
+
this.client._addMessageToCache(this.channelId, data);
|
|
2133
|
+
return published;
|
|
2134
|
+
}
|
|
2135
|
+
/** Fetch the source guild of a crossposted (followed-channel) message. */
|
|
2136
|
+
async fetchCrosspostSource() {
|
|
2137
|
+
return this.client.rest.get(
|
|
2138
|
+
import_types7.Routes.channelMessageCrosspostSource(this.channelId, this.id),
|
|
2139
|
+
{ auth: true }
|
|
2140
|
+
);
|
|
2141
|
+
}
|
|
2099
2142
|
/** Delete this message. */
|
|
2100
2143
|
async delete(reason) {
|
|
2101
2144
|
await this.client.rest.delete(import_types7.Routes.channelMessage(this.channelId, this.id), {
|
|
@@ -2198,6 +2241,43 @@ var PartialMessage = class {
|
|
|
2198
2241
|
}
|
|
2199
2242
|
};
|
|
2200
2243
|
|
|
2244
|
+
// src/ClientCore/Resolve.ts
|
|
2245
|
+
function normalizeSnowflakeId(value, label) {
|
|
2246
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
2247
|
+
throw new TypeError(
|
|
2248
|
+
`${label} received an unsafe numeric ID; pass snowflakes as strings to avoid precision loss`
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
const id = typeof value === "bigint" ? value.toString() : String(value ?? "").trim();
|
|
2252
|
+
if (!id || id === "undefined" || id === "null" || id === "[object Object]") {
|
|
2253
|
+
throw new TypeError(`${label} requires a non-empty ID`);
|
|
2254
|
+
}
|
|
2255
|
+
return id;
|
|
2256
|
+
}
|
|
2257
|
+
function assertApiObjectWithId(data, label) {
|
|
2258
|
+
if (!data || typeof data !== "object" || typeof data.id !== "string" || data.id.length === 0) {
|
|
2259
|
+
throw new TypeError(`${label} received an invalid API payload (missing string id)`);
|
|
2260
|
+
}
|
|
2261
|
+
return data;
|
|
2262
|
+
}
|
|
2263
|
+
function assertApiArray(data, label) {
|
|
2264
|
+
if (!Array.isArray(data)) {
|
|
2265
|
+
throw new TypeError(`${label} received an invalid API payload (expected an array)`);
|
|
2266
|
+
}
|
|
2267
|
+
return data;
|
|
2268
|
+
}
|
|
2269
|
+
async function dedupeFetch(pending, key, fn) {
|
|
2270
|
+
const existing = pending.get(key);
|
|
2271
|
+
if (existing) return existing;
|
|
2272
|
+
const request = fn();
|
|
2273
|
+
pending.set(key, request);
|
|
2274
|
+
try {
|
|
2275
|
+
return await request;
|
|
2276
|
+
} finally {
|
|
2277
|
+
if (pending.get(key) === request) pending.delete(key);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2201
2281
|
// src/ClientCore/MessageManager.ts
|
|
2202
2282
|
var BULK = {
|
|
2203
2283
|
requests: { min: 1, max: 25 },
|
|
@@ -2234,25 +2314,32 @@ var MessageManager = class {
|
|
|
2234
2314
|
}
|
|
2235
2315
|
/** Structure cache keyed by message id (identity for {@link get}). */
|
|
2236
2316
|
_structures = new import_collection4.Collection();
|
|
2317
|
+
pendingFetches = /* @__PURE__ */ new Map();
|
|
2237
2318
|
/** Retrieve a cached message by ID, or `undefined` if missing / caching disabled. */
|
|
2238
2319
|
get(messageId) {
|
|
2239
|
-
const
|
|
2320
|
+
const id = String(messageId ?? "").trim();
|
|
2321
|
+
if (!id) return void 0;
|
|
2322
|
+
const data = this.client._getMessageCache(this.channelId)?.get(id);
|
|
2240
2323
|
if (!data) {
|
|
2241
|
-
this._structures.delete(
|
|
2324
|
+
this._structures.delete(id);
|
|
2242
2325
|
return void 0;
|
|
2243
2326
|
}
|
|
2244
|
-
const existing = this._structures.get(
|
|
2245
|
-
if (existing)
|
|
2327
|
+
const existing = this._structures.get(id);
|
|
2328
|
+
if (existing) {
|
|
2329
|
+
existing._patch(data);
|
|
2330
|
+
return existing;
|
|
2331
|
+
}
|
|
2246
2332
|
const message = new Message(this.client, data);
|
|
2247
|
-
this._structures.set(
|
|
2333
|
+
this._structures.set(id, message);
|
|
2248
2334
|
return message;
|
|
2249
2335
|
}
|
|
2250
2336
|
/** Retrieve from cache, otherwise {@link fetch}. */
|
|
2251
2337
|
async resolve(messageId) {
|
|
2252
|
-
|
|
2338
|
+
const id = normalizeSnowflakeId(messageId, "messages.resolve()");
|
|
2339
|
+
return this.get(id) ?? this.fetch(id);
|
|
2253
2340
|
}
|
|
2254
2341
|
async fetch(idOrOptions) {
|
|
2255
|
-
return typeof idOrOptions === "string" ? this.fetchOne(idOrOptions) : this.fetchMany(idOrOptions);
|
|
2342
|
+
return typeof idOrOptions === "string" || typeof idOrOptions === "number" ? this.fetchOne(normalizeSnowflakeId(idOrOptions, "messages.fetch()")) : this.fetchMany(idOrOptions);
|
|
2256
2343
|
}
|
|
2257
2344
|
/** Cache API data and return a {@link Message} (reusing identity when present). */
|
|
2258
2345
|
wrap(data) {
|
|
@@ -2269,9 +2356,13 @@ var MessageManager = class {
|
|
|
2269
2356
|
}
|
|
2270
2357
|
/** Fetch a single message from the API. */
|
|
2271
2358
|
async fetchOne(messageId) {
|
|
2359
|
+
return dedupeFetch(this.pendingFetches, messageId, async () => this.fetchOneFresh(messageId));
|
|
2360
|
+
}
|
|
2361
|
+
async fetchOneFresh(messageId) {
|
|
2272
2362
|
try {
|
|
2273
|
-
const data =
|
|
2274
|
-
import_types8.Routes.channelMessage(this.channelId, messageId)
|
|
2363
|
+
const data = assertApiObjectWithId(
|
|
2364
|
+
await this.client.rest.get(import_types8.Routes.channelMessage(this.channelId, messageId)),
|
|
2365
|
+
"messages.fetch()"
|
|
2275
2366
|
);
|
|
2276
2367
|
return this.wrap(data);
|
|
2277
2368
|
} catch (err) {
|
|
@@ -2297,9 +2388,15 @@ var MessageManager = class {
|
|
|
2297
2388
|
if (value != null && value !== "") qs2.set(key, String(value));
|
|
2298
2389
|
}
|
|
2299
2390
|
const base = import_types8.Routes.channelMessages(this.channelId);
|
|
2300
|
-
const data =
|
|
2391
|
+
const data = assertApiArray(
|
|
2392
|
+
await this.client.rest.get(qs2.size > 0 ? `${base}?${qs2}` : base),
|
|
2393
|
+
"messages.fetch()"
|
|
2394
|
+
);
|
|
2301
2395
|
const collection = new import_collection4.Collection();
|
|
2302
|
-
for (const msg of data)
|
|
2396
|
+
for (const msg of data) {
|
|
2397
|
+
if (!msg?.id) continue;
|
|
2398
|
+
collection.set(msg.id, this.wrap(msg));
|
|
2399
|
+
}
|
|
2303
2400
|
return collection;
|
|
2304
2401
|
}
|
|
2305
2402
|
};
|
|
@@ -2503,6 +2600,9 @@ async function uploadAttachmentsForSend(client, channelId, files) {
|
|
|
2503
2600
|
}
|
|
2504
2601
|
|
|
2505
2602
|
// src/Domain/Channel/Base.ts
|
|
2603
|
+
function isFullChannelData(data) {
|
|
2604
|
+
return "guild_id" in data || "permission_overwrites" in data || "position" in data || "last_message_id" in data || "topic" in data || "thread_metadata" in data || "available_tags" in data;
|
|
2605
|
+
}
|
|
2506
2606
|
var Channel = class extends Base {
|
|
2507
2607
|
#messages;
|
|
2508
2608
|
/** The {@link Client} that instantiated this channel. */
|
|
@@ -2517,6 +2617,11 @@ var Channel = class extends Base {
|
|
|
2517
2617
|
icon;
|
|
2518
2618
|
/** ISO8601 timestamp of the last pinned message update. */
|
|
2519
2619
|
lastPinTimestamp;
|
|
2620
|
+
/**
|
|
2621
|
+
* True when built from a partial payload (e.g. a DM stub) and not yet hydrated
|
|
2622
|
+
* with a full channel object. `channels.resolve()` refetches partial channels.
|
|
2623
|
+
*/
|
|
2624
|
+
partial;
|
|
2520
2625
|
constructor(client, data) {
|
|
2521
2626
|
super();
|
|
2522
2627
|
this.client = client;
|
|
@@ -2525,6 +2630,7 @@ var Channel = class extends Base {
|
|
|
2525
2630
|
this.name = data.name ?? null;
|
|
2526
2631
|
this.icon = data.icon ?? null;
|
|
2527
2632
|
this.lastPinTimestamp = data.last_pin_timestamp ?? null;
|
|
2633
|
+
this.partial = !isFullChannelData(data);
|
|
2528
2634
|
}
|
|
2529
2635
|
/** Unix timestamp (ms) when this channel was created, derived from its snowflake ID. */
|
|
2530
2636
|
get createdTimestamp() {
|
|
@@ -2545,6 +2651,7 @@ var Channel = class extends Base {
|
|
|
2545
2651
|
if ("last_pin_timestamp" in data && data.last_pin_timestamp !== void 0) {
|
|
2546
2652
|
this.lastPinTimestamp = data.last_pin_timestamp ?? null;
|
|
2547
2653
|
}
|
|
2654
|
+
if (isFullChannelData(data)) this.partial = false;
|
|
2548
2655
|
}
|
|
2549
2656
|
/** @internal Factory wired after subclasses load. */
|
|
2550
2657
|
static from(_c, _d) {
|
|
@@ -2564,11 +2671,11 @@ var Channel = class extends Base {
|
|
|
2564
2671
|
* Checks {@link ChannelType}, not whether `send` exists on the instance.
|
|
2565
2672
|
*/
|
|
2566
2673
|
isTextBased() {
|
|
2567
|
-
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;
|
|
2568
2675
|
}
|
|
2569
2676
|
/** Check if this is a guild channel, including threads, forums, and media channels. */
|
|
2570
2677
|
isGuild() {
|
|
2571
|
-
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;
|
|
2572
2679
|
}
|
|
2573
2680
|
/** Check if this is a thread (public, private, or announcement). */
|
|
2574
2681
|
isThread() {
|
|
@@ -2602,10 +2709,18 @@ var Channel = class extends Base {
|
|
|
2602
2709
|
isPersonalNotes() {
|
|
2603
2710
|
return this.type === import_types10.ChannelType.DMPersonalNotes;
|
|
2604
2711
|
}
|
|
2605
|
-
/** Check if this is a voice channel. */
|
|
2712
|
+
/** Check if this is a voice channel (type 2 only; see {@link isVoiceBased} to include stages). */
|
|
2606
2713
|
isVoice() {
|
|
2607
2714
|
return this.type === import_types10.ChannelType.GuildVoice;
|
|
2608
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
|
+
}
|
|
2609
2724
|
/** Check if this is a link channel. */
|
|
2610
2725
|
isLink() {
|
|
2611
2726
|
return this.type === import_types10.ChannelType.GuildLink;
|
|
@@ -2836,7 +2951,7 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2836
2951
|
const full = data;
|
|
2837
2952
|
this.lastMessageId = full.last_message_id ?? null;
|
|
2838
2953
|
this.ownerId = full.owner_id ?? null;
|
|
2839
|
-
this.recipients = (full.recipients ?? []).map((u) => client.getOrCreateUser(u));
|
|
2954
|
+
this.recipients = (full.recipients ?? []).filter((u) => typeof u?.id === "string").map((u) => client.getOrCreateUser(u));
|
|
2840
2955
|
this.nicks = full.nicks ?? {};
|
|
2841
2956
|
}
|
|
2842
2957
|
/**
|
|
@@ -2851,7 +2966,7 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2851
2966
|
}
|
|
2852
2967
|
if ("owner_id" in full && full.owner_id !== void 0) this.ownerId = full.owner_id ?? null;
|
|
2853
2968
|
if ("recipients" in full && full.recipients !== void 0) {
|
|
2854
|
-
this.recipients = (full.recipients ?? []).map((u) => this.client.getOrCreateUser(u));
|
|
2969
|
+
this.recipients = (full.recipients ?? []).filter((u) => typeof u?.id === "string").map((u) => this.client.getOrCreateUser(u));
|
|
2855
2970
|
}
|
|
2856
2971
|
if ("nicks" in full && full.nicks !== void 0) this.nicks = full.nicks ?? {};
|
|
2857
2972
|
}
|
|
@@ -2916,11 +3031,11 @@ var DMChannel = class extends TextCapable(Channel) {
|
|
|
2916
3031
|
};
|
|
2917
3032
|
|
|
2918
3033
|
// src/Domain/Channel/Forum.ts
|
|
2919
|
-
var
|
|
3034
|
+
var import_types20 = require("@fluxerjs/types");
|
|
2920
3035
|
|
|
2921
3036
|
// src/Domain/Channel/Guild.ts
|
|
2922
|
-
var
|
|
2923
|
-
var
|
|
3037
|
+
var import_types17 = require("@fluxerjs/types");
|
|
3038
|
+
var import_util14 = require("@fluxerjs/util");
|
|
2924
3039
|
|
|
2925
3040
|
// src/Domain/Invite.ts
|
|
2926
3041
|
var import_types13 = require("@fluxerjs/types");
|
|
@@ -2928,17 +3043,19 @@ var import_types13 = require("@fluxerjs/types");
|
|
|
2928
3043
|
// src/Helpers/Instance.ts
|
|
2929
3044
|
var import_util9 = require("@fluxerjs/util");
|
|
2930
3045
|
var DEFAULT_INSTANCE_ENDPOINTS = Object.freeze({
|
|
2931
|
-
api: "https://
|
|
2932
|
-
api_client: "https://
|
|
2933
|
-
api_public: "https://
|
|
2934
|
-
gateway: "wss://gateway.fluxer.
|
|
3046
|
+
api: "https://fluxer.com/api",
|
|
3047
|
+
api_client: "https://fluxer.com/api",
|
|
3048
|
+
api_public: "https://fluxer.com/api",
|
|
3049
|
+
gateway: "wss://gateway.fluxer.com",
|
|
2935
3050
|
media: CDN_URL,
|
|
3051
|
+
upload_relay: "https://uploads.fluxer.app",
|
|
2936
3052
|
static_cdn: STATIC_CDN_URL,
|
|
2937
|
-
marketing: "https://fluxer.
|
|
3053
|
+
marketing: "https://fluxer.com",
|
|
3054
|
+
docs: "https://docs.fluxer.com",
|
|
2938
3055
|
admin: "https://admin.fluxer.app",
|
|
2939
3056
|
invite: "https://fluxer.gg",
|
|
2940
3057
|
gift: "https://fluxer.gift",
|
|
2941
|
-
webapp: "https://
|
|
3058
|
+
webapp: "https://fluxer.com"
|
|
2942
3059
|
});
|
|
2943
3060
|
var ENDPOINT_KEYS = [
|
|
2944
3061
|
"api",
|
|
@@ -2953,6 +3070,11 @@ var ENDPOINT_KEYS = [
|
|
|
2953
3070
|
"gift",
|
|
2954
3071
|
"webapp"
|
|
2955
3072
|
];
|
|
3073
|
+
var OPTIONAL_ENDPOINT_KEYS = [
|
|
3074
|
+
"api_transport",
|
|
3075
|
+
"upload_relay",
|
|
3076
|
+
"docs"
|
|
3077
|
+
];
|
|
2956
3078
|
function requireString(obj, key, path) {
|
|
2957
3079
|
const value = obj[key];
|
|
2958
3080
|
if (typeof value !== "string" || value.length === 0) {
|
|
@@ -2993,6 +3115,10 @@ function parseInstanceDiscovery(raw) {
|
|
|
2993
3115
|
for (const key of ENDPOINT_KEYS) {
|
|
2994
3116
|
endpoints[key] = requireString(raw.endpoints, key, "endpoints");
|
|
2995
3117
|
}
|
|
3118
|
+
for (const key of OPTIONAL_ENDPOINT_KEYS) {
|
|
3119
|
+
const value = raw.endpoints[key];
|
|
3120
|
+
if (typeof value === "string" && value.length > 0) endpoints[key] = value;
|
|
3121
|
+
}
|
|
2996
3122
|
endpoints.api = normalizeApiOrigin(endpoints.api);
|
|
2997
3123
|
endpoints.api_client = normalizeApiOrigin(endpoints.api_client);
|
|
2998
3124
|
endpoints.api_public = normalizeApiOrigin(endpoints.api_public);
|
|
@@ -3046,7 +3172,21 @@ function parseInstanceDiscovery(raw) {
|
|
|
3046
3172
|
defaultsHash: ""
|
|
3047
3173
|
},
|
|
3048
3174
|
push: raw.push ?? { public_vapid_key: null },
|
|
3049
|
-
app_public: raw.app_public ?? {}
|
|
3175
|
+
app_public: raw.app_public ?? {},
|
|
3176
|
+
...typeof raw.codename === "string" ? { codename: raw.codename } : {},
|
|
3177
|
+
age_policy: (0, import_util9.isRecord)(raw.age_policy) ? raw.age_policy : { geos: [] },
|
|
3178
|
+
...raw.notice === null || (0, import_util9.isRecord)(raw.notice) ? { notice: raw.notice } : {},
|
|
3179
|
+
...(0, import_util9.isRecord)(raw.domain_migration) ? { domain_migration: raw.domain_migration } : {},
|
|
3180
|
+
...Array.isArray(raw.guild_badges) ? { guild_badges: raw.guild_badges } : {},
|
|
3181
|
+
...typeof raw.guild_badges_partial === "boolean" ? { guild_badges_partial: raw.guild_badges_partial } : {},
|
|
3182
|
+
...typeof raw.custom_badges_version === "string" ? { custom_badges_version: raw.custom_badges_version } : {},
|
|
3183
|
+
...(0, import_util9.isRecord)(raw.built_in_guild_badge_images) ? {
|
|
3184
|
+
built_in_guild_badge_images: raw.built_in_guild_badge_images
|
|
3185
|
+
} : {},
|
|
3186
|
+
...Array.isArray(raw.hidden_built_in_guild_badges) ? {
|
|
3187
|
+
hidden_built_in_guild_badges: raw.hidden_built_in_guild_badges
|
|
3188
|
+
} : {},
|
|
3189
|
+
...Array.isArray(raw.voice_origins) ? { voice_origins: raw.voice_origins } : {}
|
|
3050
3190
|
};
|
|
3051
3191
|
}
|
|
3052
3192
|
function resolveInstanceEndpoints(input) {
|
|
@@ -3066,7 +3206,7 @@ function resolveInstanceEndpoints(input) {
|
|
|
3066
3206
|
}
|
|
3067
3207
|
const partial = input;
|
|
3068
3208
|
const merged = { ...DEFAULT_INSTANCE_ENDPOINTS };
|
|
3069
|
-
for (const key of ENDPOINT_KEYS) {
|
|
3209
|
+
for (const key of [...ENDPOINT_KEYS, ...OPTIONAL_ENDPOINT_KEYS]) {
|
|
3070
3210
|
const value = partial[key];
|
|
3071
3211
|
if (typeof value === "string" && value.length > 0) {
|
|
3072
3212
|
merged[key] = value;
|
|
@@ -3485,6 +3625,127 @@ var PermissionOverwriteManager = class {
|
|
|
3485
3625
|
}
|
|
3486
3626
|
};
|
|
3487
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
|
+
|
|
3488
3749
|
// src/Domain/Channel/ThreadBind.ts
|
|
3489
3750
|
var factory;
|
|
3490
3751
|
var managers = /* @__PURE__ */ new WeakMap();
|
|
@@ -3539,7 +3800,7 @@ var GuildChannel = class extends Channel {
|
|
|
3539
3800
|
}
|
|
3540
3801
|
/** Create a webhook for this channel. Requires Manage Webhooks. */
|
|
3541
3802
|
async createWebhook(options) {
|
|
3542
|
-
const data = await this.client.rest.post(
|
|
3803
|
+
const data = await this.client.rest.post(import_types17.Routes.channelWebhooks(this.id), {
|
|
3543
3804
|
body: options,
|
|
3544
3805
|
auth: true
|
|
3545
3806
|
});
|
|
@@ -3547,13 +3808,13 @@ var GuildChannel = class extends Channel {
|
|
|
3547
3808
|
}
|
|
3548
3809
|
/** Fetch all webhooks in this channel. Requires Manage Webhooks. */
|
|
3549
3810
|
async fetchWebhooks() {
|
|
3550
|
-
const data = await this.client.rest.get(
|
|
3811
|
+
const data = await this.client.rest.get(import_types17.Routes.channelWebhooks(this.id));
|
|
3551
3812
|
return data.map((w) => new Webhook(this.client, w));
|
|
3552
3813
|
}
|
|
3553
3814
|
/** Create an invite for this channel. Requires Create Instant Invite. */
|
|
3554
3815
|
async createInvite(options) {
|
|
3555
3816
|
const body = options ? toChannelInviteBody(options) : {};
|
|
3556
|
-
const data = await this.client.rest.post(
|
|
3817
|
+
const data = await this.client.rest.post(import_types17.Routes.channelInvites(this.id), {
|
|
3557
3818
|
body: Object.keys(body).length ? body : void 0,
|
|
3558
3819
|
auth: true
|
|
3559
3820
|
});
|
|
@@ -3561,7 +3822,7 @@ var GuildChannel = class extends Channel {
|
|
|
3561
3822
|
}
|
|
3562
3823
|
/** Fetch all invites for this channel. Requires Manage Channels. */
|
|
3563
3824
|
async fetchInvites() {
|
|
3564
|
-
const data = await this.client.rest.get(
|
|
3825
|
+
const data = await this.client.rest.get(import_types17.Routes.channelInvites(this.id));
|
|
3565
3826
|
return data.map((i) => new Invite(this.client, i));
|
|
3566
3827
|
}
|
|
3567
3828
|
/** Check if the bot can send messages in this channel (cache-only; needs `members.me`). */
|
|
@@ -3570,7 +3831,7 @@ var GuildChannel = class extends Channel {
|
|
|
3570
3831
|
const me = this.client.guilds.get(this.guildId)?.members.me;
|
|
3571
3832
|
if (!me) return false;
|
|
3572
3833
|
const perms = me.permissionsIn(this);
|
|
3573
|
-
return perms.has(
|
|
3834
|
+
return perms.has(import_util14.PermissionFlags.ViewChannel) && perms.has(import_util14.PermissionFlags.SendMessages);
|
|
3574
3835
|
}
|
|
3575
3836
|
/**
|
|
3576
3837
|
* Like {@link canSendMessage}, but hydrates `members.me` via REST when missing.
|
|
@@ -3591,7 +3852,7 @@ var GuildChannel = class extends Channel {
|
|
|
3591
3852
|
}
|
|
3592
3853
|
/** Edit this channel's settings. Requires Manage Channels. */
|
|
3593
3854
|
async edit(options) {
|
|
3594
|
-
const data = await this.client.rest.patch(
|
|
3855
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3595
3856
|
body: toChannelEditBody(options),
|
|
3596
3857
|
auth: true,
|
|
3597
3858
|
...auditReasonHeaders(options.reason)
|
|
@@ -3673,7 +3934,7 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3673
3934
|
* Sends only those fields. The thread-parent update body does not accept a channel rename.
|
|
3674
3935
|
*/
|
|
3675
3936
|
async editThreadDefaults(options) {
|
|
3676
|
-
const data = await this.client.rest.patch(
|
|
3937
|
+
const data = await this.client.rest.patch(import_types17.Routes.channel(this.id), {
|
|
3677
3938
|
body: toThreadParentEditBody(options),
|
|
3678
3939
|
auth: true,
|
|
3679
3940
|
...auditReasonHeaders(options.reason)
|
|
@@ -3683,6 +3944,23 @@ var TextChannel = class extends TextCapable(GuildChannel) {
|
|
|
3683
3944
|
}
|
|
3684
3945
|
};
|
|
3685
3946
|
var AnnouncementChannel = class extends TextChannel {
|
|
3947
|
+
/**
|
|
3948
|
+
* Follow this announcement channel into `webhookChannelId` (a channel in a guild
|
|
3949
|
+
* where the bot can manage webhooks). Published messages are copied there.
|
|
3950
|
+
*/
|
|
3951
|
+
async follow(webhookChannelId) {
|
|
3952
|
+
return this.client.rest.post(
|
|
3953
|
+
import_types17.Routes.channelFollowers(this.id),
|
|
3954
|
+
{ body: { webhook_channel_id: webhookChannelId }, auth: true }
|
|
3955
|
+
);
|
|
3956
|
+
}
|
|
3957
|
+
/** Fetch follower counts for this announcement channel. */
|
|
3958
|
+
async fetchFollowerStats() {
|
|
3959
|
+
return this.client.rest.get(
|
|
3960
|
+
import_types17.Routes.channelFollowerStats(this.id),
|
|
3961
|
+
{ auth: true }
|
|
3962
|
+
);
|
|
3963
|
+
}
|
|
3686
3964
|
};
|
|
3687
3965
|
var CategoryChannel = class extends GuildChannel {
|
|
3688
3966
|
};
|
|
@@ -3709,6 +3987,8 @@ var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
|
3709
3987
|
voiceConnectionLimit;
|
|
3710
3988
|
/** RTC region override for this channel. */
|
|
3711
3989
|
rtcRegion;
|
|
3990
|
+
/** Whether voice in this channel is peer-to-peer (`rtc_p2p`). */
|
|
3991
|
+
rtcP2p;
|
|
3712
3992
|
constructor(client, data) {
|
|
3713
3993
|
super(client, data);
|
|
3714
3994
|
this.topic = data.topic ?? null;
|
|
@@ -3722,6 +4002,7 @@ var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
|
3722
4002
|
this.userLimit = data.user_limit ?? null;
|
|
3723
4003
|
this.voiceConnectionLimit = data.voice_connection_limit ?? null;
|
|
3724
4004
|
this.rtcRegion = data.rtc_region ?? null;
|
|
4005
|
+
this.rtcP2p = data.rtc_p2p ?? false;
|
|
3725
4006
|
}
|
|
3726
4007
|
/**
|
|
3727
4008
|
* Set slowmode (seconds between messages). Pass `0` to disable.
|
|
@@ -3748,6 +4029,97 @@ var VoiceChannel = class extends TextCapable(GuildChannel) {
|
|
|
3748
4029
|
this.voiceConnectionLimit = data.voice_connection_limit ?? null;
|
|
3749
4030
|
}
|
|
3750
4031
|
if ("rtc_region" in data) this.rtcRegion = data.rtc_region ?? null;
|
|
4032
|
+
if ("rtc_p2p" in data) this.rtcP2p = data.rtc_p2p ?? false;
|
|
4033
|
+
}
|
|
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
|
+
};
|
|
3751
4123
|
}
|
|
3752
4124
|
};
|
|
3753
4125
|
var LinkChannel = class extends GuildChannel {
|
|
@@ -3763,10 +4135,10 @@ var LinkChannel = class extends GuildChannel {
|
|
|
3763
4135
|
};
|
|
3764
4136
|
|
|
3765
4137
|
// src/Domain/Channel/ThreadManager.ts
|
|
3766
|
-
var
|
|
4138
|
+
var import_types19 = require("@fluxerjs/types");
|
|
3767
4139
|
|
|
3768
4140
|
// src/Domain/Channel/ThreadChannel.ts
|
|
3769
|
-
var
|
|
4141
|
+
var import_types18 = require("@fluxerjs/types");
|
|
3770
4142
|
var ThreadMember = class {
|
|
3771
4143
|
/** Thread ID. */
|
|
3772
4144
|
id;
|
|
@@ -3893,7 +4265,7 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
3893
4265
|
* `appliedTags` is sent for public and announcement threads. `invitable` is sent for private threads.
|
|
3894
4266
|
*/
|
|
3895
4267
|
async edit(options) {
|
|
3896
|
-
const data = await this.client.rest.patch(
|
|
4268
|
+
const data = await this.client.rest.patch(import_types18.Routes.channel(this.id), {
|
|
3897
4269
|
body: toThreadEditBody(this.type, threadEditFields(options)),
|
|
3898
4270
|
auth: true,
|
|
3899
4271
|
...auditReasonHeaders(options.reason)
|
|
@@ -3911,16 +4283,16 @@ var ThreadChannel = class extends TextCapable(GuildChannel) {
|
|
|
3911
4283
|
}
|
|
3912
4284
|
/** Join this thread. */
|
|
3913
4285
|
async join() {
|
|
3914
|
-
await this.client.rest.put(
|
|
4286
|
+
await this.client.rest.put(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3915
4287
|
}
|
|
3916
4288
|
/** Leave this thread. */
|
|
3917
4289
|
async leave() {
|
|
3918
|
-
await this.client.rest.delete(
|
|
4290
|
+
await this.client.rest.delete(import_types18.Routes.channelThreadMemberMe(this.id), { auth: true });
|
|
3919
4291
|
}
|
|
3920
4292
|
/** Update the current user's notification settings for this thread. */
|
|
3921
4293
|
async editSelf(options) {
|
|
3922
4294
|
const data = await this.client.rest.patch(
|
|
3923
|
-
|
|
4295
|
+
import_types18.Routes.channelThreadMemberMeSettings(this.id),
|
|
3924
4296
|
{ body: toThreadMemberSettingsBody(options), auth: true }
|
|
3925
4297
|
);
|
|
3926
4298
|
this.member = data ? new ThreadMember(data) : null;
|
|
@@ -3934,7 +4306,7 @@ var ThreadMemberManager = class {
|
|
|
3934
4306
|
/** List members of this thread. */
|
|
3935
4307
|
async fetch(options) {
|
|
3936
4308
|
const data = await this.thread.client.rest.get(
|
|
3937
|
-
withQuery(
|
|
4309
|
+
withQuery(import_types18.Routes.channelThreadMembers(this.thread.id), {
|
|
3938
4310
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember),
|
|
3939
4311
|
after: options?.after,
|
|
3940
4312
|
limit: options?.limit
|
|
@@ -3945,7 +4317,7 @@ var ThreadMemberManager = class {
|
|
|
3945
4317
|
/** Fetch one member of this thread. */
|
|
3946
4318
|
async fetchOne(userId, options) {
|
|
3947
4319
|
const data = await this.thread.client.rest.get(
|
|
3948
|
-
withQuery(
|
|
4320
|
+
withQuery(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3949
4321
|
with_member: options?.withMember === void 0 ? void 0 : String(options.withMember)
|
|
3950
4322
|
})
|
|
3951
4323
|
);
|
|
@@ -3953,19 +4325,19 @@ var ThreadMemberManager = class {
|
|
|
3953
4325
|
}
|
|
3954
4326
|
/** Add a user to this thread. Private threads only, unless the caller can manage the parent. */
|
|
3955
4327
|
async add(userId) {
|
|
3956
|
-
await this.thread.client.rest.put(
|
|
4328
|
+
await this.thread.client.rest.put(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3957
4329
|
auth: true
|
|
3958
4330
|
});
|
|
3959
4331
|
}
|
|
3960
4332
|
/** Remove a user from this thread. */
|
|
3961
4333
|
async remove(userId) {
|
|
3962
|
-
await this.thread.client.rest.delete(
|
|
4334
|
+
await this.thread.client.rest.delete(import_types18.Routes.channelThreadMember(this.thread.id, userId), {
|
|
3963
4335
|
auth: true
|
|
3964
4336
|
});
|
|
3965
4337
|
}
|
|
3966
4338
|
};
|
|
3967
4339
|
function isThreadType(type) {
|
|
3968
|
-
return type ===
|
|
4340
|
+
return type === import_types18.ChannelType.AnnouncementThread || type === import_types18.ChannelType.PublicThread || type === import_types18.ChannelType.PrivateThread;
|
|
3969
4341
|
}
|
|
3970
4342
|
|
|
3971
4343
|
// src/Domain/Channel/ThreadManager.ts
|
|
@@ -3978,13 +4350,13 @@ var ThreadManager = class {
|
|
|
3978
4350
|
* Forum and media channels must use {@link createPost}.
|
|
3979
4351
|
*/
|
|
3980
4352
|
async create(options) {
|
|
3981
|
-
if (this.channel.type ===
|
|
4353
|
+
if (this.channel.type === import_types19.ChannelType.GuildForum || this.channel.type === import_types19.ChannelType.GuildMedia) {
|
|
3982
4354
|
throw new import_util4.FluxerError("Forum and media channels start posts with createPost", {
|
|
3983
4355
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
3984
4356
|
});
|
|
3985
4357
|
}
|
|
3986
4358
|
const data = await this.channel.client.rest.post(
|
|
3987
|
-
|
|
4359
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
3988
4360
|
{
|
|
3989
4361
|
body: toStartThreadBody(this.channel.type, options),
|
|
3990
4362
|
auth: true,
|
|
@@ -3998,7 +4370,7 @@ var ThreadManager = class {
|
|
|
3998
4370
|
* The post is a public thread. `message` is its first message.
|
|
3999
4371
|
*/
|
|
4000
4372
|
async createPost(options) {
|
|
4001
|
-
if (this.channel.type !==
|
|
4373
|
+
if (this.channel.type !== import_types19.ChannelType.GuildForum && this.channel.type !== import_types19.ChannelType.GuildMedia) {
|
|
4002
4374
|
throw new import_util4.FluxerError("createPost is for forum and media channels", {
|
|
4003
4375
|
code: import_util3.ErrorCodes.InvalidChannelType
|
|
4004
4376
|
});
|
|
@@ -4008,7 +4380,7 @@ var ThreadManager = class {
|
|
|
4008
4380
|
});
|
|
4009
4381
|
const body = {
|
|
4010
4382
|
name: options.name,
|
|
4011
|
-
type:
|
|
4383
|
+
type: import_types19.ChannelType.PublicThread,
|
|
4012
4384
|
message: toForumThreadMessage(prepared.body)
|
|
4013
4385
|
};
|
|
4014
4386
|
if (options.autoArchiveDuration !== void 0) {
|
|
@@ -4017,7 +4389,7 @@ var ThreadManager = class {
|
|
|
4017
4389
|
if (options.rateLimitPerUser !== void 0) body.rate_limit_per_user = options.rateLimitPerUser;
|
|
4018
4390
|
if (options.appliedTags !== void 0) body.applied_tags = options.appliedTags;
|
|
4019
4391
|
const data = await this.channel.client.rest.post(
|
|
4020
|
-
|
|
4392
|
+
import_types19.Routes.channelThreads(this.channel.id),
|
|
4021
4393
|
{
|
|
4022
4394
|
body,
|
|
4023
4395
|
files: prepared.files,
|
|
@@ -4036,7 +4408,7 @@ var ThreadManager = class {
|
|
|
4036
4408
|
* `before` is an ISO-8601 archive timestamp.
|
|
4037
4409
|
*/
|
|
4038
4410
|
async fetchArchived(options) {
|
|
4039
|
-
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);
|
|
4040
4412
|
const data = await this.channel.client.rest.get(
|
|
4041
4413
|
withQuery(path, { before: options.before, limit: options.limit })
|
|
4042
4414
|
);
|
|
@@ -4048,7 +4420,7 @@ var ThreadManager = class {
|
|
|
4048
4420
|
*/
|
|
4049
4421
|
async fetchJoinedPrivateArchived(options) {
|
|
4050
4422
|
const data = await this.channel.client.rest.get(
|
|
4051
|
-
withQuery(
|
|
4423
|
+
withQuery(import_types19.Routes.channelJoinedArchivedPrivateThreads(this.channel.id), {
|
|
4052
4424
|
before: options?.before,
|
|
4053
4425
|
limit: options?.limit
|
|
4054
4426
|
})
|
|
@@ -4061,7 +4433,7 @@ var ThreadManager = class {
|
|
|
4061
4433
|
*/
|
|
4062
4434
|
async search(options) {
|
|
4063
4435
|
const data = await this.channel.client.rest.get(
|
|
4064
|
-
withQuery(
|
|
4436
|
+
withQuery(import_types19.Routes.channelThreadSearch(this.channel.id), {
|
|
4065
4437
|
name: options?.name,
|
|
4066
4438
|
tag: options?.tag,
|
|
4067
4439
|
tag_setting: options?.tagSetting,
|
|
@@ -4089,7 +4461,7 @@ var ThreadManager = class {
|
|
|
4089
4461
|
}
|
|
4090
4462
|
/** Set the auto-archive and slowmode defaults copied onto new threads. */
|
|
4091
4463
|
async editDefaults(options) {
|
|
4092
|
-
return this.channel.client.rest.patch(
|
|
4464
|
+
return this.channel.client.rest.patch(import_types19.Routes.channel(this.channel.id), {
|
|
4093
4465
|
body: toThreadParentEditBody(options),
|
|
4094
4466
|
auth: true,
|
|
4095
4467
|
...auditReasonHeaders(options.reason)
|
|
@@ -4107,7 +4479,7 @@ function isSearchNotReady(data) {
|
|
|
4107
4479
|
return "code" in data && data.code === "SEARCH_INDEX_NOT_READY";
|
|
4108
4480
|
}
|
|
4109
4481
|
async function fetchActiveThreads(client, guildId) {
|
|
4110
|
-
const data = await client.rest.get(
|
|
4482
|
+
const data = await client.rest.get(import_types19.Routes.guildActiveThreads(guildId));
|
|
4111
4483
|
return fetchedThreadsFrom(client, data);
|
|
4112
4484
|
}
|
|
4113
4485
|
|
|
@@ -4166,10 +4538,10 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4166
4538
|
* `defaultForumLayout` is sent only for forum channels.
|
|
4167
4539
|
*/
|
|
4168
4540
|
async edit(options) {
|
|
4169
|
-
const data = await this.client.rest.patch(
|
|
4541
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4170
4542
|
body: {
|
|
4171
4543
|
...toChannelEditBody(options),
|
|
4172
|
-
...forumParentWire(options, this.type ===
|
|
4544
|
+
...forumParentWire(options, this.type === import_types20.ChannelType.GuildForum)
|
|
4173
4545
|
},
|
|
4174
4546
|
auth: true,
|
|
4175
4547
|
...auditReasonHeaders(options.reason)
|
|
@@ -4195,7 +4567,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4195
4567
|
}
|
|
4196
4568
|
/** Set the auto-archive and slowmode defaults copied onto new posts. */
|
|
4197
4569
|
async editThreadDefaults(options) {
|
|
4198
|
-
const data = await this.client.rest.patch(
|
|
4570
|
+
const data = await this.client.rest.patch(import_types20.Routes.channel(this.id), {
|
|
4199
4571
|
body: toThreadParentEditBody(options),
|
|
4200
4572
|
auth: true,
|
|
4201
4573
|
...auditReasonHeaders(options.reason)
|
|
@@ -4205,7 +4577,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4205
4577
|
}
|
|
4206
4578
|
/** Create a tag. The response replaces {@link availableTags}. */
|
|
4207
4579
|
async createTag(options) {
|
|
4208
|
-
const data = await this.client.rest.post(
|
|
4580
|
+
const data = await this.client.rest.post(import_types20.Routes.channelTags(this.id), {
|
|
4209
4581
|
body: toForumTagBody(options),
|
|
4210
4582
|
auth: true,
|
|
4211
4583
|
...auditReasonHeaders(options.reason)
|
|
@@ -4215,7 +4587,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4215
4587
|
}
|
|
4216
4588
|
/** Replace a tag. The response replaces {@link availableTags}. */
|
|
4217
4589
|
async editTag(tagId, options) {
|
|
4218
|
-
const data = await this.client.rest.put(
|
|
4590
|
+
const data = await this.client.rest.put(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4219
4591
|
body: toForumTagBody(options),
|
|
4220
4592
|
auth: true,
|
|
4221
4593
|
...auditReasonHeaders(options.reason)
|
|
@@ -4225,7 +4597,7 @@ var ThreadOnlyChannel = class extends GuildChannel {
|
|
|
4225
4597
|
}
|
|
4226
4598
|
/** Delete a tag. The response replaces {@link availableTags}. */
|
|
4227
4599
|
async deleteTag(tagId, reason) {
|
|
4228
|
-
const data = await this.client.rest.delete(
|
|
4600
|
+
const data = await this.client.rest.delete(import_types20.Routes.channelTag(this.id, tagId), {
|
|
4229
4601
|
auth: true,
|
|
4230
4602
|
...auditReasonHeaders(reason)
|
|
4231
4603
|
});
|
|
@@ -4254,23 +4626,24 @@ var MediaChannel = class extends ThreadOnlyChannel {
|
|
|
4254
4626
|
};
|
|
4255
4627
|
|
|
4256
4628
|
// src/Domain/Channel/Factory.ts
|
|
4257
|
-
var
|
|
4629
|
+
var import_types21 = require("@fluxerjs/types");
|
|
4258
4630
|
var GUILD_FACTORIES = {
|
|
4259
|
-
[
|
|
4260
|
-
[
|
|
4261
|
-
[
|
|
4262
|
-
[
|
|
4263
|
-
[
|
|
4264
|
-
[
|
|
4265
|
-
[
|
|
4266
|
-
[
|
|
4267
|
-
[
|
|
4268
|
-
[
|
|
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)
|
|
4269
4642
|
};
|
|
4270
4643
|
var DM_TYPES = /* @__PURE__ */ new Set([
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4644
|
+
import_types21.ChannelType.DM,
|
|
4645
|
+
import_types21.ChannelType.GroupDM,
|
|
4646
|
+
import_types21.ChannelType.DMPersonalNotes
|
|
4274
4647
|
]);
|
|
4275
4648
|
function createDM(client, data) {
|
|
4276
4649
|
return new DMChannel(client, data);
|
|
@@ -4290,11 +4663,11 @@ Channel.createDM = createDM;
|
|
|
4290
4663
|
bindThreadManager((channel) => new ThreadManager(channel));
|
|
4291
4664
|
|
|
4292
4665
|
// src/Domain/Guild/Cache.ts
|
|
4293
|
-
var
|
|
4666
|
+
var import_types28 = require("@fluxerjs/types");
|
|
4294
4667
|
|
|
4295
4668
|
// src/Domain/Guild/GuildEmoji.ts
|
|
4296
|
-
var
|
|
4297
|
-
var
|
|
4669
|
+
var import_types22 = require("@fluxerjs/types");
|
|
4670
|
+
var import_util15 = require("@fluxerjs/util");
|
|
4298
4671
|
var GuildEmoji = class extends Base {
|
|
4299
4672
|
client;
|
|
4300
4673
|
id;
|
|
@@ -4330,11 +4703,11 @@ var GuildEmoji = class extends Base {
|
|
|
4330
4703
|
}
|
|
4331
4704
|
/** Unix timestamp (ms) when this emoji was created, derived from its snowflake ID. */
|
|
4332
4705
|
get createdTimestamp() {
|
|
4333
|
-
return
|
|
4706
|
+
return import_util15.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4334
4707
|
}
|
|
4335
4708
|
/** Date when this emoji was created, derived from its snowflake ID. */
|
|
4336
4709
|
get createdAt() {
|
|
4337
|
-
return
|
|
4710
|
+
return import_util15.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4338
4711
|
}
|
|
4339
4712
|
/** Renders this emoji for use in message content: `<:name:id>` (or `<a:name:id>` when animated). */
|
|
4340
4713
|
toString() {
|
|
@@ -4342,7 +4715,7 @@ var GuildEmoji = class extends Base {
|
|
|
4342
4715
|
}
|
|
4343
4716
|
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
4344
4717
|
async delete(reason) {
|
|
4345
|
-
await this.client.rest.delete(
|
|
4718
|
+
await this.client.rest.delete(import_types22.Routes.guildEmoji(this.guildId, this.id), {
|
|
4346
4719
|
auth: true,
|
|
4347
4720
|
...auditReasonHeaders(reason)
|
|
4348
4721
|
});
|
|
@@ -4355,7 +4728,7 @@ var GuildEmoji = class extends Base {
|
|
|
4355
4728
|
*/
|
|
4356
4729
|
async edit(options) {
|
|
4357
4730
|
const { reason, name } = options;
|
|
4358
|
-
const data = await this.client.rest.patch(
|
|
4731
|
+
const data = await this.client.rest.patch(import_types22.Routes.guildEmoji(this.guildId, this.id), {
|
|
4359
4732
|
body: { name },
|
|
4360
4733
|
auth: true,
|
|
4361
4734
|
...auditReasonHeaders(reason)
|
|
@@ -4366,20 +4739,20 @@ var GuildEmoji = class extends Base {
|
|
|
4366
4739
|
};
|
|
4367
4740
|
|
|
4368
4741
|
// src/Domain/Guild/GuildMember.ts
|
|
4369
|
-
var
|
|
4370
|
-
var
|
|
4742
|
+
var import_types25 = require("@fluxerjs/types");
|
|
4743
|
+
var import_util17 = require("@fluxerjs/util");
|
|
4371
4744
|
|
|
4372
4745
|
// src/Helpers/Permissions.ts
|
|
4373
|
-
var
|
|
4374
|
-
var
|
|
4746
|
+
var import_types23 = require("@fluxerjs/types");
|
|
4747
|
+
var import_util16 = require("@fluxerjs/util");
|
|
4375
4748
|
function computePermissions(basePermissions, overwrites, memberRoles, memberId, isOwner) {
|
|
4376
|
-
if (isOwner) return
|
|
4377
|
-
if ((basePermissions &
|
|
4378
|
-
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;
|
|
4379
4752
|
}
|
|
4380
4753
|
let perms = basePermissions;
|
|
4381
4754
|
for (const overwrite of overwrites ?? []) {
|
|
4382
|
-
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;
|
|
4383
4756
|
if (!applies) continue;
|
|
4384
4757
|
const allow = BigInt(overwrite.allow || "0");
|
|
4385
4758
|
const deny = BigInt(overwrite.deny || "0");
|
|
@@ -4390,7 +4763,7 @@ function computePermissions(basePermissions, overwrites, memberRoles, memberId,
|
|
|
4390
4763
|
|
|
4391
4764
|
// src/Domain/Guild/GuildMemberRoleManager.ts
|
|
4392
4765
|
var import_collection7 = require("@fluxerjs/collection");
|
|
4393
|
-
var
|
|
4766
|
+
var import_types24 = require("@fluxerjs/types");
|
|
4394
4767
|
function roleId(roleOrId) {
|
|
4395
4768
|
return typeof roleOrId === "string" ? roleOrId : roleOrId.id;
|
|
4396
4769
|
}
|
|
@@ -4419,7 +4792,7 @@ var GuildMemberRoleManager = class {
|
|
|
4419
4792
|
const id = roleId(roleOrId);
|
|
4420
4793
|
if (this.ids.includes(id)) return;
|
|
4421
4794
|
await this.member.client.rest.put(
|
|
4422
|
-
|
|
4795
|
+
import_types24.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4423
4796
|
);
|
|
4424
4797
|
this.ids.push(id);
|
|
4425
4798
|
}
|
|
@@ -4428,13 +4801,13 @@ var GuildMemberRoleManager = class {
|
|
|
4428
4801
|
const idx = this.ids.indexOf(id);
|
|
4429
4802
|
if (idx === -1) return;
|
|
4430
4803
|
await this.member.client.rest.delete(
|
|
4431
|
-
|
|
4804
|
+
import_types24.Routes.guildMemberRole(this.member.guild.id, this.member.id, id)
|
|
4432
4805
|
);
|
|
4433
4806
|
this.ids.splice(idx, 1);
|
|
4434
4807
|
}
|
|
4435
4808
|
async set(roleIds) {
|
|
4436
4809
|
const data = await this.member.client.rest.patch(
|
|
4437
|
-
|
|
4810
|
+
import_types24.Routes.guildMember(this.member.guild.id, this.member.id),
|
|
4438
4811
|
{ body: { roles: roleIds }, auth: true }
|
|
4439
4812
|
);
|
|
4440
4813
|
this.ids = data.roles ? [...data.roles] : [];
|
|
@@ -4588,7 +4961,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4588
4961
|
*/
|
|
4589
4962
|
async edit(options) {
|
|
4590
4963
|
const isMe = this.client.user?.id === this.id;
|
|
4591
|
-
const route = isMe ?
|
|
4964
|
+
const route = isMe ? import_types25.Routes.guildMemberMe(this.guild.id) : import_types25.Routes.guildMember(this.guild.id, this.id);
|
|
4592
4965
|
const data = await this.client.rest.patch(route, {
|
|
4593
4966
|
body: toMemberEditBody(options),
|
|
4594
4967
|
auth: true,
|
|
@@ -4605,7 +4978,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4605
4978
|
* @see {@link permissionsIn} for channel-specific permissions
|
|
4606
4979
|
*/
|
|
4607
4980
|
get permissions() {
|
|
4608
|
-
return new
|
|
4981
|
+
return new import_util17.PermissionsBitField(this._effectivePermissions([], []));
|
|
4609
4982
|
}
|
|
4610
4983
|
/**
|
|
4611
4984
|
* Effective permissions in a channel (roles + overwrites).
|
|
@@ -4613,7 +4986,7 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4613
4986
|
* @returns Computed permissions bitfield
|
|
4614
4987
|
*/
|
|
4615
4988
|
permissionsIn(channel) {
|
|
4616
|
-
return new
|
|
4989
|
+
return new import_util17.PermissionsBitField(
|
|
4617
4990
|
this._effectivePermissions(channel.permissionOverwrites.toJSON(), [...this.roles.roleIds])
|
|
4618
4991
|
);
|
|
4619
4992
|
}
|
|
@@ -4638,19 +5011,19 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4638
5011
|
* False for the guild owner, self, or when the bot lacks Kick Members / role hierarchy.
|
|
4639
5012
|
*/
|
|
4640
5013
|
get kickable() {
|
|
4641
|
-
return this._moderatableWith(
|
|
5014
|
+
return this._moderatableWith(import_util17.PermissionFlags.KickMembers);
|
|
4642
5015
|
}
|
|
4643
5016
|
/**
|
|
4644
5017
|
* Whether the bot can ban this member (cache-only; needs `members.me`).
|
|
4645
5018
|
*/
|
|
4646
5019
|
get bannable() {
|
|
4647
|
-
return this._moderatableWith(
|
|
5020
|
+
return this._moderatableWith(import_util17.PermissionFlags.BanMembers);
|
|
4648
5021
|
}
|
|
4649
5022
|
/**
|
|
4650
5023
|
* Whether the bot can timeout this member (cache-only; needs `members.me`).
|
|
4651
5024
|
*/
|
|
4652
5025
|
get moderatable() {
|
|
4653
|
-
return this._moderatableWith(
|
|
5026
|
+
return this._moderatableWith(import_util17.PermissionFlags.ModerateMembers);
|
|
4654
5027
|
}
|
|
4655
5028
|
_moderatableWith(flag) {
|
|
4656
5029
|
const me = this.guild.members.me;
|
|
@@ -4701,8 +5074,8 @@ var GuildMember = class _GuildMember extends Base {
|
|
|
4701
5074
|
};
|
|
4702
5075
|
|
|
4703
5076
|
// src/Domain/Guild/GuildSticker.ts
|
|
4704
|
-
var
|
|
4705
|
-
var
|
|
5077
|
+
var import_types26 = require("@fluxerjs/types");
|
|
5078
|
+
var import_util18 = require("@fluxerjs/util");
|
|
4706
5079
|
var GuildSticker = class extends Base {
|
|
4707
5080
|
client;
|
|
4708
5081
|
id;
|
|
@@ -4744,15 +5117,15 @@ var GuildSticker = class extends Base {
|
|
|
4744
5117
|
}
|
|
4745
5118
|
/** Unix timestamp (ms) when this sticker was created, derived from its snowflake ID. */
|
|
4746
5119
|
get createdTimestamp() {
|
|
4747
|
-
return
|
|
5120
|
+
return import_util18.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4748
5121
|
}
|
|
4749
5122
|
/** Date when this sticker was created, derived from its snowflake ID. */
|
|
4750
5123
|
get createdAt() {
|
|
4751
|
-
return
|
|
5124
|
+
return import_util18.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4752
5125
|
}
|
|
4753
5126
|
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
4754
5127
|
async delete(reason) {
|
|
4755
|
-
await this.client.rest.delete(
|
|
5128
|
+
await this.client.rest.delete(import_types26.Routes.guildSticker(this.guildId, this.id), {
|
|
4756
5129
|
auth: true,
|
|
4757
5130
|
...auditReasonHeaders(reason)
|
|
4758
5131
|
});
|
|
@@ -4765,7 +5138,7 @@ var GuildSticker = class extends Base {
|
|
|
4765
5138
|
*/
|
|
4766
5139
|
async edit(options) {
|
|
4767
5140
|
const { reason, ...body } = options;
|
|
4768
|
-
const data = await this.client.rest.patch(
|
|
5141
|
+
const data = await this.client.rest.patch(import_types26.Routes.guildSticker(this.guildId, this.id), {
|
|
4769
5142
|
body,
|
|
4770
5143
|
auth: true,
|
|
4771
5144
|
...auditReasonHeaders(reason)
|
|
@@ -4778,8 +5151,8 @@ var GuildSticker = class extends Base {
|
|
|
4778
5151
|
};
|
|
4779
5152
|
|
|
4780
5153
|
// src/Domain/Guild/Role.ts
|
|
4781
|
-
var
|
|
4782
|
-
var
|
|
5154
|
+
var import_types27 = require("@fluxerjs/types");
|
|
5155
|
+
var import_util19 = require("@fluxerjs/util");
|
|
4783
5156
|
var Role = class _Role extends Base {
|
|
4784
5157
|
/** Parent client instance. */
|
|
4785
5158
|
client;
|
|
@@ -4801,6 +5174,8 @@ var Role = class _Role extends Base {
|
|
|
4801
5174
|
mentionable;
|
|
4802
5175
|
/** Unicode emoji for this role (null = none). */
|
|
4803
5176
|
unicodeEmoji;
|
|
5177
|
+
/** Role icon image hash (null = none). */
|
|
5178
|
+
icon;
|
|
4804
5179
|
/** Hoist position (null = not hoisted). */
|
|
4805
5180
|
hoistPosition;
|
|
4806
5181
|
constructor(client, data, guildId) {
|
|
@@ -4808,22 +5183,28 @@ var Role = class _Role extends Base {
|
|
|
4808
5183
|
this.client = client;
|
|
4809
5184
|
this.id = data.id;
|
|
4810
5185
|
this.guildId = guildId;
|
|
4811
|
-
this.name = data.name;
|
|
4812
|
-
this.color = data.color;
|
|
4813
|
-
this.position = data.position;
|
|
4814
|
-
this._permissions = data.permissions;
|
|
5186
|
+
this.name = data.name ?? "";
|
|
5187
|
+
this.color = data.color ?? 0;
|
|
5188
|
+
this.position = data.position ?? 0;
|
|
5189
|
+
this._permissions = data.permissions ?? "0";
|
|
4815
5190
|
this.hoist = !!data.hoist;
|
|
4816
5191
|
this.mentionable = !!data.mentionable;
|
|
4817
5192
|
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
5193
|
+
this.icon = data.icon ?? null;
|
|
4818
5194
|
this.hoistPosition = data.hoist_position ?? null;
|
|
4819
5195
|
}
|
|
4820
5196
|
/**
|
|
4821
5197
|
* Permissions bitfield (Administrator grants all permissions).
|
|
4822
5198
|
*/
|
|
4823
5199
|
get permissions() {
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
5200
|
+
let bits;
|
|
5201
|
+
try {
|
|
5202
|
+
bits = BigInt(this._permissions ?? "0");
|
|
5203
|
+
} catch {
|
|
5204
|
+
bits = 0n;
|
|
5205
|
+
}
|
|
5206
|
+
return new import_util19.PermissionsBitField(
|
|
5207
|
+
(bits & import_util19.PermissionFlags.Administrator) !== 0n ? import_util19.ALL_PERMISSIONS_BIGINT : bits
|
|
4827
5208
|
);
|
|
4828
5209
|
}
|
|
4829
5210
|
/**
|
|
@@ -4840,25 +5221,26 @@ var Role = class _Role extends Base {
|
|
|
4840
5221
|
*/
|
|
4841
5222
|
/** Unix timestamp (ms) when this role was created, derived from its snowflake ID. */
|
|
4842
5223
|
get createdTimestamp() {
|
|
4843
|
-
return
|
|
5224
|
+
return import_util19.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
4844
5225
|
}
|
|
4845
5226
|
/** Date when this role was created, derived from its snowflake ID. */
|
|
4846
5227
|
get createdAt() {
|
|
4847
|
-
return
|
|
5228
|
+
return import_util19.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
4848
5229
|
}
|
|
4849
5230
|
toString() {
|
|
4850
5231
|
return `<@&${this.id}>`;
|
|
4851
5232
|
}
|
|
4852
5233
|
/** @internal */
|
|
4853
5234
|
_patch(data) {
|
|
4854
|
-
this.name = data.name;
|
|
4855
|
-
this.color = data.color;
|
|
4856
|
-
this.position = data.position;
|
|
4857
|
-
this._permissions = data.permissions;
|
|
4858
|
-
this.hoist = !!data.hoist;
|
|
4859
|
-
this.mentionable = !!data.mentionable;
|
|
4860
|
-
this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
4861
|
-
this.
|
|
5235
|
+
if (data.name !== void 0) this.name = data.name;
|
|
5236
|
+
if (data.color !== void 0) this.color = data.color;
|
|
5237
|
+
if (data.position !== void 0) this.position = data.position;
|
|
5238
|
+
if (data.permissions !== void 0) this._permissions = data.permissions;
|
|
5239
|
+
if (data.hoist !== void 0) this.hoist = !!data.hoist;
|
|
5240
|
+
if (data.mentionable !== void 0) this.mentionable = !!data.mentionable;
|
|
5241
|
+
if (data.unicode_emoji !== void 0) this.unicodeEmoji = data.unicode_emoji ?? null;
|
|
5242
|
+
if (data.icon !== void 0) this.icon = data.icon ?? null;
|
|
5243
|
+
if (data.hoist_position !== void 0) this.hoistPosition = data.hoist_position ?? null;
|
|
4862
5244
|
}
|
|
4863
5245
|
/**
|
|
4864
5246
|
* Snapshot for role-update events (before in-place patch).
|
|
@@ -4876,6 +5258,7 @@ var Role = class _Role extends Base {
|
|
|
4876
5258
|
hoist: this.hoist,
|
|
4877
5259
|
mentionable: this.mentionable,
|
|
4878
5260
|
unicode_emoji: this.unicodeEmoji,
|
|
5261
|
+
icon: this.icon,
|
|
4879
5262
|
hoist_position: this.hoistPosition
|
|
4880
5263
|
},
|
|
4881
5264
|
this.guildId
|
|
@@ -4888,7 +5271,7 @@ var Role = class _Role extends Base {
|
|
|
4888
5271
|
*/
|
|
4889
5272
|
async edit(options) {
|
|
4890
5273
|
const body = toRoleEditBody(options);
|
|
4891
|
-
const data = await this.client.rest.patch(
|
|
5274
|
+
const data = await this.client.rest.patch(import_types27.Routes.guildRole(this.guildId, this.id), {
|
|
4892
5275
|
body: Object.keys(body).length ? body : void 0,
|
|
4893
5276
|
auth: true,
|
|
4894
5277
|
...auditReasonHeaders(options.reason)
|
|
@@ -4901,7 +5284,7 @@ var Role = class _Role extends Base {
|
|
|
4901
5284
|
* @param reason - Audit log reason (`X-Audit-Log-Reason`)
|
|
4902
5285
|
*/
|
|
4903
5286
|
async delete(reason) {
|
|
4904
|
-
await this.client.rest.delete(
|
|
5287
|
+
await this.client.rest.delete(import_types27.Routes.guildRole(this.guildId, this.id), {
|
|
4905
5288
|
auth: true,
|
|
4906
5289
|
...auditReasonHeaders(reason)
|
|
4907
5290
|
});
|
|
@@ -5002,7 +5385,7 @@ function syncChannels(guild, channels) {
|
|
|
5002
5385
|
}
|
|
5003
5386
|
}
|
|
5004
5387
|
function isThreadChannelType(type) {
|
|
5005
|
-
return type ===
|
|
5388
|
+
return type === import_types28.ChannelType.AnnouncementThread || type === import_types28.ChannelType.PublicThread || type === import_types28.ChannelType.PrivateThread;
|
|
5006
5389
|
}
|
|
5007
5390
|
function syncThreads(guild, threads, alsoKeep = /* @__PURE__ */ new Set()) {
|
|
5008
5391
|
const keep = new Set(alsoKeep);
|
|
@@ -5053,6 +5436,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5053
5436
|
});
|
|
5054
5437
|
this.client = client;
|
|
5055
5438
|
}
|
|
5439
|
+
pendingFetches = /* @__PURE__ */ new Map();
|
|
5056
5440
|
/**
|
|
5057
5441
|
* Remove a channel from cache. Does not delete it on the API.
|
|
5058
5442
|
* Use {@link Channel.delete} after {@link fetch} to delete the channel.
|
|
@@ -5065,9 +5449,11 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5065
5449
|
}
|
|
5066
5450
|
return deleted;
|
|
5067
5451
|
}
|
|
5068
|
-
/** Retrieve from cache, otherwise {@link fetch}. */
|
|
5452
|
+
/** Retrieve from cache (hydrating partial stubs), otherwise {@link fetch}. */
|
|
5069
5453
|
async resolve(channelId) {
|
|
5070
|
-
|
|
5454
|
+
const id = normalizeSnowflakeId(channelId, "channels.resolve()");
|
|
5455
|
+
const cached = this.get(id);
|
|
5456
|
+
return cached && !cached.partial ? cached : this.fetch(id);
|
|
5071
5457
|
}
|
|
5072
5458
|
/**
|
|
5073
5459
|
* Fetch a channel by ID. The returned {@link Channel} has {@link Channel.delete}
|
|
@@ -5080,10 +5466,23 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5080
5466
|
* @throws {@link FluxerError} with CHANNEL_NOT_FOUND if missing
|
|
5081
5467
|
*/
|
|
5082
5468
|
async fetch(channelId, options) {
|
|
5083
|
-
const
|
|
5084
|
-
|
|
5469
|
+
const id = normalizeSnowflakeId(channelId, "channels.fetch()");
|
|
5470
|
+
const cached = this.get(id);
|
|
5471
|
+
if (cached && !cached.partial && !options?.force) return cached;
|
|
5472
|
+
return dedupeFetch(this.pendingFetches, id, async () => this.fetchFresh(id));
|
|
5473
|
+
}
|
|
5474
|
+
async fetchFresh(channelId) {
|
|
5085
5475
|
try {
|
|
5086
|
-
const data =
|
|
5476
|
+
const data = assertApiObjectWithId(
|
|
5477
|
+
await this.client.rest.get(import_types29.Routes.channel(channelId)),
|
|
5478
|
+
"channels.fetch()"
|
|
5479
|
+
);
|
|
5480
|
+
const existing = this.get(channelId);
|
|
5481
|
+
if (existing && existing.type === data.type) {
|
|
5482
|
+
existing._patch(data);
|
|
5483
|
+
putChannel(this.client, existing);
|
|
5484
|
+
return existing;
|
|
5485
|
+
}
|
|
5087
5486
|
const guildId = "guild_id" in data ? data.guild_id : void 0;
|
|
5088
5487
|
if (guildId) {
|
|
5089
5488
|
const guild = this.client.guilds.get(guildId);
|
|
@@ -5128,7 +5527,7 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5128
5527
|
defaultAllowedMentions: this.client.options.defaultAllowedMentions
|
|
5129
5528
|
});
|
|
5130
5529
|
const data = await this.client.rest.post(
|
|
5131
|
-
|
|
5530
|
+
import_types29.Routes.channelMessages(channelId),
|
|
5132
5531
|
postPayload
|
|
5133
5532
|
);
|
|
5134
5533
|
this.client._addMessageToCache(channelId, data);
|
|
@@ -5139,12 +5538,12 @@ var ChannelManager = class extends import_collection8.LimitedCollection {
|
|
|
5139
5538
|
// src/ClientCore/Client.ts
|
|
5140
5539
|
var import_node_events3 = require("events");
|
|
5141
5540
|
var import_rest3 = require("@fluxerjs/rest");
|
|
5142
|
-
var
|
|
5143
|
-
var
|
|
5541
|
+
var import_types46 = require("@fluxerjs/types");
|
|
5542
|
+
var import_util27 = require("@fluxerjs/util");
|
|
5144
5543
|
|
|
5145
5544
|
// src/Domain/User.ts
|
|
5146
|
-
var
|
|
5147
|
-
var
|
|
5545
|
+
var import_types30 = require("@fluxerjs/types");
|
|
5546
|
+
var import_util20 = require("@fluxerjs/util");
|
|
5148
5547
|
var User = class extends Base {
|
|
5149
5548
|
/** Parent client instance. */
|
|
5150
5549
|
client;
|
|
@@ -5168,12 +5567,15 @@ var User = class extends Base {
|
|
|
5168
5567
|
system;
|
|
5169
5568
|
/** Banner hash for profile. */
|
|
5170
5569
|
banner;
|
|
5570
|
+
/** True when this user was created from an ID-only stub and not yet hydrated from REST/gateway. */
|
|
5571
|
+
partial;
|
|
5171
5572
|
constructor(client, data) {
|
|
5172
5573
|
super();
|
|
5173
5574
|
this.client = client;
|
|
5174
5575
|
this.id = data.id;
|
|
5175
|
-
this.
|
|
5176
|
-
this.
|
|
5576
|
+
this.partial = typeof data.username !== "string" || data.username.length === 0;
|
|
5577
|
+
this.username = data.username ?? "Unknown";
|
|
5578
|
+
this.discriminator = data.discriminator ?? "0";
|
|
5177
5579
|
this.globalName = data.global_name ?? null;
|
|
5178
5580
|
this.avatar = data.avatar ?? null;
|
|
5179
5581
|
this.bot = !!data.bot;
|
|
@@ -5184,13 +5586,18 @@ var User = class extends Base {
|
|
|
5184
5586
|
}
|
|
5185
5587
|
/** @internal */
|
|
5186
5588
|
_patch(data) {
|
|
5187
|
-
this.username = data.username;
|
|
5188
|
-
this.discriminator = data.discriminator;
|
|
5189
|
-
this.globalName = data.global_name ?? null;
|
|
5190
|
-
this.avatar = data.avatar ?? null;
|
|
5589
|
+
if (data.username !== void 0) this.username = data.username;
|
|
5590
|
+
if (data.discriminator !== void 0) this.discriminator = data.discriminator;
|
|
5591
|
+
if (data.global_name !== void 0) this.globalName = data.global_name ?? null;
|
|
5592
|
+
if (data.avatar !== void 0) this.avatar = data.avatar ?? null;
|
|
5191
5593
|
if (data.avatar_color !== void 0) this.avatarColor = data.avatar_color;
|
|
5192
5594
|
if (data.flags !== void 0) this.flags = data.flags;
|
|
5193
5595
|
if (data.banner !== void 0) this.banner = data.banner;
|
|
5596
|
+
if (typeof data.username === "string" && data.username.length > 0) this.partial = false;
|
|
5597
|
+
}
|
|
5598
|
+
/** Fetch the full user from REST when this instance is a partial stub. */
|
|
5599
|
+
async fetch() {
|
|
5600
|
+
return this.client.users.fetch(this.id, { force: true });
|
|
5194
5601
|
}
|
|
5195
5602
|
cdnOpts() {
|
|
5196
5603
|
return {
|
|
@@ -5228,11 +5635,11 @@ var User = class extends Base {
|
|
|
5228
5635
|
*/
|
|
5229
5636
|
/** Unix timestamp (ms) when this account was created, derived from its snowflake ID. */
|
|
5230
5637
|
get createdTimestamp() {
|
|
5231
|
-
return
|
|
5638
|
+
return import_util20.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
5232
5639
|
}
|
|
5233
5640
|
/** Date when this account was created, derived from its snowflake ID. */
|
|
5234
5641
|
get createdAt() {
|
|
5235
|
-
return
|
|
5642
|
+
return import_util20.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
5236
5643
|
}
|
|
5237
5644
|
toString() {
|
|
5238
5645
|
return `<@${this.id}>`;
|
|
@@ -5242,7 +5649,7 @@ var User = class extends Base {
|
|
|
5242
5649
|
* @returns DM channel instance (cached if already open)
|
|
5243
5650
|
*/
|
|
5244
5651
|
async createDM() {
|
|
5245
|
-
const data = await this.client.rest.post(
|
|
5652
|
+
const data = await this.client.rest.post(import_types30.Routes.userMeChannels(), {
|
|
5246
5653
|
body: { recipient_id: this.id },
|
|
5247
5654
|
auth: true
|
|
5248
5655
|
});
|
|
@@ -5320,28 +5727,28 @@ function resolveCacheLimits(input) {
|
|
|
5320
5727
|
|
|
5321
5728
|
// src/ClientCore/ClientEmoji.ts
|
|
5322
5729
|
var import_collection9 = require("@fluxerjs/collection");
|
|
5323
|
-
var
|
|
5324
|
-
var
|
|
5730
|
+
var import_types31 = require("@fluxerjs/types");
|
|
5731
|
+
var import_util21 = require("@fluxerjs/util");
|
|
5325
5732
|
async function resolveClientEmoji(client, emoji, guildId) {
|
|
5326
5733
|
if (typeof emoji === "object" && emoji.id) {
|
|
5327
|
-
return (0,
|
|
5734
|
+
return (0, import_util21.formatEmoji)({ name: emoji.name, id: emoji.id, animated: emoji.animated });
|
|
5328
5735
|
}
|
|
5329
|
-
const parsed = (0,
|
|
5736
|
+
const parsed = (0, import_util21.parseEmoji)(
|
|
5330
5737
|
typeof emoji === "string" ? emoji : emoji.id ? `:${emoji.name}:` : emoji.name
|
|
5331
5738
|
);
|
|
5332
5739
|
if (!parsed) {
|
|
5333
5740
|
throw new import_util4.FluxerError("Invalid emoji", { code: import_util3.ErrorCodes.InvalidEmoji });
|
|
5334
5741
|
}
|
|
5335
5742
|
if (parsed.id) {
|
|
5336
|
-
return (0,
|
|
5743
|
+
return (0, import_util21.formatEmoji)(parsed);
|
|
5337
5744
|
}
|
|
5338
5745
|
if (!/^\w+$/.test(parsed.name)) return parsed.name;
|
|
5339
|
-
const unicodeFromShortcode = (0,
|
|
5746
|
+
const unicodeFromShortcode = (0, import_util21.getUnicodeFromShortcode)(parsed.name);
|
|
5340
5747
|
if (unicodeFromShortcode) return unicodeFromShortcode;
|
|
5341
5748
|
if (guildId) {
|
|
5342
|
-
const emojis = await client.rest.get(
|
|
5749
|
+
const emojis = await client.rest.get(import_types31.Routes.guildEmojis(guildId));
|
|
5343
5750
|
const found = emojis.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
5344
|
-
if (found) return (0,
|
|
5751
|
+
if (found) return (0, import_util21.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
5345
5752
|
throw new import_util4.FluxerError(
|
|
5346
5753
|
`Custom emoji ":${parsed.name}:" not found in guild. Use name:id or <:name:id> format.`,
|
|
5347
5754
|
{ code: import_util3.ErrorCodes.EmojiNotFound }
|
|
@@ -5356,26 +5763,26 @@ async function resolveClientEmoji(client, emoji, guildId) {
|
|
|
5356
5763
|
return parsed.name;
|
|
5357
5764
|
}
|
|
5358
5765
|
async function fetchInstance(client) {
|
|
5359
|
-
const raw = await client.rest.get(
|
|
5766
|
+
const raw = await client.rest.get(import_types31.Routes.instanceDiscovery(), {
|
|
5360
5767
|
auth: false,
|
|
5361
5768
|
unversioned: true
|
|
5362
5769
|
});
|
|
5363
5770
|
return parseInstanceDiscovery(raw);
|
|
5364
5771
|
}
|
|
5365
5772
|
function fetchGatewayInfo(client) {
|
|
5366
|
-
return client.rest.get(
|
|
5773
|
+
return client.rest.get(import_types31.Routes.gatewayBot());
|
|
5367
5774
|
}
|
|
5368
5775
|
function fetchEmojiMetadata(client, emojiId) {
|
|
5369
|
-
return client.rest.get(
|
|
5776
|
+
return client.rest.get(import_types31.Routes.emojiMetadata(emojiId), { auth: true });
|
|
5370
5777
|
}
|
|
5371
5778
|
function fetchStickerMetadata(client, stickerId) {
|
|
5372
|
-
return client.rest.get(
|
|
5779
|
+
return client.rest.get(import_types31.Routes.stickerMetadata(stickerId), { auth: true });
|
|
5373
5780
|
}
|
|
5374
5781
|
function fetchApplication(client) {
|
|
5375
|
-
return client.rest.get(
|
|
5782
|
+
return client.rest.get(import_types31.Routes.applicationsMe(), { auth: true });
|
|
5376
5783
|
}
|
|
5377
5784
|
async function fetchOAuthApplications(client) {
|
|
5378
|
-
const data = await client.rest.get(
|
|
5785
|
+
const data = await client.rest.get(import_types31.Routes.oauth2ApplicationsMe(), { auth: true });
|
|
5379
5786
|
if (Array.isArray(data)) return data;
|
|
5380
5787
|
if (data && typeof data === "object" && "applications" in data && Array.isArray(data.applications)) {
|
|
5381
5788
|
return data.applications;
|
|
@@ -5394,14 +5801,14 @@ function assertChannelIdBatch(name, channelIds) {
|
|
|
5394
5801
|
}
|
|
5395
5802
|
function preloadMessages(client, channelIds) {
|
|
5396
5803
|
assertChannelIdBatch("preloadMessages", channelIds);
|
|
5397
|
-
return client.rest.post(
|
|
5804
|
+
return client.rest.post(import_types31.Routes.preloadMessages(), {
|
|
5398
5805
|
body: { channels: channelIds },
|
|
5399
5806
|
auth: true
|
|
5400
5807
|
});
|
|
5401
5808
|
}
|
|
5402
5809
|
function preloadMessagesAlt(client, channelIds) {
|
|
5403
5810
|
assertChannelIdBatch("preloadMessagesAlt", channelIds);
|
|
5404
|
-
return client.rest.post(
|
|
5811
|
+
return client.rest.post(import_types31.Routes.preloadMessagesAlt(), {
|
|
5405
5812
|
body: { channels: channelIds },
|
|
5406
5813
|
auth: true
|
|
5407
5814
|
});
|
|
@@ -5409,7 +5816,7 @@ function preloadMessagesAlt(client, channelIds) {
|
|
|
5409
5816
|
async function bulkFetchMessages(client, requests, options = {}) {
|
|
5410
5817
|
validateBulkMessageFetchRequests(requests);
|
|
5411
5818
|
const wire = toBulkFetchWire(requests);
|
|
5412
|
-
const data = await client.rest.post(
|
|
5819
|
+
const data = await client.rest.post(import_types31.Routes.channelsMessagesBulk(), {
|
|
5413
5820
|
body: { requests: wire },
|
|
5414
5821
|
auth: true
|
|
5415
5822
|
});
|
|
@@ -5426,12 +5833,74 @@ async function bulkFetchMessages(client, requests, options = {}) {
|
|
|
5426
5833
|
};
|
|
5427
5834
|
}
|
|
5428
5835
|
async function searchMessages(client, options = {}) {
|
|
5429
|
-
const data = await client.rest.post(
|
|
5836
|
+
const data = await client.rest.post(import_types31.Routes.searchMessages(), {
|
|
5430
5837
|
body: toMessageSearchBody(options),
|
|
5431
5838
|
auth: true
|
|
5432
5839
|
});
|
|
5433
5840
|
return toMessageSearchResponse(data);
|
|
5434
5841
|
}
|
|
5842
|
+
function fetchEmojiSource(client, emojiId) {
|
|
5843
|
+
return client.rest.get(
|
|
5844
|
+
import_types31.Routes.emojiSource(emojiId),
|
|
5845
|
+
{ auth: true }
|
|
5846
|
+
);
|
|
5847
|
+
}
|
|
5848
|
+
function fetchStickerSource(client, stickerId) {
|
|
5849
|
+
return client.rest.get(
|
|
5850
|
+
import_types31.Routes.stickerSource(stickerId),
|
|
5851
|
+
{ auth: true }
|
|
5852
|
+
);
|
|
5853
|
+
}
|
|
5854
|
+
function fetchDiscoveryCategories(client) {
|
|
5855
|
+
return client.rest.get(
|
|
5856
|
+
import_types31.Routes.discoveryCategories(),
|
|
5857
|
+
{ auth: true }
|
|
5858
|
+
);
|
|
5859
|
+
}
|
|
5860
|
+
function searchDiscoveryGuilds(client, options = {}) {
|
|
5861
|
+
const params = new URLSearchParams();
|
|
5862
|
+
if (options.query !== void 0) params.set("query", options.query);
|
|
5863
|
+
if (options.category !== void 0) params.set("category", String(options.category));
|
|
5864
|
+
if (options.language !== void 0) params.set("language", options.language);
|
|
5865
|
+
if (options.tag !== void 0) params.set("tag", options.tag);
|
|
5866
|
+
if (options.sort_by !== void 0) params.set("sort_by", options.sort_by);
|
|
5867
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
5868
|
+
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
5869
|
+
const qs2 = params.toString();
|
|
5870
|
+
return client.rest.get(
|
|
5871
|
+
qs2 ? `${import_types31.Routes.discoveryGuilds()}?${qs2}` : import_types31.Routes.discoveryGuilds(),
|
|
5872
|
+
{ auth: true }
|
|
5873
|
+
);
|
|
5874
|
+
}
|
|
5875
|
+
function fetchExperiments(client) {
|
|
5876
|
+
return client.rest.get(import_types31.Routes.experiments(), {
|
|
5877
|
+
auth: true
|
|
5878
|
+
});
|
|
5879
|
+
}
|
|
5880
|
+
function refreshAttachmentUrls(client, attachmentUrls) {
|
|
5881
|
+
return client.rest.post(
|
|
5882
|
+
import_types31.Routes.attachmentsRefreshUrls(),
|
|
5883
|
+
{ body: { attachment_urls: attachmentUrls }, auth: true }
|
|
5884
|
+
);
|
|
5885
|
+
}
|
|
5886
|
+
function fetchInstanceBadges(client, options = {}) {
|
|
5887
|
+
const params = new URLSearchParams();
|
|
5888
|
+
if (options.ids !== void 0) params.set("ids", options.ids);
|
|
5889
|
+
if (options.after !== void 0) params.set("after", options.after);
|
|
5890
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
5891
|
+
if (options.version !== void 0) params.set("version", options.version);
|
|
5892
|
+
const qs2 = params.toString();
|
|
5893
|
+
return client.rest.get(
|
|
5894
|
+
qs2 ? `${import_types31.Routes.instanceBadges()}?${qs2}` : import_types31.Routes.instanceBadges(),
|
|
5895
|
+
{ auth: false }
|
|
5896
|
+
);
|
|
5897
|
+
}
|
|
5898
|
+
function fetchChannelPostData(client, channelId, threadIds) {
|
|
5899
|
+
return client.rest.post(
|
|
5900
|
+
import_types31.Routes.channelPostData(channelId),
|
|
5901
|
+
{ body: { thread_ids: threadIds }, auth: true }
|
|
5902
|
+
);
|
|
5903
|
+
}
|
|
5435
5904
|
|
|
5436
5905
|
// src/ClientCore/ClientEvents.ts
|
|
5437
5906
|
function createEventMethods(client) {
|
|
@@ -5451,17 +5920,18 @@ var import_ws = require("@fluxerjs/ws");
|
|
|
5451
5920
|
|
|
5452
5921
|
// src/Domain/Guild/Guild.ts
|
|
5453
5922
|
var import_collection12 = require("@fluxerjs/collection");
|
|
5454
|
-
var
|
|
5455
|
-
var
|
|
5923
|
+
var import_types41 = require("@fluxerjs/types");
|
|
5924
|
+
var import_util23 = require("@fluxerjs/util");
|
|
5456
5925
|
|
|
5457
5926
|
// src/ClientCore/GuildMemberManager.ts
|
|
5458
5927
|
var import_collection10 = require("@fluxerjs/collection");
|
|
5459
|
-
var
|
|
5928
|
+
var import_types32 = require("@fluxerjs/types");
|
|
5460
5929
|
var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
5461
5930
|
constructor(guild) {
|
|
5462
5931
|
super({ maxSize: guild.client.cache.limits.members });
|
|
5463
5932
|
this.guild = guild;
|
|
5464
5933
|
}
|
|
5934
|
+
pendingFetches = /* @__PURE__ */ new Map();
|
|
5465
5935
|
/**
|
|
5466
5936
|
* Get a guild member from cache or fetch from the API if not present.
|
|
5467
5937
|
* Convenience helper to avoid repeating `guild.members.get(userId) ?? (await guild.fetchMember(userId))`.
|
|
@@ -5473,7 +5943,9 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5473
5943
|
* console.log(member.displayName);
|
|
5474
5944
|
*/
|
|
5475
5945
|
async resolve(userId) {
|
|
5476
|
-
|
|
5946
|
+
const id = normalizeSnowflakeId(userId, "members.resolve()");
|
|
5947
|
+
const cached = this.get(id);
|
|
5948
|
+
return cached && !cached.user.partial ? cached : this.fetch(id);
|
|
5477
5949
|
}
|
|
5478
5950
|
/**
|
|
5479
5951
|
* The current bot user as a GuildMember in this guild.
|
|
@@ -5501,10 +5973,11 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5501
5973
|
return this.guild.fetchMe();
|
|
5502
5974
|
}
|
|
5503
5975
|
async fetch(userIdOrOptions, options) {
|
|
5504
|
-
if (typeof userIdOrOptions === "string") {
|
|
5505
|
-
const
|
|
5506
|
-
|
|
5507
|
-
|
|
5976
|
+
if (typeof userIdOrOptions === "string" || typeof userIdOrOptions === "number") {
|
|
5977
|
+
const id = normalizeSnowflakeId(userIdOrOptions, "members.fetch()");
|
|
5978
|
+
const cached = this.get(id);
|
|
5979
|
+
if (cached && !cached.user.partial && !options?.force) return cached;
|
|
5980
|
+
return dedupeFetch(this.pendingFetches, id, async () => this.guild.fetchMember(id));
|
|
5508
5981
|
}
|
|
5509
5982
|
return this.fetchMany(userIdOrOptions);
|
|
5510
5983
|
}
|
|
@@ -5513,10 +5986,14 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5513
5986
|
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
5514
5987
|
if (options?.after) params.set("after", options.after);
|
|
5515
5988
|
const qs2 = params.toString();
|
|
5516
|
-
const url =
|
|
5517
|
-
const data =
|
|
5989
|
+
const url = import_types32.Routes.guildMembers(this.guild.id) + (qs2 ? `?${qs2}` : "");
|
|
5990
|
+
const data = assertApiArray(
|
|
5991
|
+
await this.guild.client.rest.get(url, { auth: true }),
|
|
5992
|
+
"members.fetch()"
|
|
5993
|
+
);
|
|
5518
5994
|
const members = [];
|
|
5519
5995
|
for (const m of data) {
|
|
5996
|
+
if (!m?.user?.id) continue;
|
|
5520
5997
|
const member = new GuildMember(
|
|
5521
5998
|
this.guild.client,
|
|
5522
5999
|
{ ...m, guild_id: this.guild.id },
|
|
@@ -5536,7 +6013,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5536
6013
|
*/
|
|
5537
6014
|
async search(options = {}) {
|
|
5538
6015
|
const data = await this.guild.client.rest.post(
|
|
5539
|
-
|
|
6016
|
+
import_types32.Routes.guildMembersSearch(this.guild.id),
|
|
5540
6017
|
{ body: toMemberSearchBody(options), auth: true }
|
|
5541
6018
|
);
|
|
5542
6019
|
const offset = options.offset ?? 0;
|
|
@@ -5562,7 +6039,7 @@ var GuildMemberManager = class extends import_collection10.LimitedCollection {
|
|
|
5562
6039
|
};
|
|
5563
6040
|
|
|
5564
6041
|
// src/Domain/Guild/Admin.ts
|
|
5565
|
-
var
|
|
6042
|
+
var import_types33 = require("@fluxerjs/types");
|
|
5566
6043
|
function toAuditLogEntryPayload(entry, guildId) {
|
|
5567
6044
|
return {
|
|
5568
6045
|
id: entry.id,
|
|
@@ -5583,7 +6060,7 @@ function toVanityPayload(data) {
|
|
|
5583
6060
|
return { code: data.code ?? null, uses: data.uses };
|
|
5584
6061
|
}
|
|
5585
6062
|
async function fetchAuditLogs(guild, options) {
|
|
5586
|
-
const url =
|
|
6063
|
+
const url = import_types33.Routes.guildAuditLogs(guild.id) + qs({
|
|
5587
6064
|
limit: options?.limit,
|
|
5588
6065
|
before: options?.before,
|
|
5589
6066
|
after: options?.after,
|
|
@@ -5607,7 +6084,7 @@ async function fetchAuditLogs(guild, options) {
|
|
|
5607
6084
|
};
|
|
5608
6085
|
}
|
|
5609
6086
|
async function editGuild(guild, options) {
|
|
5610
|
-
const data = await guild.client.rest.patch(
|
|
6087
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guild(guild.id), {
|
|
5611
6088
|
body: toGuildEditBody(options),
|
|
5612
6089
|
auth: true
|
|
5613
6090
|
});
|
|
@@ -5615,13 +6092,13 @@ async function editGuild(guild, options) {
|
|
|
5615
6092
|
return guild;
|
|
5616
6093
|
}
|
|
5617
6094
|
async function fetchVanityURL(guild) {
|
|
5618
|
-
const data = await guild.client.rest.get(
|
|
6095
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5619
6096
|
auth: true
|
|
5620
6097
|
});
|
|
5621
6098
|
return toVanityPayload(data);
|
|
5622
6099
|
}
|
|
5623
6100
|
async function editVanityURL(guild, code) {
|
|
5624
|
-
const data = await guild.client.rest.patch(
|
|
6101
|
+
const data = await guild.client.rest.patch(import_types33.Routes.guildVanityUrl(guild.id), {
|
|
5625
6102
|
body: { code },
|
|
5626
6103
|
auth: true
|
|
5627
6104
|
});
|
|
@@ -5629,14 +6106,14 @@ async function editVanityURL(guild, code) {
|
|
|
5629
6106
|
return toVanityPayload(data);
|
|
5630
6107
|
}
|
|
5631
6108
|
async function fetchDiscoveryStatus(guild) {
|
|
5632
|
-
const data = await guild.client.rest.get(
|
|
6109
|
+
const data = await guild.client.rest.get(import_types33.Routes.guildDiscovery(guild.id), {
|
|
5633
6110
|
auth: true
|
|
5634
6111
|
});
|
|
5635
6112
|
return toDiscoveryStatusPayload(data);
|
|
5636
6113
|
}
|
|
5637
6114
|
async function applyForDiscovery(guild, options) {
|
|
5638
6115
|
const data = await guild.client.rest.post(
|
|
5639
|
-
|
|
6116
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5640
6117
|
{
|
|
5641
6118
|
body: toDiscoveryBody(options),
|
|
5642
6119
|
auth: true
|
|
@@ -5646,7 +6123,7 @@ async function applyForDiscovery(guild, options) {
|
|
|
5646
6123
|
}
|
|
5647
6124
|
async function editDiscoveryApplication(guild, options) {
|
|
5648
6125
|
const data = await guild.client.rest.patch(
|
|
5649
|
-
|
|
6126
|
+
import_types33.Routes.guildDiscovery(guild.id),
|
|
5650
6127
|
{
|
|
5651
6128
|
body: toDiscoveryBody(options),
|
|
5652
6129
|
auth: true
|
|
@@ -5655,34 +6132,39 @@ async function editDiscoveryApplication(guild, options) {
|
|
|
5655
6132
|
return toDiscoveryApplicationPayload(data);
|
|
5656
6133
|
}
|
|
5657
6134
|
async function withdrawDiscoveryApplication(guild) {
|
|
5658
|
-
await guild.client.rest.delete(
|
|
6135
|
+
await guild.client.rest.delete(import_types33.Routes.guildDiscovery(guild.id), { auth: true });
|
|
5659
6136
|
}
|
|
5660
6137
|
async function deleteGuild(guild, options) {
|
|
5661
6138
|
const body = options ? toSudoBody(options) : {};
|
|
5662
|
-
await guild.client.rest.post(
|
|
6139
|
+
await guild.client.rest.post(import_types33.Routes.guildDelete(guild.id), {
|
|
5663
6140
|
body,
|
|
5664
6141
|
auth: true
|
|
5665
6142
|
});
|
|
5666
6143
|
guild.client.guilds.delete(guild.id);
|
|
5667
6144
|
}
|
|
5668
6145
|
async function transferOwnership(guild, newOwnerId, password) {
|
|
5669
|
-
await guild.client.rest.post(
|
|
6146
|
+
await guild.client.rest.post(import_types33.Routes.guildTransferOwnership(guild.id), {
|
|
5670
6147
|
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
5671
6148
|
auth: true
|
|
5672
6149
|
});
|
|
5673
6150
|
}
|
|
5674
6151
|
|
|
5675
6152
|
// src/Domain/Guild/Channels.ts
|
|
5676
|
-
var
|
|
6153
|
+
var import_types34 = require("@fluxerjs/types");
|
|
5677
6154
|
async function createChannel(guild, options) {
|
|
5678
|
-
const created = await guild.client.rest.post(
|
|
6155
|
+
const created = await guild.client.rest.post(import_types34.Routes.guildChannels(guild.id), {
|
|
5679
6156
|
body: toChannelCreateBody(options),
|
|
5680
6157
|
auth: true
|
|
5681
6158
|
});
|
|
5682
6159
|
return cacheChannel(guild, created);
|
|
5683
6160
|
}
|
|
5684
6161
|
async function fetchChannels(guild) {
|
|
5685
|
-
const
|
|
6162
|
+
const raw = await guild.client.rest.get(import_types34.Routes.guildChannels(guild.id));
|
|
6163
|
+
if (!Array.isArray(raw))
|
|
6164
|
+
throw new TypeError(
|
|
6165
|
+
"guild.fetchChannels() received an invalid API payload (expected an array)"
|
|
6166
|
+
);
|
|
6167
|
+
const data = raw;
|
|
5686
6168
|
const channels = [];
|
|
5687
6169
|
for (const ch of data) {
|
|
5688
6170
|
const channel = cacheChannel(guild, ch);
|
|
@@ -5691,17 +6173,17 @@ async function fetchChannels(guild) {
|
|
|
5691
6173
|
return channels;
|
|
5692
6174
|
}
|
|
5693
6175
|
async function setChannelPositions(guild, updates) {
|
|
5694
|
-
await guild.client.rest.patch(
|
|
6176
|
+
await guild.client.rest.patch(import_types34.Routes.guildChannels(guild.id), {
|
|
5695
6177
|
body: toChannelPositionBody(updates),
|
|
5696
6178
|
auth: true
|
|
5697
6179
|
});
|
|
5698
6180
|
}
|
|
5699
6181
|
async function fetchWebhooks(guild) {
|
|
5700
|
-
const data = await guild.client.rest.get(
|
|
6182
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildWebhooks(guild.id));
|
|
5701
6183
|
return data.map((w) => new Webhook(guild.client, w));
|
|
5702
6184
|
}
|
|
5703
6185
|
async function fetchInvites(guild) {
|
|
5704
|
-
const data = await guild.client.rest.get(
|
|
6186
|
+
const data = await guild.client.rest.get(import_types34.Routes.guildInvites(guild.id));
|
|
5705
6187
|
return data.map((invite) => new Invite(guild.client, invite));
|
|
5706
6188
|
}
|
|
5707
6189
|
async function fetchInvite(guild, codeOrUrl) {
|
|
@@ -5721,14 +6203,14 @@ function resolveGuildOnlineCount(data) {
|
|
|
5721
6203
|
}
|
|
5722
6204
|
|
|
5723
6205
|
// src/Domain/Guild/Emojis.ts
|
|
5724
|
-
var
|
|
6206
|
+
var import_types35 = require("@fluxerjs/types");
|
|
5725
6207
|
async function fetchEmojis(guild) {
|
|
5726
|
-
const data = await guild.client.rest.get(
|
|
6208
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmojis(guild.id));
|
|
5727
6209
|
return data.map((e) => cacheEmoji(guild, e));
|
|
5728
6210
|
}
|
|
5729
6211
|
async function fetchEmoji(guild, emojiId) {
|
|
5730
6212
|
try {
|
|
5731
|
-
const data = await guild.client.rest.get(
|
|
6213
|
+
const data = await guild.client.rest.get(import_types35.Routes.guildEmoji(guild.id, emojiId));
|
|
5732
6214
|
return cacheEmoji(guild, data);
|
|
5733
6215
|
} catch (err) {
|
|
5734
6216
|
rethrowMapped(err, {
|
|
@@ -5739,7 +6221,7 @@ async function fetchEmoji(guild, emojiId) {
|
|
|
5739
6221
|
}
|
|
5740
6222
|
async function createEmoji(guild, options) {
|
|
5741
6223
|
const { reason, ...body } = options;
|
|
5742
|
-
const data = await guild.client.rest.post(
|
|
6224
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojis(guild.id), {
|
|
5743
6225
|
body,
|
|
5744
6226
|
auth: true,
|
|
5745
6227
|
...auditReasonHeaders(reason)
|
|
@@ -5747,7 +6229,7 @@ async function createEmoji(guild, options) {
|
|
|
5747
6229
|
return cacheEmoji(guild, data);
|
|
5748
6230
|
}
|
|
5749
6231
|
async function cloneEmoji(guild, sourceEmojiId) {
|
|
5750
|
-
const data = await guild.client.rest.post(
|
|
6232
|
+
const data = await guild.client.rest.post(import_types35.Routes.guildEmojisClone(guild.id), {
|
|
5751
6233
|
body: { source_emoji_id: sourceEmojiId },
|
|
5752
6234
|
auth: true
|
|
5753
6235
|
});
|
|
@@ -5755,7 +6237,7 @@ async function cloneEmoji(guild, sourceEmojiId) {
|
|
|
5755
6237
|
}
|
|
5756
6238
|
async function createEmojisBulk(guild, emojis) {
|
|
5757
6239
|
const data = await guild.client.rest.post(
|
|
5758
|
-
|
|
6240
|
+
import_types35.Routes.guildEmojisBulk(guild.id),
|
|
5759
6241
|
{ body: { emojis }, auth: true }
|
|
5760
6242
|
);
|
|
5761
6243
|
return { success: data.success.map((e) => cacheEmoji(guild, e)), failed: data.failed };
|
|
@@ -5775,18 +6257,22 @@ var GuildRoleManager = class extends import_collection11.LimitedCollection {
|
|
|
5775
6257
|
};
|
|
5776
6258
|
|
|
5777
6259
|
// src/Domain/Guild/MemberHttp.ts
|
|
5778
|
-
var
|
|
6260
|
+
var import_types36 = require("@fluxerjs/types");
|
|
5779
6261
|
async function fetchMember(guild, userId) {
|
|
6262
|
+
const id = normalizeSnowflakeId(userId, "members.fetch()");
|
|
5780
6263
|
try {
|
|
5781
6264
|
const data = await guild.client.rest.get(
|
|
5782
|
-
|
|
6265
|
+
import_types36.Routes.guildMember(guild.id, id)
|
|
5783
6266
|
);
|
|
6267
|
+
if (!data?.user?.id) {
|
|
6268
|
+
throw new TypeError("members.fetch() received an invalid API payload (missing user.id)");
|
|
6269
|
+
}
|
|
5784
6270
|
return cacheMember(guild, data);
|
|
5785
6271
|
} catch (err) {
|
|
5786
6272
|
rethrowMapped(err, {
|
|
5787
6273
|
notFound: {
|
|
5788
6274
|
code: import_util3.ErrorCodes.MemberNotFound,
|
|
5789
|
-
message: `Member ${
|
|
6275
|
+
message: `Member ${id} not found in guild`
|
|
5790
6276
|
},
|
|
5791
6277
|
fallback: "Failed to fetch guild member"
|
|
5792
6278
|
});
|
|
@@ -5794,17 +6280,20 @@ async function fetchMember(guild, userId) {
|
|
|
5794
6280
|
}
|
|
5795
6281
|
async function fetchMe(guild) {
|
|
5796
6282
|
const data = await guild.client.rest.get(
|
|
5797
|
-
|
|
6283
|
+
import_types36.Routes.guildMemberMe(guild.id),
|
|
5798
6284
|
{ auth: true }
|
|
5799
6285
|
);
|
|
6286
|
+
if (!data?.user?.id) {
|
|
6287
|
+
throw new TypeError("members.fetchMe() received an invalid API payload (missing user.id)");
|
|
6288
|
+
}
|
|
5800
6289
|
return cacheMember(guild, data);
|
|
5801
6290
|
}
|
|
5802
6291
|
|
|
5803
6292
|
// src/Domain/Guild/Moderation.ts
|
|
5804
|
-
var
|
|
6293
|
+
var import_types38 = require("@fluxerjs/types");
|
|
5805
6294
|
|
|
5806
6295
|
// src/Domain/Guild/GuildBan.ts
|
|
5807
|
-
var
|
|
6296
|
+
var import_types37 = require("@fluxerjs/types");
|
|
5808
6297
|
function parseOptionalDate2(value) {
|
|
5809
6298
|
if (value == null || value === "") return null;
|
|
5810
6299
|
const date = new Date(value);
|
|
@@ -5831,7 +6320,7 @@ var GuildBan = class extends Base {
|
|
|
5831
6320
|
* Requires Ban Members permission.
|
|
5832
6321
|
*/
|
|
5833
6322
|
async unban(reason) {
|
|
5834
|
-
await this.client.rest.delete(
|
|
6323
|
+
await this.client.rest.delete(import_types37.Routes.guildBan(this.guildId, this.user.id), {
|
|
5835
6324
|
auth: true,
|
|
5836
6325
|
...auditReasonHeaders(reason)
|
|
5837
6326
|
});
|
|
@@ -5841,35 +6330,39 @@ var GuildBan = class extends Base {
|
|
|
5841
6330
|
// src/Domain/Guild/Moderation.ts
|
|
5842
6331
|
async function ban(guild, userId, options) {
|
|
5843
6332
|
const body = options ? toGuildBanBody(options) : {};
|
|
5844
|
-
await guild.client.rest.put(
|
|
6333
|
+
await guild.client.rest.put(import_types38.Routes.guildBan(guild.id, userId), {
|
|
5845
6334
|
body: Object.keys(body).length ? body : void 0,
|
|
5846
6335
|
auth: true,
|
|
5847
6336
|
...auditReasonHeaders(options?.reason)
|
|
5848
6337
|
});
|
|
5849
6338
|
}
|
|
6339
|
+
async function fetchBan(guild, userId) {
|
|
6340
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBan(guild.id, userId));
|
|
6341
|
+
return new GuildBan(guild.client, { ...data, guild_id: guild.id }, guild.id);
|
|
6342
|
+
}
|
|
5850
6343
|
async function fetchBans(guild) {
|
|
5851
|
-
const data = await guild.client.rest.get(
|
|
6344
|
+
const data = await guild.client.rest.get(import_types38.Routes.guildBans(guild.id));
|
|
5852
6345
|
return data.map((b) => new GuildBan(guild.client, { ...b, guild_id: guild.id }, guild.id));
|
|
5853
6346
|
}
|
|
5854
6347
|
async function unban(guild, userId, reason) {
|
|
5855
|
-
await guild.client.rest.delete(
|
|
6348
|
+
await guild.client.rest.delete(import_types38.Routes.guildBan(guild.id, userId), {
|
|
5856
6349
|
auth: true,
|
|
5857
6350
|
...auditReasonHeaders(reason)
|
|
5858
6351
|
});
|
|
5859
6352
|
}
|
|
5860
6353
|
async function kick(guild, userId, reason) {
|
|
5861
|
-
await guild.client.rest.delete(
|
|
6354
|
+
await guild.client.rest.delete(import_types38.Routes.guildMember(guild.id, userId), {
|
|
5862
6355
|
auth: true,
|
|
5863
6356
|
...auditReasonHeaders(reason)
|
|
5864
6357
|
});
|
|
5865
6358
|
}
|
|
5866
6359
|
|
|
5867
6360
|
// src/Domain/Guild/Roles.ts
|
|
5868
|
-
var
|
|
5869
|
-
var
|
|
6361
|
+
var import_types39 = require("@fluxerjs/types");
|
|
6362
|
+
var import_util22 = require("@fluxerjs/util");
|
|
5870
6363
|
async function createRole(guild, options = {}) {
|
|
5871
6364
|
const body = toRoleCreateBody(options);
|
|
5872
|
-
const data = await guild.client.rest.post(
|
|
6365
|
+
const data = await guild.client.rest.post(import_types39.Routes.guildRoles(guild.id), {
|
|
5873
6366
|
body: Object.keys(body).length ? body : void 0,
|
|
5874
6367
|
auth: true,
|
|
5875
6368
|
...auditReasonHeaders(options.reason)
|
|
@@ -5877,12 +6370,14 @@ async function createRole(guild, options = {}) {
|
|
|
5877
6370
|
return cacheRole(guild, data);
|
|
5878
6371
|
}
|
|
5879
6372
|
async function fetchRoles(guild) {
|
|
5880
|
-
const data = await guild.client.rest.get(
|
|
6373
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
6374
|
+
if (!Array.isArray(data))
|
|
6375
|
+
throw new TypeError("guild.fetchRoles() received an invalid API payload (expected an array)");
|
|
5881
6376
|
return data.map((r) => cacheRole(guild, r));
|
|
5882
6377
|
}
|
|
5883
6378
|
async function fetchRole(guild, roleId2) {
|
|
5884
6379
|
try {
|
|
5885
|
-
const data = await guild.client.rest.get(
|
|
6380
|
+
const data = await guild.client.rest.get(import_types39.Routes.guildRole(guild.id, roleId2));
|
|
5886
6381
|
return cacheRole(guild, data);
|
|
5887
6382
|
} catch (err) {
|
|
5888
6383
|
rethrowMapped(err, {
|
|
@@ -5892,14 +6387,14 @@ async function fetchRole(guild, roleId2) {
|
|
|
5892
6387
|
}
|
|
5893
6388
|
}
|
|
5894
6389
|
async function resolveRoleId(guild, arg) {
|
|
5895
|
-
const parsed = (0,
|
|
6390
|
+
const parsed = (0, import_util22.parseRoleMention)(arg);
|
|
5896
6391
|
if (parsed) return parsed;
|
|
5897
6392
|
const trimmed = arg.trim();
|
|
5898
6393
|
if (/^\d{17,19}$/.test(trimmed)) return trimmed;
|
|
5899
6394
|
const needle = trimmed.toLowerCase();
|
|
5900
6395
|
const cached = guild.roles.find((r) => r.name?.toLowerCase() === needle);
|
|
5901
6396
|
if (cached) return cached.id;
|
|
5902
|
-
const roles = await guild.client.rest.get(
|
|
6397
|
+
const roles = await guild.client.rest.get(import_types39.Routes.guildRoles(guild.id));
|
|
5903
6398
|
const role = roles.find((r) => r.name?.toLowerCase() === needle);
|
|
5904
6399
|
if (!role) return null;
|
|
5905
6400
|
cacheRole(guild, role);
|
|
@@ -5908,7 +6403,7 @@ async function resolveRoleId(guild, arg) {
|
|
|
5908
6403
|
async function setRolePositions(guild, updates) {
|
|
5909
6404
|
return replaceRoles(
|
|
5910
6405
|
guild,
|
|
5911
|
-
await guild.client.rest.patch(
|
|
6406
|
+
await guild.client.rest.patch(import_types39.Routes.guildRoles(guild.id), {
|
|
5912
6407
|
body: updates,
|
|
5913
6408
|
auth: true
|
|
5914
6409
|
})
|
|
@@ -5917,7 +6412,7 @@ async function setRolePositions(guild, updates) {
|
|
|
5917
6412
|
async function setRoleHoistPositions(guild, updates) {
|
|
5918
6413
|
return replaceRoles(
|
|
5919
6414
|
guild,
|
|
5920
|
-
await guild.client.rest.patch(
|
|
6415
|
+
await guild.client.rest.patch(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
5921
6416
|
body: updates.map((u) => ({
|
|
5922
6417
|
id: u.id,
|
|
5923
6418
|
...u.hoistPosition !== void 0 ? { hoist_position: u.hoistPosition } : {}
|
|
@@ -5929,17 +6424,17 @@ async function setRoleHoistPositions(guild, updates) {
|
|
|
5929
6424
|
async function resetRoleHoistPositions(guild) {
|
|
5930
6425
|
return replaceRoles(
|
|
5931
6426
|
guild,
|
|
5932
|
-
await guild.client.rest.delete(
|
|
6427
|
+
await guild.client.rest.delete(import_types39.Routes.guildRolesHoistPositions(guild.id), {
|
|
5933
6428
|
auth: true
|
|
5934
6429
|
})
|
|
5935
6430
|
);
|
|
5936
6431
|
}
|
|
5937
6432
|
|
|
5938
6433
|
// src/Domain/Guild/Stickers.ts
|
|
5939
|
-
var
|
|
6434
|
+
var import_types40 = require("@fluxerjs/types");
|
|
5940
6435
|
async function createSticker(guild, options) {
|
|
5941
6436
|
const { reason, ...body } = options;
|
|
5942
|
-
const data = await guild.client.rest.post(
|
|
6437
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickers(guild.id), {
|
|
5943
6438
|
body,
|
|
5944
6439
|
auth: true,
|
|
5945
6440
|
...auditReasonHeaders(reason)
|
|
@@ -5947,7 +6442,7 @@ async function createSticker(guild, options) {
|
|
|
5947
6442
|
return cacheSticker(guild, data);
|
|
5948
6443
|
}
|
|
5949
6444
|
async function cloneSticker(guild, sourceStickerId) {
|
|
5950
|
-
const data = await guild.client.rest.post(
|
|
6445
|
+
const data = await guild.client.rest.post(import_types40.Routes.guildStickersClone(guild.id), {
|
|
5951
6446
|
body: { source_sticker_id: sourceStickerId },
|
|
5952
6447
|
auth: true
|
|
5953
6448
|
});
|
|
@@ -5955,17 +6450,17 @@ async function cloneSticker(guild, sourceStickerId) {
|
|
|
5955
6450
|
}
|
|
5956
6451
|
async function createStickersBulk(guild, stickers) {
|
|
5957
6452
|
const data = await guild.client.rest.post(
|
|
5958
|
-
|
|
6453
|
+
import_types40.Routes.guildStickersBulk(guild.id),
|
|
5959
6454
|
{ body: { stickers }, auth: true }
|
|
5960
6455
|
);
|
|
5961
6456
|
return { success: data.success.map((s) => cacheSticker(guild, s)), failed: data.failed };
|
|
5962
6457
|
}
|
|
5963
6458
|
async function fetchStickers(guild) {
|
|
5964
|
-
const data = await guild.client.rest.get(
|
|
6459
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildStickers(guild.id));
|
|
5965
6460
|
return data.map((s) => cacheSticker(guild, s));
|
|
5966
6461
|
}
|
|
5967
6462
|
async function fetchSticker(guild, stickerId) {
|
|
5968
|
-
const data = await guild.client.rest.get(
|
|
6463
|
+
const data = await guild.client.rest.get(import_types40.Routes.guildSticker(guild.id, stickerId));
|
|
5969
6464
|
return cacheSticker(guild, data);
|
|
5970
6465
|
}
|
|
5971
6466
|
|
|
@@ -5977,6 +6472,11 @@ var Guild = class extends Base {
|
|
|
5977
6472
|
id;
|
|
5978
6473
|
/** Whether the guild is currently available through the gateway. */
|
|
5979
6474
|
available = true;
|
|
6475
|
+
/**
|
|
6476
|
+
* True when only guild metadata is known (e.g. created from `GET /guilds/{id}`)
|
|
6477
|
+
* and nested channels/roles have not been synced yet. `guilds.resolve()` hydrates partial guilds.
|
|
6478
|
+
*/
|
|
6479
|
+
partial = true;
|
|
5980
6480
|
/** Guild name. */
|
|
5981
6481
|
name;
|
|
5982
6482
|
/** Icon hash (use {@link iconURL} to get full CDN URL). */
|
|
@@ -6049,6 +6549,10 @@ var Guild = class extends Base {
|
|
|
6049
6549
|
emojis;
|
|
6050
6550
|
/** Cached stickers in this guild. */
|
|
6051
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;
|
|
6052
6556
|
/**
|
|
6053
6557
|
* Construct a guild from API data.
|
|
6054
6558
|
* @param data - API guild from GET /guilds/{id} or gateway GUILD_CREATE
|
|
@@ -6065,6 +6569,7 @@ var Guild = class extends Base {
|
|
|
6065
6569
|
this.roles = new GuildRoleManager(this.id, { maxSize: client.cache.limits.roles });
|
|
6066
6570
|
this.emojis = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.emojis });
|
|
6067
6571
|
this.stickers = new import_collection12.LimitedCollection({ maxSize: client.cache.limits.stickers });
|
|
6572
|
+
this.stageInstances = new import_collection12.Collection();
|
|
6068
6573
|
this.name = data.name ?? "";
|
|
6069
6574
|
this.icon = data.icon ?? null;
|
|
6070
6575
|
this.banner = data.banner ?? null;
|
|
@@ -6082,7 +6587,7 @@ var Guild = class extends Base {
|
|
|
6082
6587
|
this.systemChannelFlags = data.system_channel_flags ?? 0;
|
|
6083
6588
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6084
6589
|
this.embedSplash = data.embed_splash ?? null;
|
|
6085
|
-
this.nsfwLevel = data.nsfw_level ??
|
|
6590
|
+
this.nsfwLevel = data.nsfw_level ?? import_types41.GuildNSFWLevel.Safe;
|
|
6086
6591
|
this.nsfw = data.nsfw ?? false;
|
|
6087
6592
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
6088
6593
|
this.contentWarningText = data.content_warning_text ?? null;
|
|
@@ -6094,6 +6599,7 @@ var Guild = class extends Base {
|
|
|
6094
6599
|
this.bannerHeight = data.banner_height ?? null;
|
|
6095
6600
|
this.splashWidth = data.splash_width ?? null;
|
|
6096
6601
|
this.splashHeight = data.splash_height ?? null;
|
|
6602
|
+
this.maxStageVideoChannelUsers = data.max_stage_video_channel_users ?? null;
|
|
6097
6603
|
this.memberCount = resolveGuildMemberCount(data) ?? null;
|
|
6098
6604
|
this.onlineCount = resolveGuildOnlineCount(data) ?? null;
|
|
6099
6605
|
for (const r of data.roles ?? []) {
|
|
@@ -6130,7 +6636,7 @@ var Guild = class extends Base {
|
|
|
6130
6636
|
this.splashCardAlignment = data.splash_card_alignment ?? 0;
|
|
6131
6637
|
}
|
|
6132
6638
|
if (data.embed_splash !== void 0) this.embedSplash = data.embed_splash ?? null;
|
|
6133
|
-
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;
|
|
6134
6640
|
if (data.nsfw !== void 0) this.nsfw = data.nsfw ?? false;
|
|
6135
6641
|
if (data.content_warning_level !== void 0) {
|
|
6136
6642
|
this.contentWarningLevel = data.content_warning_level ?? 0;
|
|
@@ -6150,6 +6656,9 @@ var Guild = class extends Base {
|
|
|
6150
6656
|
if (data.banner_height !== void 0) this.bannerHeight = data.banner_height ?? null;
|
|
6151
6657
|
if (data.splash_width !== void 0) this.splashWidth = data.splash_width ?? null;
|
|
6152
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
|
+
}
|
|
6153
6662
|
const memberCount = resolveGuildMemberCount(data);
|
|
6154
6663
|
if (memberCount !== void 0) this.memberCount = memberCount;
|
|
6155
6664
|
const onlineCount = resolveGuildOnlineCount(data);
|
|
@@ -6165,11 +6674,11 @@ var Guild = class extends Base {
|
|
|
6165
6674
|
}
|
|
6166
6675
|
/** Unix timestamp (ms) when this guild was created, derived from its snowflake ID. */
|
|
6167
6676
|
get createdTimestamp() {
|
|
6168
|
-
return
|
|
6677
|
+
return import_util23.SnowflakeUtil.timestampFromSnowflake(this.id);
|
|
6169
6678
|
}
|
|
6170
6679
|
/** Date when this guild was created, derived from its snowflake ID. */
|
|
6171
6680
|
get createdAt() {
|
|
6172
|
-
return
|
|
6681
|
+
return import_util23.SnowflakeUtil.dateFromSnowflake(this.id);
|
|
6173
6682
|
}
|
|
6174
6683
|
/** The guild's name. */
|
|
6175
6684
|
toString() {
|
|
@@ -6271,6 +6780,10 @@ var Guild = class extends Base {
|
|
|
6271
6780
|
ban(userId, options) {
|
|
6272
6781
|
return ban(this, userId, options);
|
|
6273
6782
|
}
|
|
6783
|
+
/** Fetch a single ban by user ID. Requires Ban Members. */
|
|
6784
|
+
fetchBan(userId) {
|
|
6785
|
+
return fetchBan(this, userId);
|
|
6786
|
+
}
|
|
6274
6787
|
/** Fetch all bans in this guild. Requires Ban Members. */
|
|
6275
6788
|
fetchBans() {
|
|
6276
6789
|
return fetchBans(this);
|
|
@@ -6366,7 +6879,7 @@ var Guild = class extends Base {
|
|
|
6366
6879
|
};
|
|
6367
6880
|
|
|
6368
6881
|
// src/Domain/Guild/Payload.ts
|
|
6369
|
-
var
|
|
6882
|
+
var import_util24 = require("@fluxerjs/util");
|
|
6370
6883
|
var TOP_LEVEL_COUNT_KEYS = [
|
|
6371
6884
|
"member_count",
|
|
6372
6885
|
"online_count",
|
|
@@ -6406,10 +6919,10 @@ function mergeTopLevelSnapshotFields(properties, raw) {
|
|
|
6406
6919
|
return out;
|
|
6407
6920
|
}
|
|
6408
6921
|
function normalizeGuildSnapshotPayload(raw) {
|
|
6409
|
-
if (!(0,
|
|
6922
|
+
if (!(0, import_util24.isRecord)(raw)) return null;
|
|
6410
6923
|
const flatPayload = isHydratableGuildPayload(raw) && (raw.roles === void 0 || Array.isArray(raw.roles)) ? raw : null;
|
|
6411
6924
|
let nestedPayload = null;
|
|
6412
|
-
if (Object.hasOwn(raw, "properties") && (0,
|
|
6925
|
+
if (Object.hasOwn(raw, "properties") && (0, import_util24.isRecord)(raw.properties)) {
|
|
6413
6926
|
const properties = raw.properties;
|
|
6414
6927
|
const rolesValid = raw.roles === void 0 || Array.isArray(raw.roles);
|
|
6415
6928
|
if (rolesValid && isHydratableGuildPayload(properties) && raw.id === properties.id) {
|
|
@@ -6421,7 +6934,7 @@ function normalizeGuildSnapshotPayload(raw) {
|
|
|
6421
6934
|
return flatPayload ?? nestedPayload;
|
|
6422
6935
|
}
|
|
6423
6936
|
function normalizeGuildUpdatePayload(raw) {
|
|
6424
|
-
if (!(0,
|
|
6937
|
+
if (!(0, import_util24.isRecord)(raw) || !isValidGuildPayload(raw)) return null;
|
|
6425
6938
|
return raw;
|
|
6426
6939
|
}
|
|
6427
6940
|
|
|
@@ -6451,6 +6964,9 @@ function upsertGuildFromSnapshot(client, guildData, resources = {}) {
|
|
|
6451
6964
|
if (resources.members !== void 0) mergeMembers(guild, resources.members);
|
|
6452
6965
|
if (resources.emojis !== void 0) syncEmojis(guild, resources.emojis);
|
|
6453
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);
|
|
6969
|
+
if (resources.channels !== void 0) guild.partial = false;
|
|
6454
6970
|
return { guild, created, recovered };
|
|
6455
6971
|
}
|
|
6456
6972
|
function applyGuildSnapshotFromGateway(client, raw) {
|
|
@@ -6464,7 +6980,9 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6464
6980
|
emojis: g.emojis,
|
|
6465
6981
|
stickers: g.stickers,
|
|
6466
6982
|
// A channel list without `threads` means this session has no viewable threads.
|
|
6467
|
-
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
|
|
6468
6986
|
});
|
|
6469
6987
|
if (g.voice_states?.length) {
|
|
6470
6988
|
client.emit(Events.VoiceStatesSync, {
|
|
@@ -6476,23 +6994,23 @@ function applyGuildSnapshotFromGateway(client, raw) {
|
|
|
6476
6994
|
}
|
|
6477
6995
|
|
|
6478
6996
|
// src/ClientCore/ClientUser.ts
|
|
6479
|
-
var
|
|
6997
|
+
var import_types42 = require("@fluxerjs/types");
|
|
6480
6998
|
var ClientUser = class extends User {
|
|
6481
6999
|
/** Broadcast presence (gateway opcode 3) on all shards. */
|
|
6482
7000
|
setPresence(presence) {
|
|
6483
7001
|
this.client.options.presence = presence;
|
|
6484
7002
|
const wire = toPresenceWire(presence);
|
|
6485
|
-
this.client._sendToAllShards({ op:
|
|
7003
|
+
this.client._sendToAllShards({ op: import_types42.GatewayOpcodes.PresenceUpdate, d: wire });
|
|
6486
7004
|
}
|
|
6487
7005
|
/** GET /users/@me — refresh the logged-in user from REST and patch this instance. */
|
|
6488
7006
|
async fetch() {
|
|
6489
|
-
const data = await this.client.rest.get(
|
|
7007
|
+
const data = await this.client.rest.get(import_types42.Routes.currentUser(), { auth: true });
|
|
6490
7008
|
this._patch(data);
|
|
6491
7009
|
return this;
|
|
6492
7010
|
}
|
|
6493
7011
|
/** GET /users/@me/guilds — returns camelCase partial guilds. */
|
|
6494
7012
|
async fetchGuilds(options) {
|
|
6495
|
-
const path =
|
|
7013
|
+
const path = import_types42.Routes.currentUserGuilds() + (options?.withCounts ? "?with_counts=true" : "");
|
|
6496
7014
|
const data = await this.client.rest.get(path, { auth: true });
|
|
6497
7015
|
return data.map((g) => ({
|
|
6498
7016
|
id: g.id,
|
|
@@ -6516,7 +7034,7 @@ var ClientUser = class extends User {
|
|
|
6516
7034
|
*/
|
|
6517
7035
|
async leaveGuild(guildId, options) {
|
|
6518
7036
|
const body = options ? toSudoBody(options) : void 0;
|
|
6519
|
-
await this.client.rest.delete(
|
|
7037
|
+
await this.client.rest.delete(import_types42.Routes.leaveGuild(guildId), {
|
|
6520
7038
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6521
7039
|
auth: true
|
|
6522
7040
|
});
|
|
@@ -6524,7 +7042,7 @@ var ClientUser = class extends User {
|
|
|
6524
7042
|
/** Delete every message authored by the caller across a guild (sudo). */
|
|
6525
7043
|
async bulkDeleteMyMessagesInGuild(guildId, options) {
|
|
6526
7044
|
const body = options ? toSudoBody(options) : void 0;
|
|
6527
|
-
await this.client.rest.post(
|
|
7045
|
+
await this.client.rest.post(import_types42.Routes.guildBulkDeleteMine(guildId), {
|
|
6528
7046
|
body: body && Object.keys(body).length ? body : void 0,
|
|
6529
7047
|
auth: true
|
|
6530
7048
|
});
|
|
@@ -6532,17 +7050,9 @@ var ClientUser = class extends User {
|
|
|
6532
7050
|
};
|
|
6533
7051
|
|
|
6534
7052
|
// src/ClientCore/EventHandlers/Helpers.ts
|
|
6535
|
-
var
|
|
7053
|
+
var import_util25 = require("@fluxerjs/util");
|
|
6536
7054
|
function unknownUser(id) {
|
|
6537
|
-
return {
|
|
6538
|
-
id,
|
|
6539
|
-
username: "Unknown",
|
|
6540
|
-
discriminator: "0",
|
|
6541
|
-
global_name: null,
|
|
6542
|
-
avatar: null,
|
|
6543
|
-
avatar_color: null,
|
|
6544
|
-
flags: 0
|
|
6545
|
-
};
|
|
7055
|
+
return { id };
|
|
6546
7056
|
}
|
|
6547
7057
|
function indexMember(_client, guild, data) {
|
|
6548
7058
|
if (!data.user?.id) return null;
|
|
@@ -6847,50 +7357,50 @@ var guildHandlers = {
|
|
|
6847
7357
|
};
|
|
6848
7358
|
|
|
6849
7359
|
// src/ClientCore/EventHandlers/Invites.ts
|
|
6850
|
-
var
|
|
7360
|
+
var import_types43 = require("@fluxerjs/types");
|
|
6851
7361
|
function normalizeInviteCreate(client, payload) {
|
|
6852
|
-
const raw = (0,
|
|
6853
|
-
const code = (0,
|
|
7362
|
+
const raw = (0, import_util25.asRecord)(payload);
|
|
7363
|
+
const code = (0, import_util25.str)(raw?.code);
|
|
6854
7364
|
if (!raw || !code) return null;
|
|
6855
|
-
const typeNum = (0,
|
|
6856
|
-
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;
|
|
6857
7367
|
const shared = {
|
|
6858
7368
|
code,
|
|
6859
7369
|
inviter: raw.inviter ?? null,
|
|
6860
|
-
member_count: (0,
|
|
7370
|
+
member_count: (0, import_util25.num)(raw.member_count),
|
|
6861
7371
|
expires_at: raw.expires_at ?? void 0,
|
|
6862
7372
|
temporary: typeof raw.temporary === "boolean" ? raw.temporary : void 0,
|
|
6863
|
-
created_at: (0,
|
|
6864
|
-
uses: (0,
|
|
6865
|
-
max_uses: (0,
|
|
6866
|
-
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)
|
|
6867
7377
|
};
|
|
6868
|
-
const guildObj = (0,
|
|
6869
|
-
const channelObj = (0,
|
|
6870
|
-
const guildId = (0,
|
|
6871
|
-
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";
|
|
6872
7382
|
const cachedGuild = guildId !== "0" ? client.guilds.get(guildId) : null;
|
|
6873
7383
|
const cachedChannel2 = channelId !== "0" ? client.channels.get(channelId) : null;
|
|
6874
7384
|
const channel = {
|
|
6875
7385
|
id: channelId,
|
|
6876
|
-
type: (0,
|
|
6877
|
-
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,
|
|
6878
7388
|
icon: channelObj?.icon ?? null
|
|
6879
7389
|
};
|
|
6880
|
-
if (type ===
|
|
7390
|
+
if (type === import_types43.InviteType.GroupDM) return { ...shared, type, channel };
|
|
6881
7391
|
return {
|
|
6882
7392
|
...shared,
|
|
6883
|
-
type:
|
|
7393
|
+
type: import_types43.InviteType.Guild,
|
|
6884
7394
|
guild: {
|
|
6885
7395
|
id: guildId,
|
|
6886
|
-
name: (0,
|
|
7396
|
+
name: (0, import_util25.str)(guildObj?.name) ?? cachedGuild?.name ?? "Unknown Guild",
|
|
6887
7397
|
icon: guildObj?.icon ?? null,
|
|
6888
7398
|
banner: guildObj?.banner ?? null,
|
|
6889
7399
|
splash: guildObj?.splash ?? null,
|
|
6890
7400
|
features: Array.isArray(guildObj?.features) ? guildObj.features : void 0
|
|
6891
7401
|
},
|
|
6892
7402
|
channel,
|
|
6893
|
-
presence_count: (0,
|
|
7403
|
+
presence_count: (0, import_util25.num)(raw.presence_count)
|
|
6894
7404
|
};
|
|
6895
7405
|
}
|
|
6896
7406
|
var inviteHandlers = {
|
|
@@ -7001,7 +7511,7 @@ var memberHandlers = {
|
|
|
7001
7511
|
};
|
|
7002
7512
|
|
|
7003
7513
|
// src/ClientCore/EventHandlers/Messages.ts
|
|
7004
|
-
var
|
|
7514
|
+
var import_util26 = require("@fluxerjs/util");
|
|
7005
7515
|
function cachedTextChannel(client, channelId) {
|
|
7006
7516
|
const channel = client.channels.get(channelId);
|
|
7007
7517
|
return channel?.isTextBased() ? channel : null;
|
|
@@ -7017,7 +7527,7 @@ function toPartialMessage(client, args) {
|
|
|
7017
7527
|
const cached = args.cached;
|
|
7018
7528
|
const authorId = args.authorId ?? cached?.author?.id ?? null;
|
|
7019
7529
|
const author = cached?.author ? client.getOrCreateUser(cached.author) : authorId ? client.users.get(authorId) ?? null : null;
|
|
7020
|
-
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;
|
|
7021
7531
|
return new PartialMessage(client, {
|
|
7022
7532
|
id: args.id,
|
|
7023
7533
|
channelId: args.channelId,
|
|
@@ -7223,6 +7733,9 @@ var passthroughHandlers = {
|
|
|
7223
7733
|
VOICE_SERVER_UPDATE: pass(Events.VoiceServerUpdate),
|
|
7224
7734
|
VOICE_STATE_ACK: pass(Events.VoiceStateAck),
|
|
7225
7735
|
ENTRANCE_SOUND_PLAY: pass(Events.EntranceSoundPlay),
|
|
7736
|
+
VOICE_SIGNAL: pass(Events.VoiceSignal),
|
|
7737
|
+
GUILD_HEALTH_UPDATE: pass(Events.GuildHealthUpdate),
|
|
7738
|
+
OPERATOR_PASS_UPDATE: pass(Events.OperatorPassUpdate),
|
|
7226
7739
|
TYPING_START(client, d) {
|
|
7227
7740
|
const data = d;
|
|
7228
7741
|
const payload = {
|
|
@@ -7278,6 +7791,46 @@ var passthroughHandlers = {
|
|
|
7278
7791
|
WEBAUTHN_CREDENTIALS_UPDATE: pass(Events.WebAuthnCredentialsUpdate)
|
|
7279
7792
|
};
|
|
7280
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
|
+
|
|
7281
7834
|
// src/ClientCore/EventHandlers/Threads.ts
|
|
7282
7835
|
function cachedChannel(client, id) {
|
|
7283
7836
|
const direct = client.channels.get(id);
|
|
@@ -7388,7 +7941,8 @@ var eventHandlers = buildRegistry(
|
|
|
7388
7941
|
inviteHandlers,
|
|
7389
7942
|
guildResourceHandlers,
|
|
7390
7943
|
passthroughHandlers,
|
|
7391
|
-
threadHandlers
|
|
7944
|
+
threadHandlers,
|
|
7945
|
+
stageHandlers
|
|
7392
7946
|
);
|
|
7393
7947
|
|
|
7394
7948
|
// src/ClientCore/GatewayDispatch.ts
|
|
@@ -7413,29 +7967,63 @@ function handleGatewayDispatch(client, payload, deferred) {
|
|
|
7413
7967
|
}
|
|
7414
7968
|
return dispatchGatewayPayload(client, payload);
|
|
7415
7969
|
}
|
|
7416
|
-
|
|
7970
|
+
var dispatchQueues = /* @__PURE__ */ new WeakMap();
|
|
7971
|
+
function queueFor(client) {
|
|
7972
|
+
let queue = dispatchQueues.get(client);
|
|
7973
|
+
if (!queue) {
|
|
7974
|
+
queue = { tail: Promise.resolve(), pending: 0 };
|
|
7975
|
+
dispatchQueues.set(client, queue);
|
|
7976
|
+
}
|
|
7977
|
+
return queue;
|
|
7978
|
+
}
|
|
7979
|
+
async function runGatewayHandler(client, payload) {
|
|
7417
7980
|
const event = payload.t;
|
|
7418
|
-
if (!event) return
|
|
7981
|
+
if (!event) return;
|
|
7419
7982
|
const handler = eventHandlers.get(event);
|
|
7420
7983
|
if (!handler) {
|
|
7421
7984
|
client.emit(Events.Debug, `[Gateway] Unhandled dispatch: ${event}`);
|
|
7422
|
-
return
|
|
7985
|
+
return;
|
|
7423
7986
|
}
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
}
|
|
7431
|
-
if (client.options.gatewayDeferHandlers
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
};
|
|
7436
|
-
|
|
7437
|
-
|
|
7987
|
+
if (payload.d !== null && payload.d !== void 0 && typeof payload.d !== "object") {
|
|
7988
|
+
client.emit(
|
|
7989
|
+
Events.Debug,
|
|
7990
|
+
`[Gateway] Ignoring malformed dispatch ${event}: payload is not an object`
|
|
7991
|
+
);
|
|
7992
|
+
return;
|
|
7993
|
+
}
|
|
7994
|
+
if (client.options.gatewayDeferHandlers !== false) {
|
|
7995
|
+
await new Promise((resolve) => {
|
|
7996
|
+
if (typeof setImmediate === "function") setImmediate(resolve);
|
|
7997
|
+
else setTimeout(resolve, 0);
|
|
7998
|
+
});
|
|
7999
|
+
}
|
|
8000
|
+
try {
|
|
8001
|
+
await handler(client, payload.d);
|
|
8002
|
+
} catch (err) {
|
|
8003
|
+
emitClientError(client, err);
|
|
8004
|
+
}
|
|
8005
|
+
}
|
|
8006
|
+
function dispatchGatewayPayload(client, payload) {
|
|
8007
|
+
const queue = queueFor(client);
|
|
8008
|
+
if (client.options.gatewayDeferHandlers === false && queue.pending === 0) {
|
|
8009
|
+
queue.pending++;
|
|
8010
|
+
const run = runGatewayHandler(client, payload).finally(() => {
|
|
8011
|
+
queue.pending--;
|
|
8012
|
+
});
|
|
8013
|
+
queue.tail = run.catch(() => {
|
|
8014
|
+
});
|
|
8015
|
+
return run;
|
|
8016
|
+
}
|
|
8017
|
+
queue.pending++;
|
|
8018
|
+
const next = queue.tail.then(
|
|
8019
|
+
() => runGatewayHandler(client, payload),
|
|
8020
|
+
() => runGatewayHandler(client, payload)
|
|
8021
|
+
).finally(() => {
|
|
8022
|
+
queue.pending--;
|
|
8023
|
+
});
|
|
8024
|
+
queue.tail = next.catch(() => {
|
|
7438
8025
|
});
|
|
8026
|
+
return next;
|
|
7439
8027
|
}
|
|
7440
8028
|
async function flushDeferredGatewayDispatches(client, deferred) {
|
|
7441
8029
|
while (deferred.length > 0) {
|
|
@@ -7614,7 +8202,7 @@ async function connectClientGateway(client, token, signal) {
|
|
|
7614
8202
|
|
|
7615
8203
|
// src/ClientCore/GuildManager.ts
|
|
7616
8204
|
var import_collection13 = require("@fluxerjs/collection");
|
|
7617
|
-
var
|
|
8205
|
+
var import_types44 = require("@fluxerjs/types");
|
|
7618
8206
|
var GuildManager = class extends import_collection13.LimitedCollection {
|
|
7619
8207
|
constructor(client) {
|
|
7620
8208
|
super({
|
|
@@ -7623,6 +8211,7 @@ var GuildManager = class extends import_collection13.LimitedCollection {
|
|
|
7623
8211
|
});
|
|
7624
8212
|
this.client = client;
|
|
7625
8213
|
}
|
|
8214
|
+
pendingFetches = /* @__PURE__ */ new Map();
|
|
7626
8215
|
/**
|
|
7627
8216
|
* Remove a guild from cache and cascade its channels / message caches.
|
|
7628
8217
|
* Does not leave the guild. Use {@link ClientUser.leaveGuild} for that.
|
|
@@ -7637,35 +8226,73 @@ var GuildManager = class extends import_collection13.LimitedCollection {
|
|
|
7637
8226
|
}
|
|
7638
8227
|
/**
|
|
7639
8228
|
* Get a guild from cache or fetch from the API if not present.
|
|
8229
|
+
* Partial (metadata-only) cached guilds are hydrated first.
|
|
7640
8230
|
* @param guildId - Snowflake of the guild
|
|
7641
8231
|
* @returns The guild
|
|
7642
8232
|
* @throws FluxerError with GUILD_NOT_FOUND if missing
|
|
7643
8233
|
*/
|
|
7644
8234
|
async resolve(guildId) {
|
|
7645
|
-
|
|
8235
|
+
const id = normalizeSnowflakeId(guildId, "guilds.resolve()");
|
|
8236
|
+
const cached = this.get(id);
|
|
8237
|
+
if (cached && !cached.partial) return cached;
|
|
8238
|
+
if (cached) {
|
|
8239
|
+
await dedupeFetch(this.pendingFetches, id, async () => {
|
|
8240
|
+
await this.hydrate(cached);
|
|
8241
|
+
return cached;
|
|
8242
|
+
});
|
|
8243
|
+
return cached;
|
|
8244
|
+
}
|
|
8245
|
+
const guild = await this.fetch(id);
|
|
8246
|
+
await dedupeFetch(this.pendingFetches, id, async () => {
|
|
8247
|
+
await this.hydrate(guild);
|
|
8248
|
+
return guild;
|
|
8249
|
+
});
|
|
8250
|
+
return guild;
|
|
7646
8251
|
}
|
|
7647
8252
|
/**
|
|
7648
8253
|
* Fetch a guild by ID.
|
|
7649
|
-
* Returns the cached guild unless `force` is set, in which case REST metadata
|
|
8254
|
+
* Returns the cached guild unless `force` is set, in which case REST metadata
|
|
8255
|
+
* is applied via `_patch`. Use {@link resolve} to also hydrate nested caches.
|
|
7650
8256
|
* @throws FluxerError with GUILD_NOT_FOUND if missing
|
|
7651
8257
|
*/
|
|
7652
8258
|
async fetch(guildId, options) {
|
|
7653
|
-
const
|
|
8259
|
+
const id = normalizeSnowflakeId(guildId, "guilds.fetch()");
|
|
8260
|
+
const cached = this.get(id);
|
|
7654
8261
|
if (cached && !options?.force) return cached;
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
8262
|
+
return dedupeFetch(this.pendingFetches, id, async () => {
|
|
8263
|
+
try {
|
|
8264
|
+
const data = assertApiObjectWithId(
|
|
8265
|
+
await this.client.rest.get(import_types44.Routes.guild(id)),
|
|
8266
|
+
"guilds.fetch()"
|
|
8267
|
+
);
|
|
8268
|
+
let guild;
|
|
8269
|
+
const existing = this.get(id);
|
|
8270
|
+
if (existing) {
|
|
8271
|
+
existing._patch(data);
|
|
8272
|
+
guild = existing;
|
|
8273
|
+
} else {
|
|
8274
|
+
guild = new Guild(this.client, data);
|
|
8275
|
+
this.set(guild.id, guild);
|
|
8276
|
+
}
|
|
8277
|
+
return guild;
|
|
8278
|
+
} catch (err) {
|
|
8279
|
+
rethrowMapped(err, {
|
|
8280
|
+
notFound: { code: import_util3.ErrorCodes.GuildNotFound, message: `Guild ${id} not found` },
|
|
8281
|
+
fallback: `Failed to fetch guild ${id}`
|
|
8282
|
+
});
|
|
7660
8283
|
}
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
8284
|
+
});
|
|
8285
|
+
}
|
|
8286
|
+
/** Best-effort nested sync for a metadata-only guild. Failures keep `partial` set. */
|
|
8287
|
+
async hydrate(guild) {
|
|
8288
|
+
try {
|
|
8289
|
+
await Promise.all([guild.fetchChannels(), guild.fetchRoles()]);
|
|
8290
|
+
guild.partial = false;
|
|
7664
8291
|
} catch (err) {
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
8292
|
+
this.client.emit(
|
|
8293
|
+
Events.Debug,
|
|
8294
|
+
`[GuildManager] Could not fully hydrate guild ${guild.id}: ${err instanceof Error ? err.message : String(err)}`
|
|
8295
|
+
);
|
|
7669
8296
|
}
|
|
7670
8297
|
}
|
|
7671
8298
|
};
|
|
@@ -7690,6 +8317,10 @@ var MessageCache = class {
|
|
|
7690
8317
|
if (limit === false) return;
|
|
7691
8318
|
if (!this.caches) this.caches = /* @__PURE__ */ new Map();
|
|
7692
8319
|
let cache = this.caches.get(channelId);
|
|
8320
|
+
if (cache) {
|
|
8321
|
+
this.caches.delete(channelId);
|
|
8322
|
+
this.caches.set(channelId, cache);
|
|
8323
|
+
}
|
|
7693
8324
|
if (!cache) {
|
|
7694
8325
|
const channelLimit = this.getChannelLimit();
|
|
7695
8326
|
if (Number.isFinite(channelLimit) && channelLimit > 0 && this.caches.size >= channelLimit) {
|
|
@@ -7740,13 +8371,14 @@ var MessageCache = class {
|
|
|
7740
8371
|
|
|
7741
8372
|
// src/ClientCore/UserManager.ts
|
|
7742
8373
|
var import_collection14 = require("@fluxerjs/collection");
|
|
7743
|
-
var
|
|
8374
|
+
var import_types45 = require("@fluxerjs/types");
|
|
7744
8375
|
var soft = (p) => p.catch(() => null);
|
|
7745
8376
|
var UserManager = class extends import_collection14.LimitedCollection {
|
|
7746
8377
|
constructor(client) {
|
|
7747
8378
|
super({ maxSize: client.cache.limits.users });
|
|
7748
8379
|
this.client = client;
|
|
7749
8380
|
}
|
|
8381
|
+
pendingFetches = /* @__PURE__ */ new Map();
|
|
7750
8382
|
/** Remove matching users (skips `client.user`). Returns count removed. */
|
|
7751
8383
|
sweep(filter) {
|
|
7752
8384
|
let removed = 0;
|
|
@@ -7760,16 +8392,30 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
7760
8392
|
}
|
|
7761
8393
|
return removed;
|
|
7762
8394
|
}
|
|
7763
|
-
/**
|
|
8395
|
+
/**
|
|
8396
|
+
* Fetch a user by ID and update cache. Returns the cached user unless `force` is set
|
|
8397
|
+
* or the cached entry is only a partial stub (e.g. from a reaction event).
|
|
8398
|
+
*/
|
|
7764
8399
|
async fetch(userId, options) {
|
|
7765
|
-
const
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
return
|
|
8400
|
+
const id = normalizeSnowflakeId(userId, "users.fetch()");
|
|
8401
|
+
const cached = this.get(id);
|
|
8402
|
+
if (cached && !cached.partial && !options?.force) return cached;
|
|
8403
|
+
return dedupeFetch(
|
|
8404
|
+
this.pendingFetches,
|
|
8405
|
+
id,
|
|
8406
|
+
async () => this.client.getOrCreateUser(
|
|
8407
|
+
assertApiObjectWithId(
|
|
8408
|
+
await this.client.rest.get(import_types45.Routes.user(id)),
|
|
8409
|
+
"users.fetch()"
|
|
8410
|
+
)
|
|
8411
|
+
)
|
|
8412
|
+
);
|
|
7769
8413
|
}
|
|
7770
|
-
/** Return a cached user, otherwise {@link fetch}. */
|
|
8414
|
+
/** Return a cached (non-partial) user, otherwise {@link fetch}. */
|
|
7771
8415
|
async resolve(userId) {
|
|
7772
|
-
|
|
8416
|
+
const id = normalizeSnowflakeId(userId, "users.resolve()");
|
|
8417
|
+
const cached = this.get(id);
|
|
8418
|
+
return cached && !cached.partial ? cached : this.fetch(id);
|
|
7773
8419
|
}
|
|
7774
8420
|
/**
|
|
7775
8421
|
* Fetch user + profiles (+ optional guild member). Ideal for userinfo commands.
|
|
@@ -7782,10 +8428,10 @@ var UserManager = class extends import_collection14.LimitedCollection {
|
|
|
7782
8428
|
async fetchWithProfile(userId, options) {
|
|
7783
8429
|
const guildId = options?.guildId ?? void 0;
|
|
7784
8430
|
const [userData, globalProfileRaw, serverProfileRaw, memberData] = await Promise.all([
|
|
7785
|
-
this.client.rest.get(
|
|
7786
|
-
soft(this.client.rest.get(
|
|
7787
|
-
guildId ? soft(this.client.rest.get(
|
|
7788
|
-
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
|
|
7789
8435
|
]);
|
|
7790
8436
|
const user = this.client.getOrCreateUser(userData);
|
|
7791
8437
|
let member = null;
|
|
@@ -7872,7 +8518,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7872
8518
|
cache: resolved.cache,
|
|
7873
8519
|
defaultReplyPing: options.defaultReplyPing ?? true
|
|
7874
8520
|
};
|
|
7875
|
-
this.logger = options.logger ?? (0,
|
|
8521
|
+
this.logger = options.logger ?? (0, import_util27.createLogger)({
|
|
7876
8522
|
level: options.logLevel ?? "warn"
|
|
7877
8523
|
});
|
|
7878
8524
|
this.cache = new CacheController(this, resolved.limits);
|
|
@@ -7910,7 +8556,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7910
8556
|
* Wires REST from `endpoints.api_public`. `endpoints.api` / `api_client` stay on the instance for inspection.
|
|
7911
8557
|
* Does not log in. Call {@link login} with a token afterward.
|
|
7912
8558
|
*
|
|
7913
|
-
* @param origin - Origin used only to fetch discovery (e.g. `https://fluxer.
|
|
8559
|
+
* @param origin - Origin used only to fetch discovery (e.g. `https://fluxer.com` or `https://my.instance`)
|
|
7914
8560
|
* @param options - Client options (must not conflict with discovered `endpoints.api_public`)
|
|
7915
8561
|
* @param connectOptions - Optional abort signal for the discovery request
|
|
7916
8562
|
*/
|
|
@@ -7987,6 +8633,38 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
7987
8633
|
fetchStickerMetadata(stickerId) {
|
|
7988
8634
|
return fetchStickerMetadata(this, stickerId);
|
|
7989
8635
|
}
|
|
8636
|
+
/** Fetch the source guild of a custom emoji. */
|
|
8637
|
+
fetchEmojiSource(emojiId) {
|
|
8638
|
+
return fetchEmojiSource(this, emojiId);
|
|
8639
|
+
}
|
|
8640
|
+
/** Fetch the source guild of a custom sticker. */
|
|
8641
|
+
fetchStickerSource(stickerId) {
|
|
8642
|
+
return fetchStickerSource(this, stickerId);
|
|
8643
|
+
}
|
|
8644
|
+
/** List discovery categories. */
|
|
8645
|
+
fetchDiscoveryCategories() {
|
|
8646
|
+
return fetchDiscoveryCategories(this);
|
|
8647
|
+
}
|
|
8648
|
+
/** Search discoverable guilds. */
|
|
8649
|
+
searchDiscoveryGuilds(options) {
|
|
8650
|
+
return searchDiscoveryGuilds(this, options);
|
|
8651
|
+
}
|
|
8652
|
+
/** Fetch experiment assignments for this account. */
|
|
8653
|
+
fetchExperiments() {
|
|
8654
|
+
return fetchExperiments(this);
|
|
8655
|
+
}
|
|
8656
|
+
/** Refresh expiring attachment CDN URLs. */
|
|
8657
|
+
refreshAttachmentUrls(attachmentUrls) {
|
|
8658
|
+
return refreshAttachmentUrls(this, attachmentUrls);
|
|
8659
|
+
}
|
|
8660
|
+
/** List instance custom guild badges (`GET /instance/badges`). */
|
|
8661
|
+
fetchInstanceBadges(options) {
|
|
8662
|
+
return fetchInstanceBadges(this, options);
|
|
8663
|
+
}
|
|
8664
|
+
/** Fetch forum/media thread post data for a channel. */
|
|
8665
|
+
fetchChannelPostData(channelId, threadIds) {
|
|
8666
|
+
return fetchChannelPostData(this, channelId, threadIds);
|
|
8667
|
+
}
|
|
7990
8668
|
/**
|
|
7991
8669
|
* Fetch the current application (`/applications/@me`).
|
|
7992
8670
|
* @returns Application metadata (owner, flags, RPC origins, etc.)
|
|
@@ -8081,6 +8759,9 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8081
8759
|
* @internal
|
|
8082
8760
|
*/
|
|
8083
8761
|
getOrCreateUser(data) {
|
|
8762
|
+
if (!data || typeof data.id !== "string" || data.id.length === 0) {
|
|
8763
|
+
throw new TypeError("getOrCreateUser() requires user data with a non-empty string id");
|
|
8764
|
+
}
|
|
8084
8765
|
const existing = this.users.get(data.id);
|
|
8085
8766
|
if (existing) {
|
|
8086
8767
|
existing._patch(data);
|
|
@@ -8131,7 +8812,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8131
8812
|
if (options.userIds !== void 0) data.user_ids = [...new Set(options.userIds)];
|
|
8132
8813
|
if (options.presences !== void 0) data.presences = options.presences;
|
|
8133
8814
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8134
|
-
this._sendToAllShards({ op:
|
|
8815
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildMembers, d: data });
|
|
8135
8816
|
}
|
|
8136
8817
|
/**
|
|
8137
8818
|
* Request guild member/online counts via gateway opcode 15.
|
|
@@ -8146,7 +8827,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8146
8827
|
}
|
|
8147
8828
|
const data = { guild_ids: guildIds };
|
|
8148
8829
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8149
|
-
this._sendToAllShards({ op:
|
|
8830
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestGuildCounts, d: data });
|
|
8150
8831
|
}
|
|
8151
8832
|
/**
|
|
8152
8833
|
* Request per-channel member counts via gateway opcode 16.
|
|
@@ -8162,7 +8843,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8162
8843
|
if (options.channelId !== void 0) data.channel_id = options.channelId;
|
|
8163
8844
|
if (options.channelIds !== void 0) data.channel_ids = [...new Set(options.channelIds)];
|
|
8164
8845
|
if (options.nonce !== void 0) data.nonce = options.nonce;
|
|
8165
|
-
this._sendToAllShards({ op:
|
|
8846
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestChannelMemberCounts, d: data });
|
|
8166
8847
|
}
|
|
8167
8848
|
/**
|
|
8168
8849
|
* Request unread counts for posts in one forum or media channel (opcode 28).
|
|
@@ -8198,7 +8879,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8198
8879
|
channel_id: options.channelId,
|
|
8199
8880
|
threads
|
|
8200
8881
|
};
|
|
8201
|
-
this._sendToAllShards({ op:
|
|
8882
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.RequestForumUnreads, d: data });
|
|
8202
8883
|
}
|
|
8203
8884
|
/**
|
|
8204
8885
|
* Subscribe to thread traffic in a guild (opcode 14).
|
|
@@ -8228,7 +8909,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8228
8909
|
subscription.thread_member_lists = threadIds;
|
|
8229
8910
|
}
|
|
8230
8911
|
const data = { subscriptions: { [options.guildId]: subscription } };
|
|
8231
|
-
this._sendToAllShards({ op:
|
|
8912
|
+
this._sendToAllShards({ op: import_types46.GatewayOpcodes.LazyRequest, d: data });
|
|
8232
8913
|
}
|
|
8233
8914
|
/**
|
|
8234
8915
|
* Broadcast a gateway payload to all shards.
|
|
@@ -8333,7 +9014,7 @@ var Client = class _Client extends import_node_events3.EventEmitter {
|
|
|
8333
9014
|
* @see {@link Routes}
|
|
8334
9015
|
*/
|
|
8335
9016
|
static get Routes() {
|
|
8336
|
-
return
|
|
9017
|
+
return import_types46.Routes;
|
|
8337
9018
|
}
|
|
8338
9019
|
};
|
|
8339
9020
|
|
|
@@ -8750,6 +9431,8 @@ var ClientCluster = class extends import_node_events4.EventEmitter {
|
|
|
8750
9431
|
Routes,
|
|
8751
9432
|
STATIC_CDN_URL,
|
|
8752
9433
|
SplashCardAlignment,
|
|
9434
|
+
StageChannel,
|
|
9435
|
+
StageInstance,
|
|
8753
9436
|
SystemChannelFlags,
|
|
8754
9437
|
TextChannel,
|
|
8755
9438
|
ThreadAutoArchiveDuration,
|