@fluxerjs/core 1.1.5 → 1.1.7
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-JCRVGIJL.mjs} +1 -1
- package/dist/{Guild-3ETPHHF5.mjs → Guild-RXGLAN54.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-CREI4MOS.mjs → chunk-BRIU4HGS.mjs} +194 -21
- package/dist/{chunk-NNZUZLG3.mjs → chunk-EUKEYW72.mjs} +87 -7
- package/dist/chunk-KUMLJGXY.mjs +58 -0
- package/dist/{chunk-4S42USSG.mjs → chunk-S25KNTHZ.mjs} +2 -2
- package/dist/index.d.mts +246 -54
- package/dist/index.d.ts +246 -54
- package/dist/index.js +534 -194
- package/dist/index.mjs +78 -132
- 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,88 @@ 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(
|
|
1531
|
+
this.guild.client,
|
|
1532
|
+
{ ...m, guild_id: this.guild.id },
|
|
1533
|
+
this.guild
|
|
1534
|
+
);
|
|
1535
|
+
this.set(member.id, member);
|
|
1536
|
+
members.push(member);
|
|
1537
|
+
}
|
|
1538
|
+
return members;
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
|
|
1406
1544
|
// src/structures/Role.ts
|
|
1407
1545
|
var Role_exports = {};
|
|
1408
1546
|
__export(Role_exports, {
|
|
1409
1547
|
Role: () => Role
|
|
1410
1548
|
});
|
|
1411
|
-
var
|
|
1549
|
+
var import_types10, import_util5, Role;
|
|
1412
1550
|
var init_Role = __esm({
|
|
1413
1551
|
"src/structures/Role.ts"() {
|
|
1414
1552
|
"use strict";
|
|
1415
1553
|
init_Base();
|
|
1416
|
-
|
|
1554
|
+
import_types10 = require("@fluxerjs/types");
|
|
1417
1555
|
import_util5 = require("@fluxerjs/util");
|
|
1418
1556
|
Role = class extends Base {
|
|
1419
1557
|
client;
|
|
@@ -1498,7 +1636,7 @@ var init_Role = __esm({
|
|
|
1498
1636
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1499
1637
|
if (options.position !== void 0) body.position = options.position;
|
|
1500
1638
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1501
|
-
const data = await this.client.rest.patch(
|
|
1639
|
+
const data = await this.client.rest.patch(import_types10.Routes.guildRole(this.guildId, this.id), {
|
|
1502
1640
|
body: Object.keys(body).length ? body : void 0,
|
|
1503
1641
|
auth: true
|
|
1504
1642
|
});
|
|
@@ -1510,7 +1648,7 @@ var init_Role = __esm({
|
|
|
1510
1648
|
* Requires Manage Roles permission.
|
|
1511
1649
|
*/
|
|
1512
1650
|
async delete() {
|
|
1513
|
-
await this.client.rest.delete(
|
|
1651
|
+
await this.client.rest.delete(import_types10.Routes.guildRole(this.guildId, this.id), { auth: true });
|
|
1514
1652
|
const guild = this.client.guilds.get(this.guildId);
|
|
1515
1653
|
if (guild) guild.roles.delete(this.id);
|
|
1516
1654
|
}
|
|
@@ -1523,12 +1661,12 @@ var GuildBan_exports = {};
|
|
|
1523
1661
|
__export(GuildBan_exports, {
|
|
1524
1662
|
GuildBan: () => GuildBan
|
|
1525
1663
|
});
|
|
1526
|
-
var
|
|
1664
|
+
var import_types11, GuildBan;
|
|
1527
1665
|
var init_GuildBan = __esm({
|
|
1528
1666
|
"src/structures/GuildBan.ts"() {
|
|
1529
1667
|
"use strict";
|
|
1530
1668
|
init_Base();
|
|
1531
|
-
|
|
1669
|
+
import_types11 = require("@fluxerjs/types");
|
|
1532
1670
|
GuildBan = class extends Base {
|
|
1533
1671
|
client;
|
|
1534
1672
|
guildId;
|
|
@@ -1550,9 +1688,127 @@ var init_GuildBan = __esm({
|
|
|
1550
1688
|
* Requires Ban Members permission.
|
|
1551
1689
|
*/
|
|
1552
1690
|
async unban() {
|
|
1553
|
-
await this.client.rest.delete(
|
|
1691
|
+
await this.client.rest.delete(import_types11.Routes.guildBan(this.guildId, this.user.id), {
|
|
1692
|
+
auth: true
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
// src/structures/GuildEmoji.ts
|
|
1700
|
+
var GuildEmoji_exports = {};
|
|
1701
|
+
__export(GuildEmoji_exports, {
|
|
1702
|
+
GuildEmoji: () => GuildEmoji
|
|
1703
|
+
});
|
|
1704
|
+
var import_types12, GuildEmoji;
|
|
1705
|
+
var init_GuildEmoji = __esm({
|
|
1706
|
+
"src/structures/GuildEmoji.ts"() {
|
|
1707
|
+
"use strict";
|
|
1708
|
+
init_Base();
|
|
1709
|
+
import_types12 = require("@fluxerjs/types");
|
|
1710
|
+
init_Constants();
|
|
1711
|
+
GuildEmoji = class extends Base {
|
|
1712
|
+
client;
|
|
1713
|
+
id;
|
|
1714
|
+
guildId;
|
|
1715
|
+
name;
|
|
1716
|
+
animated;
|
|
1717
|
+
/** @param data - API emoji from GET /guilds/{id}/emojis or guild emoji events */
|
|
1718
|
+
constructor(client, data, guildId) {
|
|
1719
|
+
super();
|
|
1720
|
+
this.client = client;
|
|
1721
|
+
this.id = data.id;
|
|
1722
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1723
|
+
this.name = data.name;
|
|
1724
|
+
this.animated = data.animated ?? false;
|
|
1725
|
+
}
|
|
1726
|
+
/** CDN URL for this emoji image. */
|
|
1727
|
+
get url() {
|
|
1728
|
+
const ext = this.animated ? "gif" : "png";
|
|
1729
|
+
return `${CDN_URL}/emojis/${this.id}.${ext}`;
|
|
1730
|
+
}
|
|
1731
|
+
/** Emoji identifier for use in reactions: `name:id` */
|
|
1732
|
+
get identifier() {
|
|
1733
|
+
return `${this.name}:${this.id}`;
|
|
1734
|
+
}
|
|
1735
|
+
/** Delete this emoji. Requires Manage Emojis and Stickers permission. */
|
|
1736
|
+
async delete() {
|
|
1737
|
+
await this.client.rest.delete(import_types12.Routes.guildEmoji(this.guildId, this.id), {
|
|
1738
|
+
auth: true
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
/**
|
|
1742
|
+
* Edit this emoji's name.
|
|
1743
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1744
|
+
*/
|
|
1745
|
+
async edit(options) {
|
|
1746
|
+
const data = await this.client.rest.patch(import_types12.Routes.guildEmoji(this.guildId, this.id), {
|
|
1747
|
+
body: options,
|
|
1748
|
+
auth: true
|
|
1749
|
+
});
|
|
1750
|
+
this.name = data.name;
|
|
1751
|
+
return this;
|
|
1752
|
+
}
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
|
|
1757
|
+
// src/structures/GuildSticker.ts
|
|
1758
|
+
var GuildSticker_exports = {};
|
|
1759
|
+
__export(GuildSticker_exports, {
|
|
1760
|
+
GuildSticker: () => GuildSticker
|
|
1761
|
+
});
|
|
1762
|
+
var import_types13, GuildSticker;
|
|
1763
|
+
var init_GuildSticker = __esm({
|
|
1764
|
+
"src/structures/GuildSticker.ts"() {
|
|
1765
|
+
"use strict";
|
|
1766
|
+
init_Base();
|
|
1767
|
+
import_types13 = require("@fluxerjs/types");
|
|
1768
|
+
init_Constants();
|
|
1769
|
+
GuildSticker = class extends Base {
|
|
1770
|
+
client;
|
|
1771
|
+
id;
|
|
1772
|
+
guildId;
|
|
1773
|
+
name;
|
|
1774
|
+
description;
|
|
1775
|
+
tags;
|
|
1776
|
+
animated;
|
|
1777
|
+
/** @param data - API sticker from GET /guilds/{id}/stickers or guild sticker events */
|
|
1778
|
+
constructor(client, data, guildId) {
|
|
1779
|
+
super();
|
|
1780
|
+
this.client = client;
|
|
1781
|
+
this.id = data.id;
|
|
1782
|
+
this.guildId = data.guild_id ?? guildId;
|
|
1783
|
+
this.name = data.name;
|
|
1784
|
+
this.description = data.description ?? "";
|
|
1785
|
+
this.tags = data.tags ?? [];
|
|
1786
|
+
this.animated = data.animated ?? false;
|
|
1787
|
+
}
|
|
1788
|
+
/** CDN URL for this sticker image. */
|
|
1789
|
+
get url() {
|
|
1790
|
+
const ext = this.animated ? "gif" : "png";
|
|
1791
|
+
return `${CDN_URL}/stickers/${this.id}.${ext}`;
|
|
1792
|
+
}
|
|
1793
|
+
/** Delete this sticker. Requires Manage Emojis and Stickers permission. */
|
|
1794
|
+
async delete() {
|
|
1795
|
+
await this.client.rest.delete(import_types13.Routes.guildSticker(this.guildId, this.id), {
|
|
1796
|
+
auth: true
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Edit this sticker's name and/or description.
|
|
1801
|
+
* Requires Manage Emojis and Stickers permission.
|
|
1802
|
+
*/
|
|
1803
|
+
async edit(options) {
|
|
1804
|
+
const data = await this.client.rest.patch(import_types13.Routes.guildSticker(this.guildId, this.id), {
|
|
1805
|
+
body: options,
|
|
1554
1806
|
auth: true
|
|
1555
1807
|
});
|
|
1808
|
+
const s = data;
|
|
1809
|
+
this.name = s.name;
|
|
1810
|
+
this.description = s.description ?? "";
|
|
1811
|
+
return this;
|
|
1556
1812
|
}
|
|
1557
1813
|
};
|
|
1558
1814
|
}
|
|
@@ -1563,7 +1819,7 @@ var Guild_exports = {};
|
|
|
1563
1819
|
__export(Guild_exports, {
|
|
1564
1820
|
Guild: () => Guild
|
|
1565
1821
|
});
|
|
1566
|
-
var import_util6, import_rest3, import_collection6,
|
|
1822
|
+
var import_util6, import_rest3, import_collection6, import_types14, Guild;
|
|
1567
1823
|
var init_Guild = __esm({
|
|
1568
1824
|
"src/structures/Guild.ts"() {
|
|
1569
1825
|
"use strict";
|
|
@@ -1577,7 +1833,7 @@ var init_Guild = __esm({
|
|
|
1577
1833
|
init_GuildMember();
|
|
1578
1834
|
init_Role();
|
|
1579
1835
|
init_Constants();
|
|
1580
|
-
|
|
1836
|
+
import_types14 = require("@fluxerjs/types");
|
|
1581
1837
|
Guild = class extends Base {
|
|
1582
1838
|
client;
|
|
1583
1839
|
id;
|
|
@@ -1670,7 +1926,7 @@ var init_Guild = __esm({
|
|
|
1670
1926
|
* Requires Manage Roles permission.
|
|
1671
1927
|
*/
|
|
1672
1928
|
async addRoleToMember(userId, roleId) {
|
|
1673
|
-
await this.client.rest.put(
|
|
1929
|
+
await this.client.rest.put(import_types14.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1674
1930
|
}
|
|
1675
1931
|
/**
|
|
1676
1932
|
* Remove a role from a member by user ID. Does not require fetching the member first.
|
|
@@ -1679,7 +1935,7 @@ var init_Guild = __esm({
|
|
|
1679
1935
|
* Requires Manage Roles permission.
|
|
1680
1936
|
*/
|
|
1681
1937
|
async removeRoleFromMember(userId, roleId) {
|
|
1682
|
-
await this.client.rest.delete(
|
|
1938
|
+
await this.client.rest.delete(import_types14.Routes.guildMemberRole(this.id, userId, roleId));
|
|
1683
1939
|
}
|
|
1684
1940
|
/**
|
|
1685
1941
|
* Create a role in this guild.
|
|
@@ -1701,7 +1957,7 @@ var init_Guild = __esm({
|
|
|
1701
1957
|
if (options.unicode_emoji !== void 0) body.unicode_emoji = options.unicode_emoji;
|
|
1702
1958
|
if (options.position !== void 0) body.position = options.position;
|
|
1703
1959
|
if (options.hoist_position !== void 0) body.hoist_position = options.hoist_position;
|
|
1704
|
-
const data = await this.client.rest.post(
|
|
1960
|
+
const data = await this.client.rest.post(import_types14.Routes.guildRoles(this.id), {
|
|
1705
1961
|
body: Object.keys(body).length ? body : void 0,
|
|
1706
1962
|
auth: true
|
|
1707
1963
|
});
|
|
@@ -1715,7 +1971,7 @@ var init_Guild = __esm({
|
|
|
1715
1971
|
*/
|
|
1716
1972
|
async fetchRoles() {
|
|
1717
1973
|
const data = await this.client.rest.get(
|
|
1718
|
-
|
|
1974
|
+
import_types14.Routes.guildRoles(this.id)
|
|
1719
1975
|
);
|
|
1720
1976
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1721
1977
|
const roles = [];
|
|
@@ -1734,7 +1990,7 @@ var init_Guild = __esm({
|
|
|
1734
1990
|
*/
|
|
1735
1991
|
async fetchRole(roleId) {
|
|
1736
1992
|
try {
|
|
1737
|
-
const data = await this.client.rest.get(
|
|
1993
|
+
const data = await this.client.rest.get(import_types14.Routes.guildRole(this.id, roleId));
|
|
1738
1994
|
const role = new Role(this.client, data, this.id);
|
|
1739
1995
|
this.roles.set(role.id, role);
|
|
1740
1996
|
return role;
|
|
@@ -1763,7 +2019,7 @@ var init_Guild = __esm({
|
|
|
1763
2019
|
(r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase())
|
|
1764
2020
|
);
|
|
1765
2021
|
if (cached) return cached.id;
|
|
1766
|
-
const roles = await this.client.rest.get(
|
|
2022
|
+
const roles = await this.client.rest.get(import_types14.Routes.guildRoles(this.id));
|
|
1767
2023
|
const list = Array.isArray(roles) ? roles : Object.values(roles ?? {});
|
|
1768
2024
|
const role = list.find((r) => !!(r.name && r.name.toLowerCase() === arg.trim().toLowerCase()));
|
|
1769
2025
|
if (role) {
|
|
@@ -1786,7 +2042,7 @@ var init_Guild = __esm({
|
|
|
1786
2042
|
body.delete_message_days = options.delete_message_days;
|
|
1787
2043
|
if (options?.ban_duration_seconds != null)
|
|
1788
2044
|
body.ban_duration_seconds = options.ban_duration_seconds;
|
|
1789
|
-
await this.client.rest.put(
|
|
2045
|
+
await this.client.rest.put(import_types14.Routes.guildBan(this.id, userId), {
|
|
1790
2046
|
body: Object.keys(body).length ? body : void 0,
|
|
1791
2047
|
auth: true
|
|
1792
2048
|
});
|
|
@@ -1797,7 +2053,7 @@ var init_Guild = __esm({
|
|
|
1797
2053
|
*/
|
|
1798
2054
|
async fetchBans() {
|
|
1799
2055
|
const { GuildBan: GuildBan2 } = await Promise.resolve().then(() => (init_GuildBan(), GuildBan_exports));
|
|
1800
|
-
const data = await this.client.rest.get(
|
|
2056
|
+
const data = await this.client.rest.get(import_types14.Routes.guildBans(this.id));
|
|
1801
2057
|
const list = Array.isArray(data) ? data : data?.bans ?? [];
|
|
1802
2058
|
return list.map((b) => new GuildBan2(this.client, { ...b, guild_id: this.id }, this.id));
|
|
1803
2059
|
}
|
|
@@ -1807,7 +2063,7 @@ var init_Guild = __esm({
|
|
|
1807
2063
|
* Requires Ban Members permission.
|
|
1808
2064
|
*/
|
|
1809
2065
|
async unban(userId) {
|
|
1810
|
-
await this.client.rest.delete(
|
|
2066
|
+
await this.client.rest.delete(import_types14.Routes.guildBan(this.id, userId), { auth: true });
|
|
1811
2067
|
}
|
|
1812
2068
|
/**
|
|
1813
2069
|
* Kick a member from this guild.
|
|
@@ -1815,7 +2071,7 @@ var init_Guild = __esm({
|
|
|
1815
2071
|
* Requires Kick Members permission.
|
|
1816
2072
|
*/
|
|
1817
2073
|
async kick(userId) {
|
|
1818
|
-
await this.client.rest.delete(
|
|
2074
|
+
await this.client.rest.delete(import_types14.Routes.guildMember(this.id, userId), { auth: true });
|
|
1819
2075
|
}
|
|
1820
2076
|
/**
|
|
1821
2077
|
* Fetch a guild member by user ID.
|
|
@@ -1827,7 +2083,7 @@ var init_Guild = __esm({
|
|
|
1827
2083
|
async fetchMember(userId) {
|
|
1828
2084
|
try {
|
|
1829
2085
|
const data = await this.client.rest.get(
|
|
1830
|
-
|
|
2086
|
+
import_types14.Routes.guildMember(this.id, userId)
|
|
1831
2087
|
);
|
|
1832
2088
|
const member = new GuildMember(this.client, { ...data, guild_id: this.id }, this);
|
|
1833
2089
|
this.members.set(member.id, member);
|
|
@@ -1855,13 +2111,13 @@ var init_Guild = __esm({
|
|
|
1855
2111
|
if (options?.userId) params.set("user_id", options.userId);
|
|
1856
2112
|
if (options?.actionType != null) params.set("action_type", String(options.actionType));
|
|
1857
2113
|
const qs = params.toString();
|
|
1858
|
-
const url =
|
|
2114
|
+
const url = import_types14.Routes.guildAuditLogs(this.id) + (qs ? `?${qs}` : "");
|
|
1859
2115
|
return this.client.rest.get(url);
|
|
1860
2116
|
}
|
|
1861
2117
|
/** Fetch all webhooks in this guild. Returned webhooks do not include the token (cannot send). */
|
|
1862
2118
|
async fetchWebhooks() {
|
|
1863
2119
|
const { Webhook: Webhook2 } = await Promise.resolve().then(() => (init_Webhook(), Webhook_exports));
|
|
1864
|
-
const data = await this.client.rest.get(
|
|
2120
|
+
const data = await this.client.rest.get(import_types14.Routes.guildWebhooks(this.id));
|
|
1865
2121
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1866
2122
|
return list.map((w) => new Webhook2(this.client, w));
|
|
1867
2123
|
}
|
|
@@ -1872,7 +2128,7 @@ var init_Guild = __esm({
|
|
|
1872
2128
|
*/
|
|
1873
2129
|
async createChannel(data) {
|
|
1874
2130
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1875
|
-
const created = await this.client.rest.post(
|
|
2131
|
+
const created = await this.client.rest.post(import_types14.Routes.guildChannels(this.id), {
|
|
1876
2132
|
body: data,
|
|
1877
2133
|
auth: true
|
|
1878
2134
|
});
|
|
@@ -1889,7 +2145,7 @@ var init_Guild = __esm({
|
|
|
1889
2145
|
*/
|
|
1890
2146
|
async fetchChannels() {
|
|
1891
2147
|
const { Channel: Channel2 } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
1892
|
-
const data = await this.client.rest.get(
|
|
2148
|
+
const data = await this.client.rest.get(import_types14.Routes.guildChannels(this.id));
|
|
1893
2149
|
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
1894
2150
|
const channels = [];
|
|
1895
2151
|
for (const ch of list) {
|
|
@@ -1902,28 +2158,174 @@ var init_Guild = __esm({
|
|
|
1902
2158
|
}
|
|
1903
2159
|
return channels;
|
|
1904
2160
|
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Edit this guild. PATCH /guilds/{id}.
|
|
2163
|
+
* Requires guild owner or Administrator.
|
|
2164
|
+
*/
|
|
2165
|
+
async edit(options) {
|
|
2166
|
+
const data = await this.client.rest.patch(import_types14.Routes.guild(this.id), {
|
|
2167
|
+
body: options,
|
|
2168
|
+
auth: true
|
|
2169
|
+
});
|
|
2170
|
+
this.name = data.name;
|
|
2171
|
+
this.icon = data.icon ?? this.icon;
|
|
2172
|
+
this.banner = data.banner ?? this.banner;
|
|
2173
|
+
this.splash = data.splash ?? this.splash;
|
|
2174
|
+
this.systemChannelId = data.system_channel_id ?? this.systemChannelId;
|
|
2175
|
+
this.afkChannelId = data.afk_channel_id ?? this.afkChannelId;
|
|
2176
|
+
this.afkTimeout = data.afk_timeout ?? this.afkTimeout;
|
|
2177
|
+
this.verificationLevel = data.verification_level ?? this.verificationLevel;
|
|
2178
|
+
this.mfaLevel = data.mfa_level ?? this.mfaLevel;
|
|
2179
|
+
this.explicitContentFilter = data.explicit_content_filter ?? this.explicitContentFilter;
|
|
2180
|
+
this.defaultMessageNotifications = data.default_message_notifications ?? this.defaultMessageNotifications;
|
|
2181
|
+
this.features = data.features ?? this.features;
|
|
2182
|
+
return this;
|
|
2183
|
+
}
|
|
2184
|
+
/**
|
|
2185
|
+
* Delete this guild. POST /guilds/{id}/delete.
|
|
2186
|
+
* Must be the guild owner.
|
|
2187
|
+
*/
|
|
2188
|
+
async delete() {
|
|
2189
|
+
await this.client.rest.post(import_types14.Routes.guildDelete(this.id), { auth: true });
|
|
2190
|
+
this.client.guilds.delete(this.id);
|
|
2191
|
+
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Fetch vanity URL for this guild. GET /guilds/{id}/vanity-url.
|
|
2194
|
+
* Requires Manage Guild permission.
|
|
2195
|
+
*/
|
|
2196
|
+
async fetchVanityURL() {
|
|
2197
|
+
return this.client.rest.get(import_types14.Routes.guildVanityUrl(this.id), { auth: true });
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Transfer guild ownership to another user. POST /guilds/{id}/transfer-ownership.
|
|
2201
|
+
* Must be the guild owner.
|
|
2202
|
+
*/
|
|
2203
|
+
async transferOwnership(newOwnerId, password) {
|
|
2204
|
+
await this.client.rest.post(import_types14.Routes.guildTransferOwnership(this.id), {
|
|
2205
|
+
body: { new_owner_id: newOwnerId, ...password != null && { password } },
|
|
2206
|
+
auth: true
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Set text channel flexible names feature. PATCH /guilds/{id}/text-channel-flexible-names.
|
|
2211
|
+
*/
|
|
2212
|
+
setTextChannelFlexibleNames(enabled) {
|
|
2213
|
+
return this.client.rest.patch(import_types14.Routes.guildTextChannelFlexibleNames(this.id), {
|
|
2214
|
+
body: { enabled },
|
|
2215
|
+
auth: true
|
|
2216
|
+
}).then(() => this);
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* Set detached banner feature. PATCH /guilds/{id}/detached-banner.
|
|
2220
|
+
*/
|
|
2221
|
+
setDetachedBanner(enabled) {
|
|
2222
|
+
return this.client.rest.patch(import_types14.Routes.guildDetachedBanner(this.id), {
|
|
2223
|
+
body: { enabled },
|
|
2224
|
+
auth: true
|
|
2225
|
+
}).then(() => this);
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Set disallow unclaimed accounts. PATCH /guilds/{id}/disallow-unclaimed-accounts.
|
|
2229
|
+
*/
|
|
2230
|
+
setDisallowUnclaimedAccounts(enabled) {
|
|
2231
|
+
return this.client.rest.patch(import_types14.Routes.guildDisallowUnclaimedAccounts(this.id), {
|
|
2232
|
+
body: { enabled },
|
|
2233
|
+
auth: true
|
|
2234
|
+
}).then(() => this);
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Update role positions. PATCH /guilds/{id}/roles.
|
|
2238
|
+
* @param updates - Array of { id, position? }
|
|
2239
|
+
*/
|
|
2240
|
+
async setRolePositions(updates) {
|
|
2241
|
+
const data = await this.client.rest.patch(
|
|
2242
|
+
import_types14.Routes.guildRoles(this.id),
|
|
2243
|
+
{ body: updates, auth: true }
|
|
2244
|
+
);
|
|
2245
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2246
|
+
for (const r of list) {
|
|
2247
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2248
|
+
}
|
|
2249
|
+
return list;
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Update role hoist positions. PATCH /guilds/{id}/roles/hoist-positions.
|
|
2253
|
+
*/
|
|
2254
|
+
async setRoleHoistPositions(updates) {
|
|
2255
|
+
const data = await this.client.rest.patch(
|
|
2256
|
+
import_types14.Routes.guildRolesHoistPositions(this.id),
|
|
2257
|
+
{ body: updates, auth: true }
|
|
2258
|
+
);
|
|
2259
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2260
|
+
for (const r of list) {
|
|
2261
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2262
|
+
}
|
|
2263
|
+
return list;
|
|
2264
|
+
}
|
|
2265
|
+
/**
|
|
2266
|
+
* Reset role hoist positions. DELETE /guilds/{id}/roles/hoist-positions.
|
|
2267
|
+
*/
|
|
2268
|
+
async resetRoleHoistPositions() {
|
|
2269
|
+
const data = await this.client.rest.delete(
|
|
2270
|
+
import_types14.Routes.guildRolesHoistPositions(this.id),
|
|
2271
|
+
{ auth: true }
|
|
2272
|
+
);
|
|
2273
|
+
const list = Array.isArray(data) ? data : Object.values(data ?? {});
|
|
2274
|
+
for (const r of list) {
|
|
2275
|
+
this.roles.set(r.id, new Role(this.client, r, this.id));
|
|
2276
|
+
}
|
|
2277
|
+
return list;
|
|
2278
|
+
}
|
|
1905
2279
|
/**
|
|
1906
2280
|
* Update channel positions.
|
|
1907
2281
|
* @param updates - Array of { id, position?, parent_id?, lock_permissions? }
|
|
1908
2282
|
* Requires Manage Channels permission.
|
|
1909
2283
|
*/
|
|
1910
2284
|
async setChannelPositions(updates) {
|
|
1911
|
-
await this.client.rest.patch(
|
|
2285
|
+
await this.client.rest.patch(import_types14.Routes.guildChannels(this.id), {
|
|
1912
2286
|
body: updates,
|
|
1913
2287
|
auth: true
|
|
1914
2288
|
});
|
|
1915
2289
|
}
|
|
2290
|
+
/**
|
|
2291
|
+
* Bulk create emojis. POST /guilds/{id}/emojis/bulk.
|
|
2292
|
+
* @param emojis - Array of { name, image } (base64), 1-50 emojis
|
|
2293
|
+
* @returns Array of created GuildEmoji objects
|
|
2294
|
+
*/
|
|
2295
|
+
async createEmojisBulk(emojis) {
|
|
2296
|
+
const { GuildEmoji: GuildEmoji2 } = await Promise.resolve().then(() => (init_GuildEmoji(), GuildEmoji_exports));
|
|
2297
|
+
const data = await this.client.rest.post(import_types14.Routes.guildEmojisBulk(this.id), {
|
|
2298
|
+
body: { emojis },
|
|
2299
|
+
auth: true
|
|
2300
|
+
});
|
|
2301
|
+
const list = Array.isArray(data) ? data : data?.emojis ?? [];
|
|
2302
|
+
return list.map((e) => new GuildEmoji2(this.client, { ...e, guild_id: this.id }, this.id));
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Bulk create stickers. POST /guilds/{id}/stickers/bulk.
|
|
2306
|
+
* @param stickers - Array of { name, image, description?, tags? }, 1-50 stickers
|
|
2307
|
+
* @returns Array of created GuildSticker objects
|
|
2308
|
+
*/
|
|
2309
|
+
async createStickersBulk(stickers) {
|
|
2310
|
+
const { GuildSticker: GuildSticker2 } = await Promise.resolve().then(() => (init_GuildSticker(), GuildSticker_exports));
|
|
2311
|
+
const data = await this.client.rest.post(import_types14.Routes.guildStickersBulk(this.id), {
|
|
2312
|
+
body: { stickers },
|
|
2313
|
+
auth: true
|
|
2314
|
+
});
|
|
2315
|
+
const list = Array.isArray(data) ? data : data?.stickers ?? [];
|
|
2316
|
+
return list.map((s) => new GuildSticker2(this.client, { ...s, guild_id: this.id }, this.id));
|
|
2317
|
+
}
|
|
1916
2318
|
};
|
|
1917
2319
|
}
|
|
1918
2320
|
});
|
|
1919
2321
|
|
|
1920
2322
|
// src/structures/User.ts
|
|
1921
|
-
var
|
|
2323
|
+
var import_types16, User;
|
|
1922
2324
|
var init_User = __esm({
|
|
1923
2325
|
"src/structures/User.ts"() {
|
|
1924
2326
|
"use strict";
|
|
1925
2327
|
init_Base();
|
|
1926
|
-
|
|
2328
|
+
import_types16 = require("@fluxerjs/types");
|
|
1927
2329
|
init_Constants();
|
|
1928
2330
|
User = class extends Base {
|
|
1929
2331
|
client;
|
|
@@ -2001,7 +2403,7 @@ var init_User = __esm({
|
|
|
2001
2403
|
*/
|
|
2002
2404
|
async createDM() {
|
|
2003
2405
|
const { DMChannel: DMChannelClass } = await Promise.resolve().then(() => (init_Channel(), Channel_exports));
|
|
2004
|
-
const data = await this.client.rest.post(
|
|
2406
|
+
const data = await this.client.rest.post(import_types16.Routes.userMeChannels(), {
|
|
2005
2407
|
body: { recipient_id: this.id },
|
|
2006
2408
|
auth: true
|
|
2007
2409
|
});
|
|
@@ -2024,11 +2426,11 @@ var MessageReaction_exports = {};
|
|
|
2024
2426
|
__export(MessageReaction_exports, {
|
|
2025
2427
|
MessageReaction: () => MessageReaction
|
|
2026
2428
|
});
|
|
2027
|
-
var
|
|
2429
|
+
var import_types18, import_rest4, MessageReaction;
|
|
2028
2430
|
var init_MessageReaction = __esm({
|
|
2029
2431
|
"src/structures/MessageReaction.ts"() {
|
|
2030
2432
|
"use strict";
|
|
2031
|
-
|
|
2433
|
+
import_types18 = require("@fluxerjs/types");
|
|
2032
2434
|
import_rest4 = require("@fluxerjs/rest");
|
|
2033
2435
|
init_FluxerError();
|
|
2034
2436
|
init_ErrorCodes();
|
|
@@ -2067,7 +2469,7 @@ var init_MessageReaction = __esm({
|
|
|
2067
2469
|
try {
|
|
2068
2470
|
const { Message: Message2 } = await Promise.resolve().then(() => (init_Message(), Message_exports));
|
|
2069
2471
|
const data = await this.client.rest.get(
|
|
2070
|
-
|
|
2472
|
+
import_types18.Routes.channelMessage(this.channelId, this.messageId)
|
|
2071
2473
|
);
|
|
2072
2474
|
return new Message2(this.client, data);
|
|
2073
2475
|
} catch (err) {
|
|
@@ -2090,12 +2492,12 @@ var ClientUser_exports = {};
|
|
|
2090
2492
|
__export(ClientUser_exports, {
|
|
2091
2493
|
ClientUser: () => ClientUser
|
|
2092
2494
|
});
|
|
2093
|
-
var
|
|
2495
|
+
var import_types19, ClientUser;
|
|
2094
2496
|
var init_ClientUser = __esm({
|
|
2095
2497
|
"src/client/ClientUser.ts"() {
|
|
2096
2498
|
"use strict";
|
|
2097
2499
|
init_User();
|
|
2098
|
-
|
|
2500
|
+
import_types19 = require("@fluxerjs/types");
|
|
2099
2501
|
ClientUser = class extends User {
|
|
2100
2502
|
constructor(client, data) {
|
|
2101
2503
|
super(client, { ...data });
|
|
@@ -2106,7 +2508,7 @@ var init_ClientUser = __esm({
|
|
|
2106
2508
|
*/
|
|
2107
2509
|
async fetchGuilds() {
|
|
2108
2510
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2109
|
-
const data = await this.client.rest.get(
|
|
2511
|
+
const data = await this.client.rest.get(import_types19.Routes.currentUserGuilds());
|
|
2110
2512
|
const list = Array.isArray(data) ? data : data?.guilds ?? [];
|
|
2111
2513
|
const guilds = [];
|
|
2112
2514
|
for (const g of list) {
|
|
@@ -2121,7 +2523,7 @@ var init_ClientUser = __esm({
|
|
|
2121
2523
|
* @param guildId - The guild ID to leave
|
|
2122
2524
|
*/
|
|
2123
2525
|
async leaveGuild(guildId) {
|
|
2124
|
-
await this.client.rest.delete(
|
|
2526
|
+
await this.client.rest.delete(import_types19.Routes.leaveGuild(guildId), { auth: true });
|
|
2125
2527
|
this.client.guilds.delete(guildId);
|
|
2126
2528
|
}
|
|
2127
2529
|
};
|
|
@@ -2143,7 +2545,7 @@ __export(index_exports, {
|
|
|
2143
2545
|
ErrorCodes: () => ErrorCodes,
|
|
2144
2546
|
Events: () => Events,
|
|
2145
2547
|
FluxerError: () => FluxerError,
|
|
2146
|
-
GatewayOpcodes: () =>
|
|
2548
|
+
GatewayOpcodes: () => import_types21.GatewayOpcodes,
|
|
2147
2549
|
Guild: () => Guild,
|
|
2148
2550
|
GuildBan: () => GuildBan,
|
|
2149
2551
|
GuildChannel: () => GuildChannel,
|
|
@@ -2154,7 +2556,7 @@ __export(index_exports, {
|
|
|
2154
2556
|
Invite: () => Invite,
|
|
2155
2557
|
LinkChannel: () => LinkChannel,
|
|
2156
2558
|
Message: () => Message,
|
|
2157
|
-
MessageAttachmentFlags: () =>
|
|
2559
|
+
MessageAttachmentFlags: () => import_types21.MessageAttachmentFlags,
|
|
2158
2560
|
MessageCollector: () => MessageCollector,
|
|
2159
2561
|
MessageManager: () => MessageManager,
|
|
2160
2562
|
MessagePayload: () => import_builders3.MessagePayload,
|
|
@@ -2163,7 +2565,7 @@ __export(index_exports, {
|
|
|
2163
2565
|
PermissionsBitField: () => import_util9.PermissionsBitField,
|
|
2164
2566
|
ReactionCollector: () => ReactionCollector,
|
|
2165
2567
|
Role: () => Role,
|
|
2166
|
-
Routes: () =>
|
|
2568
|
+
Routes: () => import_types21.Routes,
|
|
2167
2569
|
TextChannel: () => TextChannel,
|
|
2168
2570
|
User: () => User,
|
|
2169
2571
|
UserFlagsBitField: () => import_util9.UserFlagsBitField,
|
|
@@ -2186,7 +2588,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
2186
2588
|
var import_events3 = require("events");
|
|
2187
2589
|
var import_rest5 = require("@fluxerjs/rest");
|
|
2188
2590
|
var import_ws = require("@fluxerjs/ws");
|
|
2189
|
-
var
|
|
2591
|
+
var import_types20 = require("@fluxerjs/types");
|
|
2190
2592
|
|
|
2191
2593
|
// src/client/ChannelManager.ts
|
|
2192
2594
|
var import_collection4 = require("@fluxerjs/collection");
|
|
@@ -2294,12 +2696,27 @@ var ChannelManager = class extends import_collection4.Collection {
|
|
|
2294
2696
|
|
|
2295
2697
|
// src/client/GuildManager.ts
|
|
2296
2698
|
var import_collection7 = require("@fluxerjs/collection");
|
|
2297
|
-
var
|
|
2699
|
+
var import_types15 = require("@fluxerjs/types");
|
|
2298
2700
|
var GuildManager = class extends import_collection7.Collection {
|
|
2299
2701
|
constructor(client) {
|
|
2300
2702
|
super();
|
|
2301
2703
|
this.client = client;
|
|
2302
2704
|
}
|
|
2705
|
+
/**
|
|
2706
|
+
* Create a guild. POST /guilds.
|
|
2707
|
+
* @param options - name (required), icon (base64), empty_features
|
|
2708
|
+
* @returns The created guild
|
|
2709
|
+
*/
|
|
2710
|
+
async create(options) {
|
|
2711
|
+
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2712
|
+
const data = await this.client.rest.post(import_types15.Routes.guilds(), {
|
|
2713
|
+
body: options,
|
|
2714
|
+
auth: true
|
|
2715
|
+
});
|
|
2716
|
+
const guild = new Guild2(this.client, data);
|
|
2717
|
+
this.set(guild.id, guild);
|
|
2718
|
+
return guild;
|
|
2719
|
+
}
|
|
2303
2720
|
/**
|
|
2304
2721
|
* Fetch a guild by ID from the API (or return from cache if present).
|
|
2305
2722
|
* @param guildId - Snowflake of the guild
|
|
@@ -2314,7 +2731,7 @@ var GuildManager = class extends import_collection7.Collection {
|
|
|
2314
2731
|
try {
|
|
2315
2732
|
const { Guild: Guild2 } = await Promise.resolve().then(() => (init_Guild(), Guild_exports));
|
|
2316
2733
|
const data = await this.client.rest.get(
|
|
2317
|
-
|
|
2734
|
+
import_types15.Routes.guild(guildId)
|
|
2318
2735
|
);
|
|
2319
2736
|
const guild = new Guild2(this.client, data);
|
|
2320
2737
|
this.set(guild.id, guild);
|
|
@@ -2334,7 +2751,7 @@ init_User();
|
|
|
2334
2751
|
|
|
2335
2752
|
// src/client/UsersManager.ts
|
|
2336
2753
|
var import_collection8 = require("@fluxerjs/collection");
|
|
2337
|
-
var
|
|
2754
|
+
var import_types17 = require("@fluxerjs/types");
|
|
2338
2755
|
init_GuildMember();
|
|
2339
2756
|
var UsersManager = class extends import_collection8.Collection {
|
|
2340
2757
|
constructor(client) {
|
|
@@ -2352,7 +2769,7 @@ var UsersManager = class extends import_collection8.Collection {
|
|
|
2352
2769
|
* console.log(user.username);
|
|
2353
2770
|
*/
|
|
2354
2771
|
async fetch(userId) {
|
|
2355
|
-
const data = await this.client.rest.get(
|
|
2772
|
+
const data = await this.client.rest.get(import_types17.Routes.user(userId));
|
|
2356
2773
|
return this.client.getOrCreateUser(data);
|
|
2357
2774
|
}
|
|
2358
2775
|
/**
|
|
@@ -2372,10 +2789,10 @@ var UsersManager = class extends import_collection8.Collection {
|
|
|
2372
2789
|
async fetchWithProfile(userId, options) {
|
|
2373
2790
|
const guildId = options?.guildId ?? void 0;
|
|
2374
2791
|
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(
|
|
2792
|
+
this.client.rest.get(import_types17.Routes.user(userId)),
|
|
2793
|
+
this.client.rest.get(import_types17.Routes.userProfile(userId)).catch(() => null),
|
|
2794
|
+
guildId ? this.client.rest.get(import_types17.Routes.userProfile(userId, guildId)).catch(() => null) : Promise.resolve(null),
|
|
2795
|
+
guildId ? this.client.rest.get(import_types17.Routes.guildMember(guildId, userId)).catch(() => null) : Promise.resolve(null)
|
|
2379
2796
|
]);
|
|
2380
2797
|
const user = this.client.getOrCreateUser(userData);
|
|
2381
2798
|
const globalProfile = globalProfileData && typeof globalProfileData === "object" ? globalProfileData : null;
|
|
@@ -2568,13 +2985,27 @@ handlers.set("GUILD_MEMBER_UPDATE", async (client, d) => {
|
|
|
2568
2985
|
handlers.set("GUILD_MEMBER_REMOVE", async (client, d) => {
|
|
2569
2986
|
const data = d;
|
|
2570
2987
|
const guild = client.guilds.get(data.guild_id);
|
|
2571
|
-
if (guild)
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2988
|
+
if (!guild || !data.user?.id) return;
|
|
2989
|
+
const { GuildMember: GuildMember2 } = await Promise.resolve().then(() => (init_GuildMember(), GuildMember_exports));
|
|
2990
|
+
let member = guild.members.get(data.user.id);
|
|
2991
|
+
if (member) {
|
|
2992
|
+
guild.members.delete(data.user.id);
|
|
2993
|
+
} else {
|
|
2994
|
+
const user = {
|
|
2995
|
+
...data.user,
|
|
2996
|
+
id: data.user.id,
|
|
2997
|
+
username: data.user.username ?? "Unknown",
|
|
2998
|
+
discriminator: data.user.discriminator ?? "0"
|
|
2999
|
+
};
|
|
3000
|
+
const memberData = {
|
|
3001
|
+
user,
|
|
3002
|
+
roles: [],
|
|
3003
|
+
joined_at: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
3004
|
+
nick: null
|
|
3005
|
+
};
|
|
3006
|
+
member = new GuildMember2(client, memberData, guild);
|
|
2577
3007
|
}
|
|
3008
|
+
client.emit(Events.GuildMemberRemove, member);
|
|
2578
3009
|
});
|
|
2579
3010
|
handlers.set("INTERACTION_CREATE", async (client, d) => {
|
|
2580
3011
|
client.emit(Events.InteractionCreate, d);
|
|
@@ -2745,7 +3176,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2745
3176
|
if (parsed.id) return (0, import_util7.formatEmoji)(parsed);
|
|
2746
3177
|
if (!/^\w+$/.test(parsed.name)) return encodeURIComponent(parsed.name);
|
|
2747
3178
|
if (guildId) {
|
|
2748
|
-
const emojis = await this.rest.get(
|
|
3179
|
+
const emojis = await this.rest.get(import_types20.Routes.guildEmojis(guildId));
|
|
2749
3180
|
const list = Array.isArray(emojis) ? emojis : Object.values(emojis ?? {});
|
|
2750
3181
|
const found = list.find((e) => e.name && e.name.toLowerCase() === parsed.name.toLowerCase());
|
|
2751
3182
|
if (found) return (0, import_util7.formatEmoji)({ ...parsed, id: found.id, animated: found.animated });
|
|
@@ -2760,6 +3191,13 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2760
3191
|
}
|
|
2761
3192
|
return encodeURIComponent(parsed.name);
|
|
2762
3193
|
}
|
|
3194
|
+
/**
|
|
3195
|
+
* Fetch instance info (API URL, gateway URL, features). GET /instance.
|
|
3196
|
+
* Does not require authentication.
|
|
3197
|
+
*/
|
|
3198
|
+
async fetchInstance() {
|
|
3199
|
+
return this.rest.get(import_types20.Routes.instance(), { auth: false });
|
|
3200
|
+
}
|
|
2763
3201
|
/**
|
|
2764
3202
|
* Fetch a message by channel and message ID. Use when you have IDs (e.g. from a DB).
|
|
2765
3203
|
* @param channelId - Snowflake of the channel
|
|
@@ -2912,7 +3350,7 @@ var Client = class extends import_events3.EventEmitter {
|
|
|
2912
3350
|
return this.readyAt !== null && this.user !== null;
|
|
2913
3351
|
}
|
|
2914
3352
|
static get Routes() {
|
|
2915
|
-
return
|
|
3353
|
+
return import_types20.Routes;
|
|
2916
3354
|
}
|
|
2917
3355
|
};
|
|
2918
3356
|
|
|
@@ -2931,113 +3369,15 @@ init_GuildMember();
|
|
|
2931
3369
|
init_Role();
|
|
2932
3370
|
init_Invite();
|
|
2933
3371
|
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
|
|
3372
|
+
init_GuildEmoji();
|
|
3373
|
+
init_GuildSticker();
|
|
3034
3374
|
init_Events();
|
|
3035
3375
|
init_MessageCollector();
|
|
3036
3376
|
init_ReactionCollector();
|
|
3037
3377
|
init_FluxerError();
|
|
3038
3378
|
init_ErrorCodes();
|
|
3039
3379
|
var import_builders3 = require("@fluxerjs/builders");
|
|
3040
|
-
var
|
|
3380
|
+
var import_types21 = require("@fluxerjs/types");
|
|
3041
3381
|
var import_util8 = require("@fluxerjs/util");
|
|
3042
3382
|
var import_util9 = require("@fluxerjs/util");
|
|
3043
3383
|
init_cdn();
|