@fluxerjs/core 1.1.4 → 1.1.6
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/{Channel-HBKXUNL5.mjs → Channel-L6UE2MAF.mjs} +1 -1
- package/dist/{ClientUser-RXOB6K6C.mjs → ClientUser-5KQNQHUB.mjs} +1 -1
- package/dist/{Guild-3ETPHHF5.mjs → Guild-NNMSFIA6.mjs} +2 -2
- package/dist/GuildEmoji-SOGQ4C32.mjs +8 -0
- package/dist/{GuildMember-43B5E5CH.mjs → GuildMember-F5FZJOHD.mjs} +1 -1
- package/dist/GuildSticker-3QYT6ZIY.mjs +8 -0
- package/dist/{Message-DXBXIQIJ.mjs → Message-QNWAPT55.mjs} +1 -1
- package/dist/{MessageReaction-NIAHV3EM.mjs → MessageReaction-MFK2N3AD.mjs} +1 -1
- package/dist/{Webhook-WIF6OGPA.mjs → Webhook-IWPKKMWD.mjs} +1 -1
- package/dist/{chunk-FSXTONUR.mjs → chunk-2245SAIA.mjs} +1 -1
- package/dist/{chunk-VZPN7FNH.mjs → chunk-4OEOU7G7.mjs} +11 -0
- package/dist/{chunk-DUQAD7F6.mjs → chunk-5JEDVRKU.mjs} +20 -0
- package/dist/chunk-5QRROWJS.mjs +56 -0
- package/dist/{chunk-E6SU3TR5.mjs → chunk-B6F5LWNS.mjs} +1 -1
- package/dist/{chunk-NNZUZLG3.mjs → chunk-EUKEYW72.mjs} +87 -7
- package/dist/{chunk-CREI4MOS.mjs → chunk-FVZY7IZ4.mjs} +190 -21
- package/dist/chunk-KUMLJGXY.mjs +58 -0
- package/dist/{chunk-4S42USSG.mjs → chunk-USHLLE7C.mjs} +2 -2
- package/dist/index.d.mts +246 -54
- package/dist/index.d.ts +246 -54
- package/dist/index.js +510 -188
- package/dist/index.mjs +58 -126
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -411,6 +411,17 @@ var init_Message = __esm({
|
|
|
411
411
|
async delete() {
|
|
412
412
|
await this.client.rest.delete(import_types.Routes.channelMessage(this.channelId, this.id));
|
|
413
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Delete a specific attachment from this message.
|
|
416
|
+
* DELETE /channels/{id}/messages/{id}/attachments/{attachmentId}.
|
|
417
|
+
*/
|
|
418
|
+
async deleteAttachment(attachmentId) {
|
|
419
|
+
await this.client.rest.delete(
|
|
420
|
+
import_types.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
|
|
421
|
+
{ auth: true }
|
|
422
|
+
);
|
|
423
|
+
this.attachments.delete(attachmentId);
|
|
424
|
+
}
|
|
414
425
|
/** Pin this message to the channel. Requires Manage Messages permission. */
|
|
415
426
|
async pin() {
|
|
416
427
|
await this.client.rest.put(import_types.Routes.channelPinMessage(this.channelId, this.id));
|
|
@@ -1020,6 +1031,66 @@ var init_Channel = __esm({
|
|
|
1020
1031
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1021
1032
|
return list.map((i) => new Invite2(this.client, i));
|
|
1022
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Set or update a permission overwrite. PUT /channels/{id}/permissions/{overwriteId}.
|
|
1036
|
+
* @param overwriteId - Role or member ID
|
|
1037
|
+
* @param options - type (0=role, 1=member), allow, deny (permission bitfields)
|
|
1038
|
+
*/
|
|
1039
|
+
async editPermission(overwriteId, options) {
|
|
1040
|
+
await this.client.rest.put(import_types5.Routes.channelPermission(this.id, overwriteId), {
|
|
1041
|
+
body: options,
|
|
1042
|
+
auth: true
|
|
1043
|
+
});
|
|
1044
|
+
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1045
|
+
const entry = {
|
|
1046
|
+
id: overwriteId,
|
|
1047
|
+
type: options.type,
|
|
1048
|
+
allow: options.allow ?? "0",
|
|
1049
|
+
deny: options.deny ?? "0"
|
|
1050
|
+
};
|
|
1051
|
+
if (idx >= 0) this.permissionOverwrites[idx] = entry;
|
|
1052
|
+
else this.permissionOverwrites.push(entry);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
|
|
1056
|
+
*/
|
|
1057
|
+
async deletePermission(overwriteId) {
|
|
1058
|
+
await this.client.rest.delete(import_types5.Routes.channelPermission(this.id, overwriteId), { auth: true });
|
|
1059
|
+
const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
|
|
1060
|
+
if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Edit this channel. PATCH /channels/{id}.
|
|
1064
|
+
* Requires Manage Channel permission.
|
|
1065
|
+
*/
|
|
1066
|
+
async edit(options) {
|
|
1067
|
+
const data = await this.client.rest.patch(import_types5.Routes.channel(this.id), {
|
|
1068
|
+
body: options,
|
|
1069
|
+
auth: true
|
|
1070
|
+
});
|
|
1071
|
+
this.name = data.name ?? this.name;
|
|
1072
|
+
this.parentId = data.parent_id ?? this.parentId;
|
|
1073
|
+
this.permissionOverwrites = data.permission_overwrites ?? this.permissionOverwrites;
|
|
1074
|
+
const self = this;
|
|
1075
|
+
if ("topic" in self && "topic" in data) self.topic = data.topic ?? null;
|
|
1076
|
+
if ("nsfw" in self && "nsfw" in data) self.nsfw = data.nsfw ?? false;
|
|
1077
|
+
if ("rate_limit_per_user" in data) self.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
|
1078
|
+
if ("bitrate" in self && "bitrate" in data) self.bitrate = data.bitrate ?? null;
|
|
1079
|
+
if ("user_limit" in data) self.userLimit = data.user_limit ?? null;
|
|
1080
|
+
if ("rtc_region" in data) self.rtcRegion = data.rtc_region ?? null;
|
|
1081
|
+
return this;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Delete this channel. Requires Manage Channel permission.
|
|
1085
|
+
* @param options - silent: if true, does not send a system message (default false)
|
|
1086
|
+
*/
|
|
1087
|
+
async delete(options) {
|
|
1088
|
+
const url = import_types5.Routes.channel(this.id) + (options?.silent ? "?silent=true" : "");
|
|
1089
|
+
await this.client.rest.delete(url, { auth: true });
|
|
1090
|
+
this.client.channels.delete(this.id);
|
|
1091
|
+
const guild = this.client.guilds.get(this.guildId);
|
|
1092
|
+
if (guild) guild.channels.delete(this.id);
|
|
1093
|
+
}
|
|
1023
1094
|
};
|
|
1024
1095
|
TextChannel = class extends GuildChannel {
|
|
1025
1096
|
topic;
|
|
@@ -1176,49 +1247,25 @@ var init_Channel = __esm({
|
|
|
1176
1247
|
);
|
|
1177
1248
|
return this.client.channels.fetchMessage(this.id, messageId);
|
|
1178
1249
|
}
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
// src/client/GuildMemberManager.ts
|
|
1184
|
-
var import_collection5, GuildMemberManager;
|
|
1185
|
-
var init_GuildMemberManager = __esm({
|
|
1186
|
-
"src/client/GuildMemberManager.ts"() {
|
|
1187
|
-
"use strict";
|
|
1188
|
-
import_collection5 = require("@fluxerjs/collection");
|
|
1189
|
-
GuildMemberManager = class extends import_collection5.Collection {
|
|
1190
|
-
constructor(guild) {
|
|
1191
|
-
super();
|
|
1192
|
-
this.guild = guild;
|
|
1193
|
-
}
|
|
1194
1250
|
/**
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
* Use fetchMe() to load the bot's member when not cached.
|
|
1198
|
-
*
|
|
1199
|
-
* @example
|
|
1200
|
-
* const perms = guild.members.me?.permissions;
|
|
1201
|
-
* if (perms?.has(PermissionFlags.BanMembers)) { ... }
|
|
1251
|
+
* Add a recipient to this Group DM. Requires Group DM (type GroupDM).
|
|
1252
|
+
* PUT /channels/{id}/recipients/{userId}.
|
|
1202
1253
|
*/
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1254
|
+
async addRecipient(userId) {
|
|
1255
|
+
await this.client.rest.put(import_types5.Routes.channelRecipient(this.id, userId), { auth: true });
|
|
1256
|
+
const user = this.client.users.get(userId) ?? await this.client.users.fetch(userId);
|
|
1257
|
+
if (user) this.recipients.push(user);
|
|
1206
1258
|
}
|
|
1207
1259
|
/**
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
* @throws Error if client.user is null (client not ready)
|
|
1212
|
-
* @example
|
|
1213
|
-
* const me = await guild.members.fetchMe();
|
|
1214
|
-
* console.log(me.displayName);
|
|
1260
|
+
* Remove a recipient from this Group DM. Requires Group DM (type GroupDM).
|
|
1261
|
+
* DELETE /channels/{id}/recipients/{userId}.
|
|
1262
|
+
* @param options - silent: if true, does not send a system message (default false)
|
|
1215
1263
|
*/
|
|
1216
|
-
async
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
return this.guild.fetchMember(userId);
|
|
1264
|
+
async removeRecipient(userId, options) {
|
|
1265
|
+
const url = import_types5.Routes.channelRecipient(this.id, userId) + (options?.silent ? "?silent=true" : "");
|
|
1266
|
+
await this.client.rest.delete(url, { auth: true });
|
|
1267
|
+
const idx = this.recipients.findIndex((u) => u.id === userId);
|
|
1268
|
+
if (idx >= 0) this.recipients.splice(idx, 1);
|
|
1222
1269
|
}
|
|
1223
1270
|
};
|
|
1224
1271
|
}
|
|
@@ -1339,6 +1386,26 @@ var init_GuildMember = __esm({
|
|
|
1339
1386
|
async removeRole(roleId) {
|
|
1340
1387
|
await this.client.rest.delete(import_types8.Routes.guildMemberRole(this.guild.id, this.id, roleId));
|
|
1341
1388
|
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Edit this guild member. PATCH /guilds/{id}/members/{userId} or /members/@me for the bot.
|
|
1391
|
+
* For @me: nick, avatar, banner, bio, pronouns, accent_color, profile_flags, mute, deaf,
|
|
1392
|
+
* communication_disabled_until, timeout_reason, channel_id, connection_id.
|
|
1393
|
+
* For other members: same plus roles (array of role IDs).
|
|
1394
|
+
*/
|
|
1395
|
+
async edit(options) {
|
|
1396
|
+
const isMe = this.client.user?.id === this.id;
|
|
1397
|
+
const route = isMe ? `/guilds/${this.guild.id}/members/@me` : import_types8.Routes.guildMember(this.guild.id, this.id);
|
|
1398
|
+
const data = await this.client.rest.patch(route, {
|
|
1399
|
+
body: options,
|
|
1400
|
+
auth: true
|
|
1401
|
+
});
|
|
1402
|
+
this.nick = data.nick ?? this.nick;
|
|
1403
|
+
if (data.roles) this.roles = data.roles;
|
|
1404
|
+
if (data.communication_disabled_until != null) {
|
|
1405
|
+
this.communicationDisabledUntil = data.communication_disabled_until ? new Date(data.communication_disabled_until) : null;
|
|
1406
|
+
}
|
|
1407
|
+
return this;
|
|
1408
|
+
}
|
|
1342
1409
|
/**
|
|
1343
1410
|
* Get the member's guild-level permissions (from roles only, no channel overwrites).
|
|
1344
1411
|
* Use this for server-wide permission checks (e.g. ban, kick, manage roles).
|
|
@@ -1403,17 +1470,84 @@ var init_GuildMember = __esm({
|
|
|
1403
1470
|
}
|
|
1404
1471
|
});
|
|
1405
1472
|
|
|
1473
|
+
// src/client/GuildMemberManager.ts
|
|
1474
|
+
var import_collection5, import_types9, GuildMemberManager;
|
|
1475
|
+
var init_GuildMemberManager = __esm({
|
|
1476
|
+
"src/client/GuildMemberManager.ts"() {
|
|
1477
|
+
"use strict";
|
|
1478
|
+
import_collection5 = require("@fluxerjs/collection");
|
|
1479
|
+
import_types9 = require("@fluxerjs/types");
|
|
1480
|
+
GuildMemberManager = class extends import_collection5.Collection {
|
|
1481
|
+
constructor(guild) {
|
|
1482
|
+
super();
|
|
1483
|
+
this.guild = guild;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* The current bot user as a GuildMember in this guild.
|
|
1487
|
+
* Returns null if the bot's member is not cached or client.user is null.
|
|
1488
|
+
* Use fetchMe() to load the bot's member when not cached.
|
|
1489
|
+
*
|
|
1490
|
+
* @example
|
|
1491
|
+
* const perms = guild.members.me?.permissions;
|
|
1492
|
+
* if (perms?.has(PermissionFlags.BanMembers)) { ... }
|
|
1493
|
+
*/
|
|
1494
|
+
get me() {
|
|
1495
|
+
const userId = this.guild.client.user?.id;
|
|
1496
|
+
return userId ? this.get(userId) ?? null : null;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Fetch the current bot user as a GuildMember in this guild.
|
|
1500
|
+
* Caches the result in guild.members.
|
|
1501
|
+
*
|
|
1502
|
+
* @throws Error if client.user is null (client not ready)
|
|
1503
|
+
* @example
|
|
1504
|
+
* const me = await guild.members.fetchMe();
|
|
1505
|
+
* console.log(me.displayName);
|
|
1506
|
+
*/
|
|
1507
|
+
async fetchMe() {
|
|
1508
|
+
const userId = this.guild.client.user?.id;
|
|
1509
|
+
if (!userId) {
|
|
1510
|
+
throw new Error("Cannot fetch me: client.user is null (client not ready)");
|
|
1511
|
+
}
|
|
1512
|
+
return this.guild.fetchMember(userId);
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Fetch guild members with pagination. GET /guilds/{id}/members.
|
|
1516
|
+
* @param options - limit (1-1000), after (user ID for pagination)
|
|
1517
|
+
* @returns Array of GuildMember objects (cached in guild.members)
|
|
1518
|
+
*/
|
|
1519
|
+
async fetch(options) {
|
|
1520
|
+
const params = new URLSearchParams();
|
|
1521
|
+
if (options?.limit != null) params.set("limit", String(options.limit));
|
|
1522
|
+
if (options?.after) params.set("after", options.after);
|
|
1523
|
+
const qs = params.toString();
|
|
1524
|
+
const url = import_types9.Routes.guildMembers(this.guild.id) + (qs ? `?${qs}` : "");
|
|
1525
|
+
const data = await this.guild.client.rest.get(url, { auth: true });
|
|
1526
|
+
const list = Array.isArray(data) ? data : data?.members ?? [];
|
|
1527
|
+
const { GuildMember: GuildMember2 } = await Promise.resolve().then(() => (init_GuildMember(), GuildMember_exports));
|
|
1528
|
+
const members = [];
|
|
1529
|
+
for (const m of list) {
|
|
1530
|
+
const member = new GuildMember2(this.guild.client, { ...m, guild_id: this.guild.id }, this.guild);
|
|
1531
|
+
this.set(member.id, member);
|
|
1532
|
+
members.push(member);
|
|
1533
|
+
}
|
|
1534
|
+
return members;
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
|
|
1406
1540
|
// src/structures/Role.ts
|
|
1407
1541
|
var Role_exports = {};
|
|
1408
1542
|
__export(Role_exports, {
|
|
1409
1543
|
Role: () => Role
|
|
1410
1544
|
});
|
|
1411
|
-
var
|
|
1545
|
+
var import_types10, import_util5, Role;
|
|
1412
1546
|
var init_Role = __esm({
|
|
1413
1547
|
"src/structures/Role.ts"() {
|
|
1414
1548
|
"use strict";
|
|
1415
1549
|
init_Base();
|
|
1416
|
-
|
|
1550
|
+
import_types10 = require("@fluxerjs/types");
|
|
1417
1551
|
import_util5 = require("@fluxerjs/util");
|
|
1418
1552
|
Role = class extends Base {
|
|
1419
1553
|
client;
|
|
@@ -1498,7 +1632,7 @@ var init_Role = __esm({
|
|
|
1498
1632
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1499
1633
|
if (options.position !== void 0) body.position = options.position;
|
|
1500
1634
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1501
|
-
const data = await this.client.rest.patch(
|
|
1635
|
+
const data = await this.client.rest.patch(import_types10.Routes.guildRole(this.guildId, this.id), {
|
|
1502
1636
|
body: Object.keys(body).length ? body : void 0,
|
|
1503
1637
|
auth: true
|
|
1504
1638
|
});
|
|
@@ -1510,7 +1644,7 @@ var init_Role = __esm({
|
|
|
1510
1644
|
* Requires Manage Roles permission.
|
|
1511
1645
|
*/
|
|
1512
1646
|
async delete() {
|
|
1513
|
-
await this.client.rest.delete(
|
|
1647
|
+
await this.client.rest.delete(import_types10.Routes.guildRole(this.guildId, this.id), { auth: true });
|
|
1514
1648
|
const guild = this.client.guilds.get(this.guildId);
|
|
1515
1649
|
if (guild) guild.roles.delete(this.id);
|
|
1516
1650
|
}
|
|
@@ -1523,12 +1657,12 @@ var GuildBan_exports = {};
|
|
|
1523
1657
|
__export(GuildBan_exports, {
|
|
1524
1658
|
GuildBan: () => GuildBan
|
|
1525
1659
|
});
|
|
1526
|
-
var
|
|
1660
|
+
var import_types11, GuildBan;
|
|
1527
1661
|
var init_GuildBan = __esm({
|
|
1528
1662
|
"src/structures/GuildBan.ts"() {
|
|
1529
1663
|
"use strict";
|
|
1530
1664
|
init_Base();
|
|
1531
|
-
|
|
1665
|
+
import_types11 = require("@fluxerjs/types");
|
|
1532
1666
|
GuildBan = class extends Base {
|
|
1533
1667
|
client;
|
|
1534
1668
|
guildId;
|
|
@@ -1550,7 +1684,7 @@ var init_GuildBan = __esm({
|
|
|
1550
1684
|
* Requires Ban Members permission.
|
|
1551
1685
|
*/
|
|
1552
1686
|
async unban() {
|
|
1553
|
-
await this.client.rest.delete(
|
|
1687
|
+
await this.client.rest.delete(import_types11.Routes.guildBan(this.guildId, this.user.id), {
|
|
1554
1688
|
auth: true
|
|
1555
1689
|
});
|
|
1556
1690
|
}
|
|
@@ -1558,12 +1692,130 @@ var init_GuildBan = __esm({
|
|
|
1558
1692
|
}
|
|
1559
1693
|
});
|
|
1560
1694
|
|
|
1695
|
+
// src/structures/GuildEmoji.ts
|
|
1696
|
+
var GuildEmoji_exports = {};
|
|
1697
|
+
__export(GuildEmoji_exports, {
|
|
1698
|
+
GuildEmoji: () => GuildEmoji
|
|
1699
|
+
});
|
|
1700
|
+
var import_types12, GuildEmoji;
|
|
1701
|
+
var init_GuildEmoji = __esm({
|
|
1702
|
+
"src/structures/GuildEmoji.ts"() {
|
|
1703
|
+
"use strict";
|
|
1704
|
+
init_Base();
|
|
1705
|
+
import_types12 = require("@fluxerjs/types");
|
|
1706
|
+
init_Constants();
|
|
1707
|
+
GuildEmoji = class extends Base {
|
|
1708
|
+
client;
|
|
1709
|
+
id;
|
|
1710
|
+
guildId;
|
|
1711
|
+
name;
|
|
1712
|
+
animated;
|
|
1713
|
+
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
1714
|
+
constructor(client, data, guildId) {
|
|
1715
|
+
super();
|
|
1716
|
+
this.client = client;
|
|
1717
|
+
this.id = data.id;
|
|
1718
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1719
|
+
this.name = data.name;
|
|
1720
|
+
this.animated = data.animated ?? false;
|
|
1721
|
+
}
|
|
1722
|
+
/** CDN URL for this emoji image. */
|
|
1723
|
+
get url() {
|
|
1724
|
+
const ext = this.animated ? "gif" : "png";
|
|
1725
|
+
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
1726
|
+
}
|
|
1727
|
+
/** Emoji identifier for use in reactions: `name:id` */
|
|
1728
|
+
get identifier() {
|
|
1729
|
+
return `${this.name}:${this.id}`;
|
|
1730
|
+
}
|
|
1731
|
+
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
1732
|
+
async delete() {
|
|
1733
|
+
await this.client.rest.delete(import_types12.Routes.guildEmoji(this.guildId, this.id), {
|
|
1734
|
+
auth: true
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Edit this emoji's name.
|
|
1739
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1740
|
+
*/
|
|
1741
|
+
async edit(options) {
|
|
1742
|
+
const data = await this.client.rest.patch(import_types12.Routes.guildEmoji(this.guildId, this.id), {
|
|
1743
|
+
body: options,
|
|
1744
|
+
auth: true
|
|
1745
|
+
});
|
|
1746
|
+
this.name = data.name;
|
|
1747
|
+
return this;
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1753
|
+
// src/structures/GuildSticker.ts
|
|
1754
|
+
var GuildSticker_exports = {};
|
|
1755
|
+
__export(GuildSticker_exports, {
|
|
1756
|
+
GuildSticker: () => GuildSticker
|
|
1757
|
+
});
|
|
1758
|
+
var import_types13, GuildSticker;
|
|
1759
|
+
var init_GuildSticker = __esm({
|
|
1760
|
+
"src/structures/GuildSticker.ts"() {
|
|
1761
|
+
"use strict";
|
|
1762
|
+
init_Base();
|
|
1763
|
+
import_types13 = require("@fluxerjs/types");
|
|
1764
|
+
init_Constants();
|
|
1765
|
+
GuildSticker = class extends Base {
|
|
1766
|
+
client;
|
|
1767
|
+
id;
|
|
1768
|
+
guildId;
|
|
1769
|
+
name;
|
|
1770
|
+
description;
|
|
1771
|
+
tags;
|
|
1772
|
+
animated;
|
|
1773
|
+
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
1774
|
+
constructor(client, data, guildId) {
|
|
1775
|
+
super();
|
|
1776
|
+
this.client = client;
|
|
1777
|
+
this.id = data.id;
|
|
1778
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1779
|
+
this.name = data.name;
|
|
1780
|
+
this.description = data.description ?? "";
|
|
1781
|
+
this.tags = data.tags ?? [];
|
|
1782
|
+
this.animated = data.animated ?? false;
|
|
1783
|
+
}
|
|
1784
|
+
/** CDN URL for this sticker image. */
|
|
1785
|
+
get url() {
|
|
1786
|
+
const ext = this.animated ? "gif" : "png";
|
|
1787
|
+
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
1788
|
+
}
|
|
1789
|
+
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
1790
|
+
async delete() {
|
|
1791
|
+
await this.client.rest.delete(import_types13.Routes.guildSticker(this.guildId, this.id), {
|
|
1792
|
+
auth: true
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Edit this sticker's name and/or description.
|
|
1797
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1798
|
+
*/
|
|
1799
|
+
async edit(options) {
|
|
1800
|
+
const data = await this.client.rest.patch(import_types13.Routes.guildSticker(this.guildId, this.id), {
|
|
1801
|
+
body: options,
|
|
1802
|
+
auth: true
|
|
1803
|
+
});
|
|
1804
|
+
const s = data;
|
|
1805
|
+
this.name = s.name;
|
|
1806
|
+
this.description = s.description ?? "";
|
|
1807
|
+
return this;
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
});
|
|
1812
|
+
|
|
1561
1813
|
// src/structures/Guild.ts
|
|
1562
1814
|
var Guild_exports = {};
|
|
1563
1815
|
__export(Guild_exports, {
|
|
1564
1816
|
Guild: () => Guild
|
|
1565
1817
|
});
|
|
1566
|
-
var import_util6, import_rest3, import_collection6,
|
|
1818
|
+
var import_util6, import_rest3, import_collection6, import_types14, Guild;
|
|
1567
1819
|
var init_Guild = __esm({
|
|
1568
1820
|
"src/structures/Guild.ts"() {
|
|
1569
1821
|
"use strict";
|
|
@@ -1577,7 +1829,7 @@ var init_Guild = __esm({
|
|
|
1577
1829
|
init_GuildMember();
|
|
1578
1830
|
init_Role();
|
|
1579
1831
|
init_Constants();
|
|
1580
|
-
|
|
1832
|
+
import_types14 = require("@fluxerjs/types");
|
|
1581
1833
|
Guild = class extends Base {
|
|
1582
1834
|
client;
|
|
1583
1835
|
id;
|
|
@@ -1670,7 +1922,7 @@ var init_Guild = __esm({
|
|
|
1670
1922
|
* Requires Manage Roles permission.
|
|
1671
1923
|
*/
|
|
1672
1924
|
async addRoleToMember(userId, roleId) {
|
|
1673
|
-
await this.client.rest.put(
|
|
1925
|
+
await this.client.rest.put(import_types14.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1674
1926
|
}
|
|
1675
1927
|
/**
|
|
1676
1928
|
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
@@ -1679,7 +1931,7 @@ var init_Guild = __esm({
|
|
|
1679
1931
|
* Requires Manage Roles permission.
|
|
1680
1932
|
*/
|
|
1681
1933
|
async removeRoleFromMember(userId, roleId) {
|
|
1682
|
-
await this.client.rest.delete(
|
|
1934
|
+
await this.client.rest.delete(import_types14.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1683
1935
|
}
|
|
1684
1936
|
/**
|
|
1685
1937
|
* Create a role in this guild.
|
|
@@ -1701,7 +1953,7 @@ var init_Guild = __esm({
|
|
|
1701
1953
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1702
1954
|
if (options.position !== void 0) body.position = options.position;
|
|
1703
1955
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1704
|
-
const data = await this.client.rest.post(
|
|
1956
|
+
const data = await this.client.rest.post(import_types14.Routes.guildRoles(this.id), {
|
|
1705
1957
|
body: Object.keys(body).length ? body : void 0,
|
|
1706
1958
|
auth: true
|
|
1707
1959
|
});
|
|
@@ -1715,7 +1967,7 @@ var init_Guild = __esm({
|
|
|
1715
1967
|
*/
|
|
1716
1968
|
async fetchRoles() {
|
|
1717
1969
|
const data = await this.client.rest.get(
|
|
1718
|
-
|
|
1970
|
+
import_types14.Routes.guildRoles(this.id)
|
|
1719
1971
|
);
|
|
1720
1972
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1721
1973
|
const roles = [];
|
|
@@ -1734,7 +1986,7 @@ var init_Guild = __esm({
|
|
|
1734
1986
|
*/
|
|
1735
1987
|
async fetchRole(roleId) {
|
|
1736
1988
|
try {
|
|
1737
|
-
const data = await this.client.rest.get(
|
|
1989
|
+
const data = await this.client.rest.get(import_types14.Routes.guildRole(this.id, roleId));
|
|
1738
1990
|
const role = new Role(this.client, data, this.id);
|
|
1739
1991
|
this.roles.set(role.id, role);
|
|
1740
1992
|
return role;
|
|
@@ -1763,7 +2015,7 @@ var init_Guild = __esm({
|
|
|
1763
2015
|
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
1764
2016
|
);
|
|
1765
2017
|
if (cached) return cached.id;
|
|
1766
|
-
const roles = await this.client.rest.get(
|
|
2018
|
+
const roles = await this.client.rest.get(import_types14.Routes.guildRoles(this.id));
|
|
1767
2019
|
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
1768
2020
|
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
1769
2021
|
if (role) {
|
|
@@ -1786,7 +2038,7 @@ var init_Guild = __esm({
|
|
|
1786
2038
|
body.delete_message_days = options.delete_message_days;
|
|
1787
2039
|
if (options?.ban_duration_seconds != null)
|
|
1788
2040
|
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
1789
|
-
await this.client.rest.put(
|
|
2041
|
+
await this.client.rest.put(import_types14.Routes.guildBan(this.id, userId), {
|
|
1790
2042
|
body: Object.keys(body).length ? body : void 0,
|
|
1791
2043
|
auth: true
|
|
1792
2044
|
});
|
|
@@ -1797,7 +2049,7 @@ var init_Guild = __esm({
|
|
|
1797
2049
|
*/
|
|
1798
2050
|
async fetchBans() {
|
|
1799
2051
|
const { GuildBan: GuildBan2 } = await Promise.resolve().then(() => (init_GuildBan(), GuildBan_exports));
|
|
1800
|
-
const data = await this.client.rest.get(
|
|
2052
|
+
const data = await this.client.rest.get(import_types14.Routes.guildBans(this.id));
|
|
1801
2053
|
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
1802
2054
|
return list.map((b) => new GuildBan2(this.client, { ...b, guild_id: this.id }, this.id));
|
|
1803
2055
|
}
|
|
@@ -1807,7 +2059,7 @@ var init_Guild = __esm({
|
|
|
1807
2059
|
* Requires Ban Members permission.
|
|
1808
2060
|
*/
|
|
1809
2061
|
async unban(userId) {
|
|
1810
|
-
await this.client.rest.delete(
|
|
2062
|
+
await this.client.rest.delete(import_types14.Routes.guildBan(this.id, userId), { auth: true });
|
|
1811
2063
|
}
|
|
1812
2064
|
/**
|
|
1813
2065
|
* Kick a member from this guild.
|
|
@@ -1815,7 +2067,7 @@ var init_Guild = __esm({
|
|
|
1815
2067
|
* Requires Kick Members permission.
|
|
1816
2068
|
*/
|
|
1817
2069
|
async kick(userId) {
|
|
1818
|
-
await this.client.rest.delete(
|
|
2070
|
+
await this.client.rest.delete(import_types14.Routes.guildMember(this.id, userId), { auth: true });
|
|
1819
2071
|
}
|
|
1820
2072
|
/**
|
|
1821
2073
|
* Fetch a guild member by user ID.
|
|
@@ -1827,7 +2079,7 @@ var init_Guild = __esm({
|
|
|
1827
2079
|
async fetchMember(userId) {
|
|
1828
2080
|
try {
|
|
1829
2081
|
const data = await this.client.rest.get(
|
|
1830
|
-
|
|
2082
|
+
import_types14.Routes.guildMember(this.id, userId)
|
|
1831
2083
|
);
|
|
1832
2084
|
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
1833
2085
|
this.members.set(member.id, member);
|
|
@@ -1855,13 +2107,13 @@ var init_Guild = __esm({
|
|
|
1855
2107
|
if (options?.userId) params.set("user_id", options.userId);
|
|
1856
2108
|
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
1857
2109
|
const qs = params.toString();
|
|
1858
|
-
const url =
|
|
2110
|
+
const url = import_types14.Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
1859
2111
|
return this.client.rest.get(url);
|
|
1860
2112
|
}
|
|
1861
2113
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
1862
2114
|
async fetchWebhooks() {
|
|
1863
2115
|
const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
|
|
1864
|
-
const data = await this.client.rest.get(
|
|
2116
|
+
const data = await this.client.rest.get(import_types14.Routes.guildWebhooks(this.id));
|
|
1865
2117
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1866
2118
|
return list.map((w) => new Webhook2(this.client, w));
|
|
1867
2119
|
}
|
|
@@ -1872,7 +2124,7 @@ var init_Guild = __esm({
|
|
|
1872
2124
|
*/
|
|
1873
2125
|
async createChannel(data) {
|
|
1874
2126
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1875
|
-
const created = await this.client.rest.post(
|
|
2127
|
+
const created = await this.client.rest.post(import_types14.Routes.guildChannels(this.id), {
|
|
1876
2128
|
body: data,
|
|
1877
2129
|
auth: true
|
|
1878
2130
|
});
|
|
@@ -1889,7 +2141,7 @@ var init_Guild = __esm({
|
|
|
1889
2141
|
*/
|
|
1890
2142
|
async fetchChannels() {
|
|
1891
2143
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1892
|
-
const data = await this.client.rest.get(
|
|
2144
|
+
const data = await this.client.rest.get(import_types14.Routes.guildChannels(this.id));
|
|
1893
2145
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1894
2146
|
const channels = [];
|
|
1895
2147
|
for (const ch of list) {
|
|
@@ -1902,28 +2154,174 @@ var init_Guild = __esm({
|
|
|
1902
2154
|
}
|
|
1903
2155
|
return channels;
|
|
1904
2156
|
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Edit this guild. PATCH /guilds/{id}.
|
|
2159
|
+
* Requires guild owner or Administrator.
|
|
2160
|
+
*/
|
|
2161
|
+
async edit(options) {
|
|
2162
|
+
const data = await this.client.rest.patch(import_types14.Routes.guild(this.id), {
|
|
2163
|
+
body: options,
|
|
2164
|
+
auth: true
|
|
2165
|
+
});
|
|
2166
|
+
this.name = data.name;
|
|
2167
|
+
this.icon = data.icon ?? this.icon;
|
|
2168
|
+
this.banner = data.banner ?? this.banner;
|
|
2169
|
+
this.splash = data.splash ?? this.splash;
|
|
2170
|
+
this.systemChannelId = data.system_channel_id ?? this.systemChannelId;
|
|
2171
|
+
this.afkChannelId = data.afk_channel_id ?? this.afkChannelId;
|
|
2172
|
+
this.afkTimeout = data.afk_timeout ?? this.afkTimeout;
|
|
2173
|
+
this.verificationLevel = data.verification_level ?? this.verificationLevel;
|
|
2174
|
+
this.mfaLevel = data.mfa_level ?? this.mfaLevel;
|
|
2175
|
+
this.explicitContentFilter = data.explicit_content_filter ?? this.explicitContentFilter;
|
|
2176
|
+
this.defaultMessageNotifications = data.default_message_notifications ?? this.defaultMessageNotifications;
|
|
2177
|
+
this.features = data.features ?? this.features;
|
|
2178
|
+
return this;
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Delete this guild. POST /guilds/{id}/delete.
|
|
2182
|
+
* Must be the guild owner.
|
|
2183
|
+
*/
|
|
2184
|
+
async delete() {
|
|
2185
|
+
await this.client.rest.post(import_types14.Routes.guildDelete(this.id), { auth: true });
|
|
2186
|
+
this.client.guilds.delete(this.id);
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
|
|
2190
|
+
* Requires Manage Guild permission.
|
|
2191
|
+
*/
|
|
2192
|
+
async fetchVanityURL() {
|
|
2193
|
+
return this.client.rest.get(import_types14.Routes.guildVanityUrl(this.id), { auth: true });
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
|
|
2197
|
+
* Must be the guild owner.
|
|
2198
|
+
*/
|
|
2199
|
+
async transferOwnership(newOwnerId, password) {
|
|
2200
|
+
await this.client.rest.post(import_types14.Routes.guildTransferOwnership(this.id), {
|
|
2201
|
+
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2202
|
+
auth: true
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
|
|
2207
|
+
*/
|
|
2208
|
+
setTextChannelFlexibleNames(enabled) {
|
|
2209
|
+
return this.client.rest.patch(import_types14.Routes.guildTextChannelFlexibleNames(this.id), {
|
|
2210
|
+
body: { enabled },
|
|
2211
|
+
auth: true
|
|
2212
|
+
}).then(() => this);
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Set detached banner feature. PATCH /guilds/{id}/detached-banner.
|
|
2216
|
+
*/
|
|
2217
|
+
setDetachedBanner(enabled) {
|
|
2218
|
+
return this.client.rest.patch(import_types14.Routes.guildDetachedBanner(this.id), {
|
|
2219
|
+
body: { enabled },
|
|
2220
|
+
auth: true
|
|
2221
|
+
}).then(() => this);
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2224
|
+
* Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
|
|
2225
|
+
*/
|
|
2226
|
+
setDisallowUnclaimedAccounts(enabled) {
|
|
2227
|
+
return this.client.rest.patch(import_types14.Routes.guildDisallowUnclaimedAccounts(this.id), {
|
|
2228
|
+
body: { enabled },
|
|
2229
|
+
auth: true
|
|
2230
|
+
}).then(() => this);
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Update role positions. PATCH /guilds/{id}/roles.
|
|
2234
|
+
* @param updates - Array of { id, position? }
|
|
2235
|
+
*/
|
|
2236
|
+
async setRolePositions(updates) {
|
|
2237
|
+
const data = await this.client.rest.patch(
|
|
2238
|
+
import_types14.Routes.guildRoles(this.id),
|
|
2239
|
+
{ body: updates, auth: true }
|
|
2240
|
+
);
|
|
2241
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2242
|
+
for (const r of list) {
|
|
2243
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2244
|
+
}
|
|
2245
|
+
return list;
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
|
|
2249
|
+
*/
|
|
2250
|
+
async setRoleHoistPositions(updates) {
|
|
2251
|
+
const data = await this.client.rest.patch(
|
|
2252
|
+
import_types14.Routes.guildRolesHoistPositions(this.id),
|
|
2253
|
+
{ body: updates, auth: true }
|
|
2254
|
+
);
|
|
2255
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2256
|
+
for (const r of list) {
|
|
2257
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2258
|
+
}
|
|
2259
|
+
return list;
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
|
|
2263
|
+
*/
|
|
2264
|
+
async resetRoleHoistPositions() {
|
|
2265
|
+
const data = await this.client.rest.delete(
|
|
2266
|
+
import_types14.Routes.guildRolesHoistPositions(this.id),
|
|
2267
|
+
{ auth: true }
|
|
2268
|
+
);
|
|
2269
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2270
|
+
for (const r of list) {
|
|
2271
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2272
|
+
}
|
|
2273
|
+
return list;
|
|
2274
|
+
}
|
|
1905
2275
|
/**
|
|
1906
2276
|
* Update channel positions.
|
|
1907
2277
|
* @param updates - Array of { id, position?, parent_id?, lock_permissions? }
|
|
1908
2278
|
* Requires Manage Channels permission.
|
|
1909
2279
|
*/
|
|
1910
2280
|
async setChannelPositions(updates) {
|
|
1911
|
-
await this.client.rest.patch(
|
|
2281
|
+
await this.client.rest.patch(import_types14.Routes.guildChannels(this.id), {
|
|
1912
2282
|
body: updates,
|
|
1913
2283
|
auth: true
|
|
1914
2284
|
});
|
|
1915
2285
|
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Bulk create emojis. POST /guilds/{id}/emojis/bulk.
|
|
2288
|
+
* @param emojis - Array of { name, image } (base64), 1-50 emojis
|
|
2289
|
+
* @returns Array of created GuildEmoji objects
|
|
2290
|
+
*/
|
|
2291
|
+
async createEmojisBulk(emojis) {
|
|
2292
|
+
const { GuildEmoji: GuildEmoji2 } = await Promise.resolve().then(() => (init_GuildEmoji(), GuildEmoji_exports));
|
|
2293
|
+
const data = await this.client.rest.post(import_types14.Routes.guildEmojisBulk(this.id), {
|
|
2294
|
+
body: { emojis },
|
|
2295
|
+
auth: true
|
|
2296
|
+
});
|
|
2297
|
+
const list = Array.isArray(data) ? data : data?.emojis ?? [];
|
|
2298
|
+
return list.map((e) => new GuildEmoji2(this.client, { ...e, guild_id: this.id }, this.id));
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Bulk create stickers. POST /guilds/{id}/stickers/bulk.
|
|
2302
|
+
* @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
|
|
2303
|
+
* @returns Array of created GuildSticker objects
|
|
2304
|
+
*/
|
|
2305
|
+
async createStickersBulk(stickers) {
|
|
2306
|
+
const { GuildSticker: GuildSticker2 } = await Promise.resolve().then(() => (init_GuildSticker(), GuildSticker_exports));
|
|
2307
|
+
const data = await this.client.rest.post(import_types14.Routes.guildStickersBulk(this.id), {
|
|
2308
|
+
body: { stickers },
|
|
2309
|
+
auth: true
|
|
2310
|
+
});
|
|
2311
|
+
const list = Array.isArray(data) ? data : data?.stickers ?? [];
|
|
2312
|
+
return list.map((s) => new GuildSticker2(this.client, { ...s, guild_id: this.id }, this.id));
|
|
2313
|
+
}
|
|
1916
2314
|
};
|
|
1917
2315
|
}
|
|
1918
2316
|
});
|
|
1919
2317
|
|
|
1920
2318
|
// src/structures/User.ts
|
|
1921
|
-
var
|
|
2319
|
+
var import_types16, User;
|
|
1922
2320
|
var init_User = __esm({
|
|
1923
2321
|
"src/structures/User.ts"() {
|
|
1924
2322
|
"use strict";
|
|
1925
2323
|
init_Base();
|
|
1926
|
-
|
|
2324
|
+
import_types16 = require("@fluxerjs/types");
|
|
1927
2325
|
init_Constants();
|
|
1928
2326
|
User = class extends Base {
|
|
1929
2327
|
client;
|
|
@@ -2001,7 +2399,7 @@ var init_User = __esm({
|
|
|
2001
2399
|
*/
|
|
2002
2400
|
async createDM() {
|
|
2003
2401
|
const { DMChannel: DMChannelClass } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
2004
|
-
const data = await this.client.rest.post(
|
|
2402
|
+
const data = await this.client.rest.post(import_types16.Routes.userMeChannels(), {
|
|
2005
2403
|
body: { recipient_id: this.id },
|
|
2006
2404
|
auth: true
|
|
2007
2405
|
});
|
|
@@ -2024,11 +2422,11 @@ var MessageReaction_exports = {};
|
|
|
2024
2422
|
__export(MessageReaction_exports, {
|
|
2025
2423
|
MessageReaction: () => MessageReaction
|
|
2026
2424
|
});
|
|
2027
|
-
var
|
|
2425
|
+
var import_types18, import_rest4, MessageReaction;
|
|
2028
2426
|
var init_MessageReaction = __esm({
|
|
2029
2427
|
"src/structures/MessageReaction.ts"() {
|
|
2030
2428
|
"use strict";
|
|
2031
|
-
|
|
2429
|
+
import_types18 = require("@fluxerjs/types");
|
|
2032
2430
|
import_rest4 = require("@fluxerjs/rest");
|
|
2033
2431
|
init_FluxerError();
|
|
2034
2432
|
init_ErrorCodes();
|
|
@@ -2067,7 +2465,7 @@ var init_MessageReaction = __esm({
|
|
|
2067
2465
|
try {
|
|
2068
2466
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
2069
2467
|
const data = await this.client.rest.get(
|
|
2070
|
-
|
|
2468
|
+
import_types18.Routes.channelMessage(this.channelId, this.messageId)
|
|
2071
2469
|
);
|
|
2072
2470
|
return new Message2(this.client, data);
|
|
2073
2471
|
} catch (err) {
|
|
@@ -2090,12 +2488,12 @@ var ClientUser_exports = {};
|
|
|
2090
2488
|
__export(ClientUser_exports, {
|
|
2091
2489
|
ClientUser: () => ClientUser
|
|
2092
2490
|
});
|
|
2093
|
-
var
|
|
2491
|
+
var import_types19, ClientUser;
|
|
2094
2492
|
var init_ClientUser = __esm({
|
|
2095
2493
|
"src/client/ClientUser.ts"() {
|
|
2096
2494
|
"use strict";
|
|
2097
2495
|
init_User();
|
|
2098
|
-
|
|
2496
|
+
import_types19 = require("@fluxerjs/types");
|
|
2099
2497
|
ClientUser = class extends User {
|
|
2100
2498
|
constructor(client, data) {
|
|
2101
2499
|
super(client, { ...data });
|
|
@@ -2106,7 +2504,7 @@ var init_ClientUser = __esm({
|
|
|
2106
2504
|
*/
|
|
2107
2505
|
async fetchGuilds() {
|
|
2108
2506
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2109
|
-
const data = await this.client.rest.get(
|
|
2507
|
+
const data = await this.client.rest.get(import_types19.Routes.currentUserGuilds());
|
|
2110
2508
|
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
2111
2509
|
const guilds = [];
|
|
2112
2510
|
for (const g of list) {
|
|
@@ -2121,7 +2519,7 @@ var init_ClientUser = __esm({
|
|
|
2121
2519
|
* @param guildId - The guild ID to leave
|
|
2122
2520
|
*/
|
|
2123
2521
|
async leaveGuild(guildId) {
|
|
2124
|
-
await this.client.rest.delete(
|
|
2522
|
+
await this.client.rest.delete(import_types19.Routes.leaveGuild(guildId), { auth: true });
|
|
2125
2523
|
this.client.guilds.delete(guildId);
|
|
2126
2524
|
}
|
|
2127
2525
|
};
|
|
@@ -2143,7 +2541,7 @@ __export(index_exports, {
|
|
|
2143
2541
|
ErrorCodes: () => ErrorCodes,
|
|
2144
2542
|
Events: () => Events,
|
|
2145
2543
|
FluxerError: () => FluxerError,
|
|
2146
|
-
GatewayOpcodes: () =>
|
|
2544
|
+
GatewayOpcodes: () => import_types21.GatewayOpcodes,
|
|
2147
2545
|
Guild: () => Guild,
|
|
2148
2546
|
GuildBan: () => GuildBan,
|
|
2149
2547
|
GuildChannel: () => GuildChannel,
|
|
@@ -2154,7 +2552,7 @@ __export(index_exports, {
|
|
|
2154
2552
|
Invite: () => Invite,
|
|
2155
2553
|
LinkChannel: () => LinkChannel,
|
|
2156
2554
|
Message: () => Message,
|
|
2157
|
-
MessageAttachmentFlags: () =>
|
|
2555
|
+
MessageAttachmentFlags: () => import_types21.MessageAttachmentFlags,
|
|
2158
2556
|
MessageCollector: () => MessageCollector,
|
|
2159
2557
|
MessageManager: () => MessageManager,
|
|
2160
2558
|
MessagePayload: () => import_builders3.MessagePayload,
|
|
@@ -2163,7 +2561,7 @@ __export(index_exports, {
|
|
|
2163
2561
|
PermissionsBitField: () => import_util9.PermissionsBitField,
|
|
2164
2562
|
ReactionCollector: () => ReactionCollector,
|
|
2165
2563
|
Role: () => Role,
|
|
2166
|
-
Routes: () =>
|
|
2564
|
+
Routes: () => import_types21.Routes,
|
|
2167
2565
|
TextChannel: () => TextChannel,
|
|
2168
2566
|
User: () => User,
|
|
2169
2567
|
UserFlagsBitField: () => import_util9.UserFlagsBitField,
|
|
@@ -2186,7 +2584,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
2186
2584
|
var import_events3 = require("events");
|
|
2187
2585
|
var import_rest5 = require("@fluxerjs/rest");
|
|
2188
2586
|
var import_ws = require("@fluxerjs/ws");
|
|
2189
|
-
var
|
|
2587
|
+
var import_types20 = require("@fluxerjs/types");
|
|
2190
2588
|
|
|
2191
2589
|
// src/client/ChannelManager.ts
|
|
2192
2590
|
var import_collection4 = require("@fluxerjs/collection");
|
|
@@ -2294,12 +2692,27 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
2294
2692
|
|
|
2295
2693
|
// src/client/GuildManager.ts
|
|
2296
2694
|
var import_collection7 = require("@fluxerjs/collection");
|
|
2297
|
-
var
|
|
2695
|
+
var import_types15 = require("@fluxerjs/types");
|
|
2298
2696
|
var GuildManager = class extends import_collection7.Collection {
|
|
2299
2697
|
constructor(client) {
|
|
2300
2698
|
super();
|
|
2301
2699
|
this.client = client;
|
|
2302
2700
|
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Create a guild. POST /guilds.
|
|
2703
|
+
* @param options - name (required), icon (base64), empty_features
|
|
2704
|
+
* @returns The created guild
|
|
2705
|
+
*/
|
|
2706
|
+
async create(options) {
|
|
2707
|
+
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2708
|
+
const data = await this.client.rest.post(
|
|
2709
|
+
import_types15.Routes.guilds(),
|
|
2710
|
+
{ body: options, auth: true }
|
|
2711
|
+
);
|
|
2712
|
+
const guild = new Guild2(this.client, data);
|
|
2713
|
+
this.set(guild.id, guild);
|
|
2714
|
+
return guild;
|
|
2715
|
+
}
|
|
2303
2716
|
/**
|
|
2304
2717
|
* Fetch a guild by ID from the API (or return from cache if present).
|
|
2305
2718
|
* @param guildId - Snowflake of the guild
|
|
@@ -2314,7 +2727,7 @@ var GuildManager = class extends import_collection7.Collection {
|
|
|
2314
2727
|
try {
|
|
2315
2728
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2316
2729
|
const data = await this.client.rest.get(
|
|
2317
|
-
|
|
2730
|
+
import_types15.Routes.guild(guildId)
|
|
2318
2731
|
);
|
|
2319
2732
|
const guild = new Guild2(this.client, data);
|
|
2320
2733
|
this.set(guild.id, guild);
|
|
@@ -2334,7 +2747,7 @@ init_User();
|
|
|
2334
2747
|
|
|
2335
2748
|
// src/client/UsersManager.ts
|
|
2336
2749
|
var import_collection8 = require("@fluxerjs/collection");
|
|
2337
|
-
var
|
|
2750
|
+
var import_types17 = require("@fluxerjs/types");
|
|
2338
2751
|
init_GuildMember();
|
|
2339
2752
|
var UsersManager = class extends import_collection8.Collection {
|
|
2340
2753
|
constructor(client) {
|
|
@@ -2352,7 +2765,7 @@ var UsersManager = class extends import_collection8.Collection {
|
|
|
2352
2765
|
* console.log(user.username);
|
|
2353
2766
|
*/
|
|
2354
2767
|
async fetch(userId) {
|
|
2355
|
-
const data = await this.client.rest.get(
|
|
2768
|
+
const data = await this.client.rest.get(import_types17.Routes.user(userId));
|
|
2356
2769
|
return this.client.getOrCreateUser(data);
|
|
2357
2770
|
}
|
|
2358
2771
|
/**
|
|
@@ -2372,10 +2785,10 @@ var UsersManager = class extends import_collection8.Collection {
|
|
|
2372
2785
|
async fetchWithProfile(userId, options) {
|
|
2373
2786
|
const guildId = options?.guildId ?? void 0;
|
|
2374
2787
|
const [userData, globalProfileData, serverProfileData, memberData] = await Promise.all([
|
|
2375
|
-
this.client.rest.get(
|
|
2376
|
-
this.client.rest.get(
|
|
2377
|
-
guildId ? this.client.rest.get(
|
|
2378
|
-
guildId ? this.client.rest.get(
|
|
2788
|
+
this.client.rest.get(import_types17.Routes.user(userId)),
|
|
2789
|
+
this.client.rest.get(import_types17.Routes.userProfile(userId)).catch(() => null),
|
|
2790
|
+
guildId ? this.client.rest.get(import_types17.Routes.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
|
|
2791
|
+
guildId ? this.client.rest.get(import_types17.Routes.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
|
|
2379
2792
|
]);
|
|
2380
2793
|
const user = this.client.getOrCreateUser(userData);
|
|
2381
2794
|
const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
|
|
@@ -2745,7 +3158,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2745
3158
|
if (parsed.id) return (0, import_util7.formatEmoji)(parsed);
|
|
2746
3159
|
if (!/^\w+$/.test(parsed.name)) return encodeURIComponent(parsed.name);
|
|
2747
3160
|
if (guildId) {
|
|
2748
|
-
const emojis = await this.rest.get(
|
|
3161
|
+
const emojis = await this.rest.get(import_types20.Routes.guildEmojis(guildId));
|
|
2749
3162
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
2750
3163
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
2751
3164
|
if (found) return (0, import_util7.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -2760,6 +3173,13 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2760
3173
|
}
|
|
2761
3174
|
return encodeURIComponent(parsed.name);
|
|
2762
3175
|
}
|
|
3176
|
+
/**
|
|
3177
|
+
* Fetch instance info (API URL, gateway URL, features). GET /instance.
|
|
3178
|
+
* Does not require authentication.
|
|
3179
|
+
*/
|
|
3180
|
+
async fetchInstance() {
|
|
3181
|
+
return this.rest.get(import_types20.Routes.instance(), { auth: false });
|
|
3182
|
+
}
|
|
2763
3183
|
/**
|
|
2764
3184
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
2765
3185
|
* @param channelId - Snowflake of the channel
|
|
@@ -2912,7 +3332,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2912
3332
|
return this.readyAt !== null && this.user !== null;
|
|
2913
3333
|
}
|
|
2914
3334
|
static get Routes() {
|
|
2915
|
-
return
|
|
3335
|
+
return import_types20.Routes;
|
|
2916
3336
|
}
|
|
2917
3337
|
};
|
|
2918
3338
|
|
|
@@ -2931,113 +3351,15 @@ init_GuildMember();
|
|
|
2931
3351
|
init_Role();
|
|
2932
3352
|
init_Invite();
|
|
2933
3353
|
init_GuildBan();
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
init_Base();
|
|
2937
|
-
var import_types18 = require("@fluxerjs/types");
|
|
2938
|
-
init_Constants();
|
|
2939
|
-
var GuildEmoji = class extends Base {
|
|
2940
|
-
client;
|
|
2941
|
-
id;
|
|
2942
|
-
guildId;
|
|
2943
|
-
name;
|
|
2944
|
-
animated;
|
|
2945
|
-
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
2946
|
-
constructor(client, data, guildId) {
|
|
2947
|
-
super();
|
|
2948
|
-
this.client = client;
|
|
2949
|
-
this.id = data.id;
|
|
2950
|
-
this.guildId = data.guild_id ?? guildId;
|
|
2951
|
-
this.name = data.name;
|
|
2952
|
-
this.animated = data.animated ?? false;
|
|
2953
|
-
}
|
|
2954
|
-
/** CDN URL for this emoji image. */
|
|
2955
|
-
get url() {
|
|
2956
|
-
const ext = this.animated ? "gif" : "png";
|
|
2957
|
-
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
2958
|
-
}
|
|
2959
|
-
/** Emoji identifier for use in reactions: `name:id` */
|
|
2960
|
-
get identifier() {
|
|
2961
|
-
return `${this.name}:${this.id}`;
|
|
2962
|
-
}
|
|
2963
|
-
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
2964
|
-
async delete() {
|
|
2965
|
-
await this.client.rest.delete(import_types18.Routes.guildEmoji(this.guildId, this.id), {
|
|
2966
|
-
auth: true
|
|
2967
|
-
});
|
|
2968
|
-
}
|
|
2969
|
-
/**
|
|
2970
|
-
* Edit this emoji's name.
|
|
2971
|
-
* Requires Manage Emojis and Stickers permission.
|
|
2972
|
-
*/
|
|
2973
|
-
async edit(options) {
|
|
2974
|
-
const data = await this.client.rest.patch(import_types18.Routes.guildEmoji(this.guildId, this.id), {
|
|
2975
|
-
body: options,
|
|
2976
|
-
auth: true
|
|
2977
|
-
});
|
|
2978
|
-
this.name = data.name;
|
|
2979
|
-
return this;
|
|
2980
|
-
}
|
|
2981
|
-
};
|
|
2982
|
-
|
|
2983
|
-
// src/structures/GuildSticker.ts
|
|
2984
|
-
init_Base();
|
|
2985
|
-
var import_types19 = require("@fluxerjs/types");
|
|
2986
|
-
init_Constants();
|
|
2987
|
-
var GuildSticker = class extends Base {
|
|
2988
|
-
client;
|
|
2989
|
-
id;
|
|
2990
|
-
guildId;
|
|
2991
|
-
name;
|
|
2992
|
-
description;
|
|
2993
|
-
tags;
|
|
2994
|
-
animated;
|
|
2995
|
-
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
2996
|
-
constructor(client, data, guildId) {
|
|
2997
|
-
super();
|
|
2998
|
-
this.client = client;
|
|
2999
|
-
this.id = data.id;
|
|
3000
|
-
this.guildId = data.guild_id ?? guildId;
|
|
3001
|
-
this.name = data.name;
|
|
3002
|
-
this.description = data.description ?? "";
|
|
3003
|
-
this.tags = data.tags ?? [];
|
|
3004
|
-
this.animated = data.animated ?? false;
|
|
3005
|
-
}
|
|
3006
|
-
/** CDN URL for this sticker image. */
|
|
3007
|
-
get url() {
|
|
3008
|
-
const ext = this.animated ? "gif" : "png";
|
|
3009
|
-
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
3010
|
-
}
|
|
3011
|
-
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
3012
|
-
async delete() {
|
|
3013
|
-
await this.client.rest.delete(import_types19.Routes.guildSticker(this.guildId, this.id), {
|
|
3014
|
-
auth: true
|
|
3015
|
-
});
|
|
3016
|
-
}
|
|
3017
|
-
/**
|
|
3018
|
-
* Edit this sticker's name and/or description.
|
|
3019
|
-
* Requires Manage Emojis and Stickers permission.
|
|
3020
|
-
*/
|
|
3021
|
-
async edit(options) {
|
|
3022
|
-
const data = await this.client.rest.patch(import_types19.Routes.guildSticker(this.guildId, this.id), {
|
|
3023
|
-
body: options,
|
|
3024
|
-
auth: true
|
|
3025
|
-
});
|
|
3026
|
-
const s = data;
|
|
3027
|
-
this.name = s.name;
|
|
3028
|
-
this.description = s.description ?? "";
|
|
3029
|
-
return this;
|
|
3030
|
-
}
|
|
3031
|
-
};
|
|
3032
|
-
|
|
3033
|
-
// src/index.ts
|
|
3354
|
+
init_GuildEmoji();
|
|
3355
|
+
init_GuildSticker();
|
|
3034
3356
|
init_Events();
|
|
3035
3357
|
init_MessageCollector();
|
|
3036
3358
|
init_ReactionCollector();
|
|
3037
3359
|
init_FluxerError();
|
|
3038
3360
|
init_ErrorCodes();
|
|
3039
3361
|
var import_builders3 = require("@fluxerjs/builders");
|
|
3040
|
-
var
|
|
3362
|
+
var import_types21 = require("@fluxerjs/types");
|
|
3041
3363
|
var import_util8 = require("@fluxerjs/util");
|
|
3042
3364
|
var import_util9 = require("@fluxerjs/util");
|
|
3043
3365
|
init_cdn();
|