@impulsedev/chameleon 1.6.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/diff.txt +3086 -0
- package/dist/builders-CCZQJXF6.js +60 -0
- package/dist/chunk-F2RRJ7OJ.js +850 -0
- package/dist/index.d.ts +171 -142
- package/dist/index.js +451 -925
- package/media/discordchameleon.png +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionRowBuilder,
|
|
3
|
+
ButtonBuilder,
|
|
4
|
+
ButtonStyle,
|
|
5
|
+
Colors,
|
|
6
|
+
ComponentType,
|
|
7
|
+
EmbedBuilder,
|
|
8
|
+
ModalBuilder,
|
|
9
|
+
SelectMenuBuilder,
|
|
10
|
+
TextInputBuilder,
|
|
11
|
+
buildAutoModRule,
|
|
12
|
+
buildChannel,
|
|
13
|
+
buildEmoji,
|
|
14
|
+
buildEntitlement,
|
|
15
|
+
buildGuild,
|
|
16
|
+
buildIntegration,
|
|
17
|
+
buildInteraction,
|
|
18
|
+
buildMember,
|
|
19
|
+
buildMessage,
|
|
20
|
+
buildRole,
|
|
21
|
+
buildScheduledEvent,
|
|
22
|
+
buildStageInstance,
|
|
23
|
+
buildSticker,
|
|
24
|
+
buildStickerItem,
|
|
25
|
+
buildUser,
|
|
26
|
+
buildVoiceState,
|
|
27
|
+
resolveChannel,
|
|
28
|
+
resolveGuild,
|
|
29
|
+
resolveRole,
|
|
30
|
+
resolveUser,
|
|
31
|
+
serializeComponent,
|
|
32
|
+
toSnakeCase
|
|
33
|
+
} from "./chunk-F2RRJ7OJ.js";
|
|
34
|
+
|
|
1
35
|
// src/types/user/index.ts
|
|
2
36
|
var UserFlag = {
|
|
3
37
|
STAFF: 1 << 0,
|
|
@@ -462,26 +496,6 @@ var AutoModerationActionType = {
|
|
|
462
496
|
BLOCK_MEMBER_INTERACTION: 4
|
|
463
497
|
};
|
|
464
498
|
|
|
465
|
-
// src/types/components/index.ts
|
|
466
|
-
var ComponentType = {
|
|
467
|
-
ACTION_ROW: 1,
|
|
468
|
-
BUTTON: 2,
|
|
469
|
-
STRING_SELECT: 3,
|
|
470
|
-
TEXT_INPUT: 4,
|
|
471
|
-
USER_SELECT: 5,
|
|
472
|
-
ROLE_SELECT: 6,
|
|
473
|
-
MENTIONABLE_SELECT: 7,
|
|
474
|
-
CHANNEL_SELECT: 8
|
|
475
|
-
};
|
|
476
|
-
var ButtonStyle = {
|
|
477
|
-
PRIMARY: 1,
|
|
478
|
-
SECONDARY: 2,
|
|
479
|
-
SUCCESS: 3,
|
|
480
|
-
DANGER: 4,
|
|
481
|
-
LINK: 5,
|
|
482
|
-
PREMIUM: 6
|
|
483
|
-
};
|
|
484
|
-
|
|
485
499
|
// src/types/entitlement/index.ts
|
|
486
500
|
var EntitlementType = {
|
|
487
501
|
PURCHASE: 1,
|
|
@@ -1215,7 +1229,7 @@ var ChameleonGateway = class {
|
|
|
1215
1229
|
// package.json
|
|
1216
1230
|
var package_default = {
|
|
1217
1231
|
name: "@impulsedev/chameleon",
|
|
1218
|
-
version: "
|
|
1232
|
+
version: "2.0.0",
|
|
1219
1233
|
description: "highly optimized, memory-efficient, and fully type-safe Discord API library",
|
|
1220
1234
|
main: "dist/index.js",
|
|
1221
1235
|
types: "dist/index.d.ts",
|
|
@@ -1290,535 +1304,6 @@ var MESSAGE_FLAGS = {
|
|
|
1290
1304
|
var CHAMELEON_VERSION = package_default.version;
|
|
1291
1305
|
var CHAMELEON = package_default.name;
|
|
1292
1306
|
|
|
1293
|
-
// src/builders/embed.ts
|
|
1294
|
-
var Colors = {
|
|
1295
|
-
Blue: 2003199,
|
|
1296
|
-
Purple: 10181046,
|
|
1297
|
-
Orange: 16744272,
|
|
1298
|
-
Pink: 16739201,
|
|
1299
|
-
White: 16777215,
|
|
1300
|
-
Blurple: 5793266,
|
|
1301
|
-
Green: 5763719,
|
|
1302
|
-
Yellow: 16705372,
|
|
1303
|
-
Fuchsia: 15418782,
|
|
1304
|
-
Red: 15548997,
|
|
1305
|
-
Black: 2303786,
|
|
1306
|
-
Transparent: 3092790
|
|
1307
|
-
};
|
|
1308
|
-
var EmbedBuilder = class {
|
|
1309
|
-
data = {};
|
|
1310
|
-
constructor(data) {
|
|
1311
|
-
if (data) Object.assign(this.data, data);
|
|
1312
|
-
}
|
|
1313
|
-
setTitle(title) {
|
|
1314
|
-
this.data.title = title;
|
|
1315
|
-
return this;
|
|
1316
|
-
}
|
|
1317
|
-
setDescription(description) {
|
|
1318
|
-
this.data.description = description;
|
|
1319
|
-
return this;
|
|
1320
|
-
}
|
|
1321
|
-
setColor(color) {
|
|
1322
|
-
this.data.color = color;
|
|
1323
|
-
return this;
|
|
1324
|
-
}
|
|
1325
|
-
setURL(url) {
|
|
1326
|
-
this.data.url = url;
|
|
1327
|
-
return this;
|
|
1328
|
-
}
|
|
1329
|
-
setTimestamp(ts = Date.now()) {
|
|
1330
|
-
this.data.timestamp = ts instanceof Date ? ts.getTime() : ts;
|
|
1331
|
-
return this;
|
|
1332
|
-
}
|
|
1333
|
-
setFooter(text, iconUrl) {
|
|
1334
|
-
this.data.footer = {
|
|
1335
|
-
text,
|
|
1336
|
-
...iconUrl ? { iconUrl } : {}
|
|
1337
|
-
};
|
|
1338
|
-
return this;
|
|
1339
|
-
}
|
|
1340
|
-
setAuthor(name, iconUrl, url) {
|
|
1341
|
-
this.data.author = {
|
|
1342
|
-
name,
|
|
1343
|
-
...iconUrl ? { iconUrl } : {},
|
|
1344
|
-
...url ? { url } : {}
|
|
1345
|
-
};
|
|
1346
|
-
return this;
|
|
1347
|
-
}
|
|
1348
|
-
setImage(url) {
|
|
1349
|
-
this.data.image = { url };
|
|
1350
|
-
return this;
|
|
1351
|
-
}
|
|
1352
|
-
setThumbnail(url) {
|
|
1353
|
-
this.data.thumbnail = { url };
|
|
1354
|
-
return this;
|
|
1355
|
-
}
|
|
1356
|
-
addField(name, value, inline = false) {
|
|
1357
|
-
if (!this.data.fields) this.data.fields = [];
|
|
1358
|
-
this.data.fields.push({ name, value, inline });
|
|
1359
|
-
return this;
|
|
1360
|
-
}
|
|
1361
|
-
addFields(...fields) {
|
|
1362
|
-
if (!this.data.fields) this.data.fields = [];
|
|
1363
|
-
this.data.fields.push(...fields);
|
|
1364
|
-
return this;
|
|
1365
|
-
}
|
|
1366
|
-
build() {
|
|
1367
|
-
return this.data;
|
|
1368
|
-
}
|
|
1369
|
-
toJSON() {
|
|
1370
|
-
const e = this.data;
|
|
1371
|
-
const payload = {};
|
|
1372
|
-
if (e.title) payload.title = e.title;
|
|
1373
|
-
if (e.description) payload.description = e.description;
|
|
1374
|
-
if (e.color) payload.color = e.color;
|
|
1375
|
-
if (e.url) payload.url = e.url;
|
|
1376
|
-
if (e.timestamp) {
|
|
1377
|
-
payload.timestamp = new Date(e.timestamp).toISOString();
|
|
1378
|
-
}
|
|
1379
|
-
if (e.author) {
|
|
1380
|
-
payload.author = {
|
|
1381
|
-
name: e.author.name,
|
|
1382
|
-
...e.author.url ? { url: e.author.url } : {},
|
|
1383
|
-
...e.author.iconUrl ? { icon_url: e.author.iconUrl } : {},
|
|
1384
|
-
...e.author.proxyIconUrl ? { proxy_icon_url: e.author.proxyIconUrl } : {}
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
if (e.footer) {
|
|
1388
|
-
payload.footer = {
|
|
1389
|
-
text: e.footer.text,
|
|
1390
|
-
...e.footer.iconUrl ? { icon_url: e.footer.iconUrl } : {},
|
|
1391
|
-
...e.footer.proxyIconUrl ? { proxy_icon_url: e.footer.proxyIconUrl } : {}
|
|
1392
|
-
};
|
|
1393
|
-
}
|
|
1394
|
-
if (e.image?.url) {
|
|
1395
|
-
payload.image = {
|
|
1396
|
-
url: e.image.url
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
if (e.thumbnail?.url) {
|
|
1400
|
-
payload.thumbnail = {
|
|
1401
|
-
url: e.thumbnail.url
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
if (e.fields?.length) {
|
|
1405
|
-
payload.fields = e.fields.map((f) => ({
|
|
1406
|
-
name: f.name,
|
|
1407
|
-
value: f.value,
|
|
1408
|
-
inline: f.inline ?? false
|
|
1409
|
-
}));
|
|
1410
|
-
}
|
|
1411
|
-
return payload;
|
|
1412
|
-
}
|
|
1413
|
-
};
|
|
1414
|
-
|
|
1415
|
-
// src/builders/components.ts
|
|
1416
|
-
function serializeEmoji(emoji) {
|
|
1417
|
-
if (!emoji) return void 0;
|
|
1418
|
-
return {
|
|
1419
|
-
id: emoji.id,
|
|
1420
|
-
name: emoji.name,
|
|
1421
|
-
animated: emoji.animated
|
|
1422
|
-
};
|
|
1423
|
-
}
|
|
1424
|
-
var ButtonBuilder = class {
|
|
1425
|
-
data = {
|
|
1426
|
-
type: ComponentType.BUTTON
|
|
1427
|
-
};
|
|
1428
|
-
setCustomId(id) {
|
|
1429
|
-
this.data.customId = id;
|
|
1430
|
-
return this;
|
|
1431
|
-
}
|
|
1432
|
-
setLabel(label) {
|
|
1433
|
-
this.data.label = label;
|
|
1434
|
-
return this;
|
|
1435
|
-
}
|
|
1436
|
-
setStyle(style) {
|
|
1437
|
-
this.data.style = style;
|
|
1438
|
-
return this;
|
|
1439
|
-
}
|
|
1440
|
-
setEmoji(emoji) {
|
|
1441
|
-
this.data.emoji = emoji;
|
|
1442
|
-
return this;
|
|
1443
|
-
}
|
|
1444
|
-
setDisabled(disabled = true) {
|
|
1445
|
-
this.data.disabled = disabled;
|
|
1446
|
-
return this;
|
|
1447
|
-
}
|
|
1448
|
-
setURL(url) {
|
|
1449
|
-
this.data.url = url;
|
|
1450
|
-
this.data.style = ButtonStyle.LINK;
|
|
1451
|
-
return this;
|
|
1452
|
-
}
|
|
1453
|
-
build() {
|
|
1454
|
-
return {
|
|
1455
|
-
...this.data
|
|
1456
|
-
};
|
|
1457
|
-
}
|
|
1458
|
-
toJSON() {
|
|
1459
|
-
return {
|
|
1460
|
-
type: ComponentType.BUTTON,
|
|
1461
|
-
custom_id: this.data.customId,
|
|
1462
|
-
label: this.data.label,
|
|
1463
|
-
style: this.data.style,
|
|
1464
|
-
disabled: this.data.disabled,
|
|
1465
|
-
url: this.data.url,
|
|
1466
|
-
emoji: serializeEmoji(this.data.emoji)
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
|
-
var SelectMenuBuilder = class {
|
|
1471
|
-
data = {
|
|
1472
|
-
type: ComponentType.STRING_SELECT
|
|
1473
|
-
};
|
|
1474
|
-
setCustomId(id) {
|
|
1475
|
-
this.data.customId = id;
|
|
1476
|
-
return this;
|
|
1477
|
-
}
|
|
1478
|
-
setPlaceholder(placeholder) {
|
|
1479
|
-
this.data.placeholder = placeholder;
|
|
1480
|
-
return this;
|
|
1481
|
-
}
|
|
1482
|
-
setMinValues(min) {
|
|
1483
|
-
this.data.minValues = min;
|
|
1484
|
-
return this;
|
|
1485
|
-
}
|
|
1486
|
-
setMaxValues(max) {
|
|
1487
|
-
this.data.maxValues = max;
|
|
1488
|
-
return this;
|
|
1489
|
-
}
|
|
1490
|
-
setDisabled(disabled = true) {
|
|
1491
|
-
this.data.disabled = disabled;
|
|
1492
|
-
return this;
|
|
1493
|
-
}
|
|
1494
|
-
setType(type) {
|
|
1495
|
-
this.data.type = type;
|
|
1496
|
-
return this;
|
|
1497
|
-
}
|
|
1498
|
-
addOption(option) {
|
|
1499
|
-
if (!this.data.options) {
|
|
1500
|
-
this.data.options = [];
|
|
1501
|
-
}
|
|
1502
|
-
this.data.options.push(option);
|
|
1503
|
-
return this;
|
|
1504
|
-
}
|
|
1505
|
-
addOptions(...options) {
|
|
1506
|
-
if (!this.data.options) {
|
|
1507
|
-
this.data.options = [];
|
|
1508
|
-
}
|
|
1509
|
-
this.data.options.push(...options);
|
|
1510
|
-
return this;
|
|
1511
|
-
}
|
|
1512
|
-
build() {
|
|
1513
|
-
return {
|
|
1514
|
-
...this.data
|
|
1515
|
-
};
|
|
1516
|
-
}
|
|
1517
|
-
toJSON() {
|
|
1518
|
-
return {
|
|
1519
|
-
type: this.data.type ?? ComponentType.STRING_SELECT,
|
|
1520
|
-
custom_id: this.data.customId,
|
|
1521
|
-
placeholder: this.data.placeholder,
|
|
1522
|
-
min_values: this.data.minValues,
|
|
1523
|
-
max_values: this.data.maxValues,
|
|
1524
|
-
disabled: this.data.disabled,
|
|
1525
|
-
options: this.data.options?.map((option) => ({
|
|
1526
|
-
label: option.label,
|
|
1527
|
-
value: option.value,
|
|
1528
|
-
description: option.description,
|
|
1529
|
-
emoji: serializeEmoji(option.emoji),
|
|
1530
|
-
default: option.default
|
|
1531
|
-
}))
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
};
|
|
1535
|
-
var TextInputBuilder = class {
|
|
1536
|
-
data = {
|
|
1537
|
-
type: ComponentType.TEXT_INPUT
|
|
1538
|
-
};
|
|
1539
|
-
_minLength;
|
|
1540
|
-
_maxLength;
|
|
1541
|
-
_required;
|
|
1542
|
-
_value;
|
|
1543
|
-
setCustomId(id) {
|
|
1544
|
-
this.data.customId = id;
|
|
1545
|
-
return this;
|
|
1546
|
-
}
|
|
1547
|
-
setLabel(label) {
|
|
1548
|
-
this.data.label = label;
|
|
1549
|
-
return this;
|
|
1550
|
-
}
|
|
1551
|
-
setStyle(style) {
|
|
1552
|
-
this.data.style = style;
|
|
1553
|
-
return this;
|
|
1554
|
-
}
|
|
1555
|
-
setPlaceholder(placeholder) {
|
|
1556
|
-
this.data.placeholder = placeholder;
|
|
1557
|
-
return this;
|
|
1558
|
-
}
|
|
1559
|
-
setMinLength(length) {
|
|
1560
|
-
this._minLength = length;
|
|
1561
|
-
return this;
|
|
1562
|
-
}
|
|
1563
|
-
setMaxLength(length) {
|
|
1564
|
-
this._maxLength = length;
|
|
1565
|
-
return this;
|
|
1566
|
-
}
|
|
1567
|
-
setRequired(required = true) {
|
|
1568
|
-
this._required = required;
|
|
1569
|
-
return this;
|
|
1570
|
-
}
|
|
1571
|
-
setValue(value) {
|
|
1572
|
-
this._value = value;
|
|
1573
|
-
return this;
|
|
1574
|
-
}
|
|
1575
|
-
build() {
|
|
1576
|
-
return {
|
|
1577
|
-
...this.data,
|
|
1578
|
-
minLength: this._minLength,
|
|
1579
|
-
maxLength: this._maxLength,
|
|
1580
|
-
required: this._required,
|
|
1581
|
-
value: this._value
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
|
-
toJSON() {
|
|
1585
|
-
return {
|
|
1586
|
-
type: ComponentType.TEXT_INPUT,
|
|
1587
|
-
custom_id: this.data.customId,
|
|
1588
|
-
style: this.data.style,
|
|
1589
|
-
label: this.data.label,
|
|
1590
|
-
placeholder: this.data.placeholder,
|
|
1591
|
-
min_length: this._minLength,
|
|
1592
|
-
max_length: this._maxLength,
|
|
1593
|
-
required: this._required,
|
|
1594
|
-
value: this._value
|
|
1595
|
-
};
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
var ActionRowBuilder = class {
|
|
1599
|
-
data = {
|
|
1600
|
-
type: ComponentType.ACTION_ROW,
|
|
1601
|
-
components: []
|
|
1602
|
-
};
|
|
1603
|
-
addComponent(component) {
|
|
1604
|
-
this.data.components.push(component);
|
|
1605
|
-
return this;
|
|
1606
|
-
}
|
|
1607
|
-
addComponents(...components) {
|
|
1608
|
-
for (const component of components) {
|
|
1609
|
-
this.addComponent(component);
|
|
1610
|
-
}
|
|
1611
|
-
return this;
|
|
1612
|
-
}
|
|
1613
|
-
build() {
|
|
1614
|
-
return {
|
|
1615
|
-
...this.data,
|
|
1616
|
-
components: [...this.data.components]
|
|
1617
|
-
};
|
|
1618
|
-
}
|
|
1619
|
-
toJSON() {
|
|
1620
|
-
return {
|
|
1621
|
-
type: ComponentType.ACTION_ROW,
|
|
1622
|
-
components: this.data.components?.map((component) => {
|
|
1623
|
-
if (component && typeof component.toJSON === "function") {
|
|
1624
|
-
return component.toJSON();
|
|
1625
|
-
}
|
|
1626
|
-
return component;
|
|
1627
|
-
})
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
};
|
|
1631
|
-
var ModalBuilder = class {
|
|
1632
|
-
_title = "";
|
|
1633
|
-
_customId = "";
|
|
1634
|
-
_components = [];
|
|
1635
|
-
setTitle(title) {
|
|
1636
|
-
this._title = title;
|
|
1637
|
-
return this;
|
|
1638
|
-
}
|
|
1639
|
-
setCustomId(id) {
|
|
1640
|
-
this._customId = id;
|
|
1641
|
-
return this;
|
|
1642
|
-
}
|
|
1643
|
-
addComponent(component) {
|
|
1644
|
-
this._components.push(component);
|
|
1645
|
-
return this;
|
|
1646
|
-
}
|
|
1647
|
-
addComponents(...components) {
|
|
1648
|
-
for (const component of components) {
|
|
1649
|
-
this.addComponent(component);
|
|
1650
|
-
}
|
|
1651
|
-
return this;
|
|
1652
|
-
}
|
|
1653
|
-
build() {
|
|
1654
|
-
return {
|
|
1655
|
-
title: this._title,
|
|
1656
|
-
custom_id: this._customId,
|
|
1657
|
-
components: [...this._components]
|
|
1658
|
-
};
|
|
1659
|
-
}
|
|
1660
|
-
toJSON() {
|
|
1661
|
-
return {
|
|
1662
|
-
title: this._title,
|
|
1663
|
-
custom_id: this._customId,
|
|
1664
|
-
components: this._components.map((component) => {
|
|
1665
|
-
if (component && typeof component.toJSON === "function") {
|
|
1666
|
-
return component.toJSON();
|
|
1667
|
-
}
|
|
1668
|
-
return component;
|
|
1669
|
-
})
|
|
1670
|
-
};
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
|
|
1674
|
-
// src/builders/index.ts
|
|
1675
|
-
function buildUser(raw) {
|
|
1676
|
-
return {
|
|
1677
|
-
id: raw.id,
|
|
1678
|
-
username: raw.username,
|
|
1679
|
-
discriminator: raw.discriminator,
|
|
1680
|
-
globalName: raw.global_name ?? null,
|
|
1681
|
-
avatar: raw.avatar ?? null,
|
|
1682
|
-
bot: raw.bot ?? false,
|
|
1683
|
-
system: raw.system ?? false,
|
|
1684
|
-
mfaEnabled: raw.mfa_enabled ?? false,
|
|
1685
|
-
banner: raw.banner ?? null,
|
|
1686
|
-
accentColor: raw.accent_color ?? null,
|
|
1687
|
-
locale: raw.locale ?? void 0,
|
|
1688
|
-
flags: raw.flags ?? 0,
|
|
1689
|
-
premiumType: raw.premium_type ?? 0,
|
|
1690
|
-
publicFlags: raw.public_flags ?? 0
|
|
1691
|
-
};
|
|
1692
|
-
}
|
|
1693
|
-
function buildChannel(raw, guildId) {
|
|
1694
|
-
return {
|
|
1695
|
-
id: raw.id,
|
|
1696
|
-
type: raw.type,
|
|
1697
|
-
guildId: raw.guild_id ?? guildId ?? void 0,
|
|
1698
|
-
name: raw.name ?? null,
|
|
1699
|
-
position: raw.position ?? 0,
|
|
1700
|
-
parentId: raw.parent_id ?? null,
|
|
1701
|
-
topic: raw.topic ?? null,
|
|
1702
|
-
nsfw: raw.nsfw ?? false,
|
|
1703
|
-
lastMessageId: raw.last_message_id ?? null,
|
|
1704
|
-
bitrate: raw.bitrate ?? void 0,
|
|
1705
|
-
userLimit: raw.user_limit ?? void 0,
|
|
1706
|
-
rateLimitPerUser: raw.rate_limit_per_user ?? 0,
|
|
1707
|
-
permissionOverwrites: raw.permission_overwrites ?? []
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
function buildGuild(raw) {
|
|
1711
|
-
return {
|
|
1712
|
-
id: raw.id,
|
|
1713
|
-
name: raw.name,
|
|
1714
|
-
icon: raw.icon ?? null,
|
|
1715
|
-
splash: raw.splash ?? null,
|
|
1716
|
-
discoverySplash: raw.discovery_splash ?? null,
|
|
1717
|
-
ownerId: raw.owner_id,
|
|
1718
|
-
afkChannelId: raw.afk_channel_id ?? null,
|
|
1719
|
-
afkTimeout: raw.afk_timeout ?? 0,
|
|
1720
|
-
verificationLevel: raw.verification_level ?? 0,
|
|
1721
|
-
defaultMessageNotifications: raw.default_message_notifications ?? 0,
|
|
1722
|
-
explicitContentFilter: raw.explicit_content_filter ?? 0,
|
|
1723
|
-
features: raw.features ?? [],
|
|
1724
|
-
mfaLevel: raw.mfa_level ?? 0,
|
|
1725
|
-
systemChannelId: raw.system_channel_id ?? null,
|
|
1726
|
-
systemChannelFlags: raw.system_channel_flags ?? 0,
|
|
1727
|
-
rulesChannelId: raw.rules_channel_id ?? null,
|
|
1728
|
-
memberCount: raw.member_count ?? 0,
|
|
1729
|
-
vanityUrlCode: raw.vanity_url_code ?? null,
|
|
1730
|
-
description: raw.description ?? null,
|
|
1731
|
-
banner: raw.banner ?? null,
|
|
1732
|
-
premiumTier: raw.premium_tier ?? 0,
|
|
1733
|
-
premiumSubscriptionCount: raw.premium_subscription_count ?? 0,
|
|
1734
|
-
preferredLocale: raw.preferred_locale ?? "en-US",
|
|
1735
|
-
publicUpdatesChannelId: raw.public_updates_channel_id ?? null,
|
|
1736
|
-
nsfwLevel: raw.nsfw_level ?? 0,
|
|
1737
|
-
premiumProgressBarEnabled: raw.premium_progress_bar_enabled ?? false,
|
|
1738
|
-
roles: Array.isArray(raw.roles) ? raw.roles.map((r) => buildRole(r)) : [],
|
|
1739
|
-
emojis: raw.emojis ?? [],
|
|
1740
|
-
applicationId: raw.application_id ?? null,
|
|
1741
|
-
large: raw.large ?? false
|
|
1742
|
-
};
|
|
1743
|
-
}
|
|
1744
|
-
function buildRole(raw) {
|
|
1745
|
-
return {
|
|
1746
|
-
id: raw.id,
|
|
1747
|
-
name: raw.name,
|
|
1748
|
-
color: raw.color ?? 0,
|
|
1749
|
-
hoist: raw.hoist ?? false,
|
|
1750
|
-
position: raw.position ?? 0,
|
|
1751
|
-
permissions: raw.permissions,
|
|
1752
|
-
managed: raw.managed ?? false,
|
|
1753
|
-
mentionable: raw.mentionable ?? false,
|
|
1754
|
-
icon: raw.icon ?? null,
|
|
1755
|
-
unicodeEmoji: raw.unicode_emoji ?? null,
|
|
1756
|
-
flags: raw.flags ?? 0
|
|
1757
|
-
};
|
|
1758
|
-
}
|
|
1759
|
-
function buildMember(raw, guildId, cache) {
|
|
1760
|
-
let userObj;
|
|
1761
|
-
if (raw.user) {
|
|
1762
|
-
const user = buildUser(raw.user);
|
|
1763
|
-
cache.users.set(user.id, user);
|
|
1764
|
-
userObj = user;
|
|
1765
|
-
}
|
|
1766
|
-
return {
|
|
1767
|
-
...userObj ? { user: userObj } : {},
|
|
1768
|
-
nick: raw.nick ?? null,
|
|
1769
|
-
avatar: raw.avatar ?? null,
|
|
1770
|
-
roles: raw.roles ?? [],
|
|
1771
|
-
joinedAt: raw.joined_at ? Date.parse(raw.joined_at) : 0,
|
|
1772
|
-
premiumSince: raw.premium_since ? Date.parse(raw.premium_since) : null,
|
|
1773
|
-
deaf: raw.deaf ?? false,
|
|
1774
|
-
mute: raw.mute ?? false,
|
|
1775
|
-
pending: raw.pending ?? false,
|
|
1776
|
-
flags: raw.flags ?? 0,
|
|
1777
|
-
communicationDisabledUntil: raw.communication_disabled_until ? Date.parse(raw.communication_disabled_until) : null
|
|
1778
|
-
};
|
|
1779
|
-
}
|
|
1780
|
-
function buildMessage(raw, cache, oldMessage) {
|
|
1781
|
-
const authorRaw = raw.author;
|
|
1782
|
-
const author = authorRaw ? buildUser(authorRaw) : oldMessage?.author ?? {};
|
|
1783
|
-
if (authorRaw && author.id) {
|
|
1784
|
-
cache.users.set(author.id, author);
|
|
1785
|
-
}
|
|
1786
|
-
const msgId = raw.id ?? oldMessage?.id;
|
|
1787
|
-
const channelId = raw.channel_id ?? oldMessage?.channelId;
|
|
1788
|
-
const guildId = raw.guild_id ? raw.guild_id : oldMessage?.guildId;
|
|
1789
|
-
const msg = {
|
|
1790
|
-
id: msgId,
|
|
1791
|
-
channelId,
|
|
1792
|
-
author,
|
|
1793
|
-
...guildId ? { guildId } : {},
|
|
1794
|
-
url: `https://discord.com/channels/${guildId ?? "@me"}/${channelId}/${msgId}`,
|
|
1795
|
-
content: raw.content ?? oldMessage?.content ?? "",
|
|
1796
|
-
timestamp: raw.timestamp ? Date.parse(raw.timestamp) : oldMessage?.timestamp ?? Date.now(),
|
|
1797
|
-
editedTimestamp: raw.edited_timestamp ? Date.parse(raw.edited_timestamp) : oldMessage?.editedTimestamp ?? null,
|
|
1798
|
-
tts: raw.tts ?? oldMessage?.tts ?? false,
|
|
1799
|
-
mentionEveryone: raw.mention_everyone ?? oldMessage?.mentionEveryone ?? false,
|
|
1800
|
-
mentions: raw.mentions ? raw.mentions.map((m) => buildUser(m)) : oldMessage?.mentions ?? [],
|
|
1801
|
-
mentionRoles: raw.mention_roles ?? oldMessage?.mentionRoles ?? [],
|
|
1802
|
-
attachments: raw.attachments ?? oldMessage?.attachments ?? [],
|
|
1803
|
-
embeds: raw.embeds ?? oldMessage?.embeds ?? [],
|
|
1804
|
-
pinned: raw.pinned ?? oldMessage?.pinned ?? false,
|
|
1805
|
-
type: raw.type ?? oldMessage?.type ?? 0
|
|
1806
|
-
};
|
|
1807
|
-
return msg;
|
|
1808
|
-
}
|
|
1809
|
-
function resolveChannel(channelId, cache) {
|
|
1810
|
-
return cache.channels.get(channelId) ?? { id: channelId };
|
|
1811
|
-
}
|
|
1812
|
-
function resolveGuild(guildId, cache) {
|
|
1813
|
-
return cache.guilds.get(guildId) ?? { id: guildId };
|
|
1814
|
-
}
|
|
1815
|
-
function resolveUser(userId, cache) {
|
|
1816
|
-
return cache.users.get(userId) ?? { id: userId };
|
|
1817
|
-
}
|
|
1818
|
-
function resolveRole(roleId, cache) {
|
|
1819
|
-
return cache.roles.get(roleId) ?? { id: roleId };
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
1307
|
// src/commands/options.ts
|
|
1823
1308
|
var opt = {
|
|
1824
1309
|
string: (description, options) => ({
|
|
@@ -1862,8 +1347,7 @@ var opt = {
|
|
|
1862
1347
|
};
|
|
1863
1348
|
|
|
1864
1349
|
// src/commands/context.ts
|
|
1865
|
-
var
|
|
1866
|
-
options;
|
|
1350
|
+
var BaseInteractionContext = class {
|
|
1867
1351
|
user;
|
|
1868
1352
|
guild;
|
|
1869
1353
|
channel;
|
|
@@ -1872,11 +1356,10 @@ var CommandContext = class {
|
|
|
1872
1356
|
_client;
|
|
1873
1357
|
_deferred = false;
|
|
1874
1358
|
_replied = false;
|
|
1875
|
-
constructor(client,
|
|
1359
|
+
constructor(client, raw, user, guild, channel) {
|
|
1876
1360
|
this._client = client;
|
|
1877
|
-
this.interactionId =
|
|
1878
|
-
this.interactionToken =
|
|
1879
|
-
this.options = parsedOptions;
|
|
1361
|
+
this.interactionId = raw.id;
|
|
1362
|
+
this.interactionToken = raw.token;
|
|
1880
1363
|
this.user = user;
|
|
1881
1364
|
this.guild = guild;
|
|
1882
1365
|
this.channel = channel;
|
|
@@ -1887,10 +1370,27 @@ var CommandContext = class {
|
|
|
1887
1370
|
get deferred() {
|
|
1888
1371
|
return this._deferred;
|
|
1889
1372
|
}
|
|
1373
|
+
_resolvePayload(payload) {
|
|
1374
|
+
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
1375
|
+
if (typeof payload === "object") {
|
|
1376
|
+
if (payload.ephemeral) data.flags = MESSAGE_FLAGS.EPHEMERAL;
|
|
1377
|
+
if (payload.embeds) {
|
|
1378
|
+
data.embeds = payload.embeds.map((e) => {
|
|
1379
|
+
if (e && typeof e.toJSON === "function") {
|
|
1380
|
+
return e.toJSON();
|
|
1381
|
+
}
|
|
1382
|
+
return e;
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
if (payload.components) {
|
|
1386
|
+
data.components = payload.components.map((c) => serializeComponent(c));
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return data;
|
|
1390
|
+
}
|
|
1890
1391
|
async reply(payload) {
|
|
1891
1392
|
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
1892
|
-
const data =
|
|
1893
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
1393
|
+
const data = this._resolvePayload(payload);
|
|
1894
1394
|
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
1895
1395
|
type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
1896
1396
|
data
|
|
@@ -1901,16 +1401,13 @@ var CommandContext = class {
|
|
|
1901
1401
|
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
1902
1402
|
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
1903
1403
|
type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
1904
|
-
data: {
|
|
1905
|
-
flags: options?.ephemeral ? 64 : 0
|
|
1906
|
-
}
|
|
1404
|
+
data: { flags: options?.ephemeral ? MESSAGE_FLAGS.EPHEMERAL : 0 }
|
|
1907
1405
|
});
|
|
1908
1406
|
this._deferred = true;
|
|
1909
1407
|
}
|
|
1910
1408
|
async followUp(payload) {
|
|
1911
|
-
if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.
|
|
1912
|
-
const data =
|
|
1913
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
1409
|
+
if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
|
|
1410
|
+
const data = this._resolvePayload(payload);
|
|
1914
1411
|
await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
|
|
1915
1412
|
}
|
|
1916
1413
|
async showModal(modal) {
|
|
@@ -1918,13 +1415,12 @@ var CommandContext = class {
|
|
|
1918
1415
|
const payload = modal.type === "modal" ? {
|
|
1919
1416
|
custom_id: modal.customId,
|
|
1920
1417
|
title: modal.title,
|
|
1921
|
-
components: modal.fields.map((f) => ({
|
|
1418
|
+
components: Array.isArray(modal.fields) ? modal.fields.map((f) => ({
|
|
1922
1419
|
type: 1 /* ACTION_ROW */,
|
|
1923
1420
|
components: [{
|
|
1924
1421
|
type: 4 /* TEXT_INPUT */,
|
|
1925
1422
|
custom_id: f.id,
|
|
1926
1423
|
style: f.type,
|
|
1927
|
-
// 1 short, 2 paragraph
|
|
1928
1424
|
label: f.label,
|
|
1929
1425
|
required: f.required,
|
|
1930
1426
|
min_length: f.minLength,
|
|
@@ -1932,7 +1428,7 @@ var CommandContext = class {
|
|
|
1932
1428
|
placeholder: f.placeholder,
|
|
1933
1429
|
value: f.value
|
|
1934
1430
|
}]
|
|
1935
|
-
}))
|
|
1431
|
+
})) : []
|
|
1936
1432
|
} : modal;
|
|
1937
1433
|
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
1938
1434
|
type: 9 /* MODAL */,
|
|
@@ -1941,6 +1437,13 @@ var CommandContext = class {
|
|
|
1941
1437
|
this._replied = true;
|
|
1942
1438
|
}
|
|
1943
1439
|
};
|
|
1440
|
+
var CommandContext = class extends BaseInteractionContext {
|
|
1441
|
+
options;
|
|
1442
|
+
constructor(client, rawInteraction, parsedOptions, user, guild, channel) {
|
|
1443
|
+
super(client, rawInteraction, user, guild, channel);
|
|
1444
|
+
this.options = parsedOptions;
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1944
1447
|
|
|
1945
1448
|
// src/commands/command.ts
|
|
1946
1449
|
function defineSubcommand(def) {
|
|
@@ -1954,46 +1457,55 @@ function defineCommand(def) {
|
|
|
1954
1457
|
}
|
|
1955
1458
|
|
|
1956
1459
|
// src/commands/interactions.ts
|
|
1957
|
-
var
|
|
1460
|
+
var ModalContext = class extends BaseInteractionContext {
|
|
1958
1461
|
customId;
|
|
1959
|
-
|
|
1960
|
-
guild;
|
|
1961
|
-
channel;
|
|
1962
|
-
message;
|
|
1963
|
-
interactionId;
|
|
1964
|
-
interactionToken;
|
|
1965
|
-
_client;
|
|
1966
|
-
_deferred = false;
|
|
1967
|
-
_replied = false;
|
|
1462
|
+
_fields = /* @__PURE__ */ new Map();
|
|
1968
1463
|
constructor(client, raw, user, guild, channel) {
|
|
1969
|
-
|
|
1970
|
-
this.interactionId = raw.id;
|
|
1971
|
-
this.interactionToken = raw.token;
|
|
1464
|
+
super(client, raw, user, guild, channel);
|
|
1972
1465
|
this.customId = raw.data?.custom_id ?? "";
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
get deferred() {
|
|
1982
|
-
return this._deferred;
|
|
1466
|
+
const rows = raw.data?.components ?? [];
|
|
1467
|
+
for (const row of rows) {
|
|
1468
|
+
for (const comp of row.components ?? []) {
|
|
1469
|
+
if (comp.custom_id && comp.value !== void 0) {
|
|
1470
|
+
this._fields.set(comp.custom_id, comp.value);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1983
1474
|
}
|
|
1984
|
-
|
|
1475
|
+
// Get a text input value by its customId
|
|
1476
|
+
// values from a select menu interaction
|
|
1985
1477
|
get values() {
|
|
1986
1478
|
return this._values ?? [];
|
|
1987
1479
|
}
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1480
|
+
// Get all field values as a plain object
|
|
1481
|
+
get fields() {
|
|
1482
|
+
return Object.fromEntries(this._fields);
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
// src/components/context.ts
|
|
1487
|
+
var ComponentContext = class extends BaseInteractionContext {
|
|
1488
|
+
customId;
|
|
1489
|
+
message;
|
|
1490
|
+
values;
|
|
1491
|
+
fields;
|
|
1492
|
+
constructor(client, raw, user, guild, channel) {
|
|
1493
|
+
super(client, raw, user, guild, channel);
|
|
1494
|
+
const data = raw.data;
|
|
1495
|
+
this.customId = data?.custom_id ?? "";
|
|
1496
|
+
if (raw.message) {
|
|
1497
|
+
this.message = raw.message;
|
|
1498
|
+
}
|
|
1499
|
+
this.values = data?.values ?? [];
|
|
1500
|
+
const fields = {};
|
|
1501
|
+
if (data?.components) {
|
|
1502
|
+
for (const row of data.components) {
|
|
1503
|
+
for (const comp of row.components) {
|
|
1504
|
+
fields[comp.custom_id] = comp.value;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
this.fields = fields;
|
|
1997
1509
|
}
|
|
1998
1510
|
async deferUpdate() {
|
|
1999
1511
|
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
@@ -2004,87 +1516,13 @@ var ComponentContext = class {
|
|
|
2004
1516
|
}
|
|
2005
1517
|
async update(payload) {
|
|
2006
1518
|
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2007
|
-
const data =
|
|
2008
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
1519
|
+
const data = this._resolvePayload(payload);
|
|
2009
1520
|
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2010
1521
|
type: 7 /* UPDATE_MESSAGE */,
|
|
2011
1522
|
data
|
|
2012
1523
|
});
|
|
2013
1524
|
this._replied = true;
|
|
2014
1525
|
}
|
|
2015
|
-
async followUp(payload) {
|
|
2016
|
-
if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
|
|
2017
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2018
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
2019
|
-
await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
|
|
2020
|
-
}
|
|
2021
|
-
};
|
|
2022
|
-
var ModalContext = class {
|
|
2023
|
-
customId;
|
|
2024
|
-
user;
|
|
2025
|
-
guild;
|
|
2026
|
-
channel;
|
|
2027
|
-
interactionId;
|
|
2028
|
-
interactionToken;
|
|
2029
|
-
_fields = /* @__PURE__ */ new Map();
|
|
2030
|
-
_client;
|
|
2031
|
-
_replied = false;
|
|
2032
|
-
_deferred = false;
|
|
2033
|
-
constructor(client, raw, user, guild, channel) {
|
|
2034
|
-
this._client = client;
|
|
2035
|
-
this.interactionId = raw.id;
|
|
2036
|
-
this.interactionToken = raw.token;
|
|
2037
|
-
this.customId = raw.data?.custom_id ?? "";
|
|
2038
|
-
this.user = user;
|
|
2039
|
-
this.guild = guild;
|
|
2040
|
-
this.channel = channel;
|
|
2041
|
-
const rows = raw.data?.components ?? [];
|
|
2042
|
-
for (const row of rows) {
|
|
2043
|
-
for (const comp of row.components ?? []) {
|
|
2044
|
-
if (comp.custom_id && comp.value !== void 0) {
|
|
2045
|
-
this._fields.set(comp.custom_id, comp.value);
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
get replied() {
|
|
2051
|
-
return this._replied;
|
|
2052
|
-
}
|
|
2053
|
-
get deferred() {
|
|
2054
|
-
return this._deferred;
|
|
2055
|
-
}
|
|
2056
|
-
/** Get a text input value by its customId */
|
|
2057
|
-
getField(customId) {
|
|
2058
|
-
return this._fields.get(customId);
|
|
2059
|
-
}
|
|
2060
|
-
/** Get all field values as a plain object */
|
|
2061
|
-
get fields() {
|
|
2062
|
-
return Object.fromEntries(this._fields);
|
|
2063
|
-
}
|
|
2064
|
-
async reply(payload) {
|
|
2065
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2066
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2067
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
2068
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2069
|
-
type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
2070
|
-
data
|
|
2071
|
-
});
|
|
2072
|
-
this._replied = true;
|
|
2073
|
-
}
|
|
2074
|
-
async defer(options) {
|
|
2075
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2076
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2077
|
-
type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
2078
|
-
data: { flags: options?.ephemeral ? 64 : 0 }
|
|
2079
|
-
});
|
|
2080
|
-
this._deferred = true;
|
|
2081
|
-
}
|
|
2082
|
-
async followUp(payload) {
|
|
2083
|
-
if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
|
|
2084
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2085
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
2086
|
-
await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
|
|
2087
|
-
}
|
|
2088
1526
|
};
|
|
2089
1527
|
|
|
2090
1528
|
// src/commands/manager.ts
|
|
@@ -2167,11 +1605,11 @@ var CommandManager = class {
|
|
|
2167
1605
|
};
|
|
2168
1606
|
const options = [];
|
|
2169
1607
|
if (cmd.subcommands) {
|
|
2170
|
-
for (const [subName,
|
|
2171
|
-
const subDef = subDefRaw;
|
|
1608
|
+
for (const [subName, subDef] of Object.entries(cmd.subcommands)) {
|
|
2172
1609
|
const subOpts = [];
|
|
2173
1610
|
if (subDef.options) {
|
|
2174
|
-
for (const [optName,
|
|
1611
|
+
for (const [optName, optDefRaw] of Object.entries(subDef.options)) {
|
|
1612
|
+
const optDef = optDefRaw;
|
|
2175
1613
|
subOpts.push({
|
|
2176
1614
|
type: mapType(optDef.type),
|
|
2177
1615
|
name: optName,
|
|
@@ -2191,7 +1629,8 @@ var CommandManager = class {
|
|
|
2191
1629
|
});
|
|
2192
1630
|
}
|
|
2193
1631
|
} else if (cmd.options) {
|
|
2194
|
-
for (const [optName,
|
|
1632
|
+
for (const [optName, optDefRaw] of Object.entries(cmd.options)) {
|
|
1633
|
+
const optDef = optDefRaw;
|
|
2195
1634
|
options.push({
|
|
2196
1635
|
type: mapType(optDef.type),
|
|
2197
1636
|
name: optName,
|
|
@@ -2210,15 +1649,18 @@ var CommandManager = class {
|
|
|
2210
1649
|
};
|
|
2211
1650
|
}
|
|
2212
1651
|
async handleInteraction(raw) {
|
|
2213
|
-
|
|
2214
|
-
if (
|
|
1652
|
+
const data = raw.data;
|
|
1653
|
+
if (!data) return;
|
|
1654
|
+
if (raw.type === 3 /* MESSAGE_COMPONENT */) return this._handleComponentInteraction(raw, data);
|
|
1655
|
+
if (raw.type === 5 /* MODAL_SUBMIT */) return this._handleModalInteraction(raw, data);
|
|
2215
1656
|
if (raw.type !== 2 /* APPLICATION_COMMAND */) return;
|
|
2216
|
-
const name =
|
|
1657
|
+
const name = data.name;
|
|
1658
|
+
if (!name) return;
|
|
2217
1659
|
const command = this._commands.get(name);
|
|
2218
1660
|
if (!command) return;
|
|
2219
1661
|
const parsedOptions = {};
|
|
2220
1662
|
let targetExecute = command.execute;
|
|
2221
|
-
const rawOptions =
|
|
1663
|
+
const rawOptions = data.options || [];
|
|
2222
1664
|
let actualOptions = rawOptions;
|
|
2223
1665
|
if (rawOptions.length > 0 && rawOptions[0].type === 1 /* SUB_COMMAND */) {
|
|
2224
1666
|
const subcommandName = rawOptions[0].name;
|
|
@@ -2228,26 +1670,26 @@ var CommandManager = class {
|
|
|
2228
1670
|
}
|
|
2229
1671
|
}
|
|
2230
1672
|
for (const opt2 of actualOptions) {
|
|
2231
|
-
if (opt2.type === 6 /* USER */ &&
|
|
2232
|
-
parsedOptions[opt2.name] = resolveUser(opt2.value, this._client
|
|
2233
|
-
} else if (opt2.type === 7 /* CHANNEL */ &&
|
|
2234
|
-
parsedOptions[opt2.name] = resolveChannel(opt2.value, this._client
|
|
2235
|
-
} else if (opt2.type === 8 /* ROLE */ &&
|
|
2236
|
-
parsedOptions[opt2.name] = resolveRole(opt2.value, this._client.
|
|
1673
|
+
if (opt2.type === 6 /* USER */ && data.resolved?.users?.[opt2.value]) {
|
|
1674
|
+
parsedOptions[opt2.name] = resolveUser(opt2.value, this._client);
|
|
1675
|
+
} else if (opt2.type === 7 /* CHANNEL */ && data.resolved?.channels?.[opt2.value]) {
|
|
1676
|
+
parsedOptions[opt2.name] = resolveChannel(opt2.value, this._client);
|
|
1677
|
+
} else if (opt2.type === 8 /* ROLE */ && data.resolved?.roles?.[opt2.value]) {
|
|
1678
|
+
parsedOptions[opt2.name] = resolveRole(opt2.value, this._client, raw.guild_id);
|
|
2237
1679
|
} else {
|
|
2238
1680
|
parsedOptions[opt2.name] = opt2.value;
|
|
2239
1681
|
}
|
|
2240
1682
|
}
|
|
2241
|
-
const member = raw.member
|
|
2242
|
-
const userRaw = member
|
|
1683
|
+
const member = raw.member;
|
|
1684
|
+
const userRaw = member?.user ?? raw.user;
|
|
2243
1685
|
const user = buildUser(userRaw);
|
|
2244
1686
|
const ctx = new CommandContext(
|
|
2245
1687
|
this._client,
|
|
2246
1688
|
raw,
|
|
2247
1689
|
parsedOptions,
|
|
2248
1690
|
user,
|
|
2249
|
-
raw.guild_id ? resolveGuild(raw.guild_id, this._client
|
|
2250
|
-
raw.channel_id ? resolveChannel(raw.channel_id, this._client
|
|
1691
|
+
raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
|
|
1692
|
+
raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
|
|
2251
1693
|
);
|
|
2252
1694
|
if (targetExecute) {
|
|
2253
1695
|
try {
|
|
@@ -2257,164 +1699,53 @@ var CommandManager = class {
|
|
|
2257
1699
|
}
|
|
2258
1700
|
}
|
|
2259
1701
|
}
|
|
2260
|
-
async _handleComponentInteraction(raw) {
|
|
2261
|
-
const customId =
|
|
2262
|
-
const handler = this._components.find(
|
|
2263
|
-
(h
|
|
2264
|
-
|
|
1702
|
+
async _handleComponentInteraction(raw, data) {
|
|
1703
|
+
const customId = data.custom_id;
|
|
1704
|
+
const handler = this._components.find((h) => {
|
|
1705
|
+
if (!h.customId) return false;
|
|
1706
|
+
return typeof h.customId === "string" ? h.customId === customId : h.customId.test(customId);
|
|
1707
|
+
});
|
|
2265
1708
|
if (!handler) return;
|
|
2266
|
-
const
|
|
1709
|
+
const member = raw.member;
|
|
1710
|
+
const userRaw = member?.user ?? raw.user;
|
|
2267
1711
|
const user = buildUser(userRaw);
|
|
2268
1712
|
const ctx = new ComponentContext(
|
|
2269
1713
|
this._client,
|
|
2270
1714
|
raw,
|
|
2271
1715
|
user,
|
|
2272
|
-
raw.guild_id ? resolveGuild(raw.guild_id, this._client
|
|
2273
|
-
raw.channel_id ? resolveChannel(raw.channel_id, this._client
|
|
1716
|
+
raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
|
|
1717
|
+
raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
|
|
2274
1718
|
);
|
|
2275
|
-
if (raw.data.component_type === 3 /* STRING_SELECT */ || raw.data.component_type === 5 /* USER_SELECT */ || raw.data.component_type === 6 /* ROLE_SELECT */ || raw.data.component_type === 7 /* MENTIONABLE_SELECT */ || raw.data.component_type === 8 /* CHANNEL_SELECT */) {
|
|
2276
|
-
ctx._values = raw.data.values || [];
|
|
2277
|
-
}
|
|
2278
1719
|
try {
|
|
2279
|
-
await handler.execute(ctx);
|
|
1720
|
+
await handler.execute?.(ctx);
|
|
2280
1721
|
} catch (err) {
|
|
2281
1722
|
console.error(`[Chameleon] Error executing component ${customId}:`, err);
|
|
2282
1723
|
}
|
|
2283
1724
|
}
|
|
2284
|
-
async _handleModalInteraction(raw) {
|
|
2285
|
-
const customId =
|
|
1725
|
+
async _handleModalInteraction(raw, data) {
|
|
1726
|
+
const customId = data.custom_id;
|
|
2286
1727
|
const handler = this._modals.find(
|
|
2287
1728
|
(h) => typeof h.customId === "string" ? h.customId === customId : h.customId.test(customId)
|
|
2288
1729
|
);
|
|
2289
1730
|
if (!handler) return;
|
|
2290
|
-
const
|
|
1731
|
+
const member = raw.member;
|
|
1732
|
+
const userRaw = member?.user ?? raw.user;
|
|
2291
1733
|
const user = buildUser(userRaw);
|
|
2292
1734
|
const ctx = new ModalContext(
|
|
2293
1735
|
this._client,
|
|
2294
1736
|
raw,
|
|
2295
1737
|
user,
|
|
2296
|
-
raw.guild_id ? resolveGuild(raw.guild_id, this._client
|
|
2297
|
-
raw.channel_id ? resolveChannel(raw.channel_id, this._client
|
|
1738
|
+
raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
|
|
1739
|
+
raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
|
|
2298
1740
|
);
|
|
2299
1741
|
try {
|
|
2300
|
-
await handler.execute(ctx);
|
|
1742
|
+
await handler.execute?.(ctx);
|
|
2301
1743
|
} catch (err) {
|
|
2302
1744
|
console.error(`[Chameleon] Error executing modal ${customId}:`, err);
|
|
2303
1745
|
}
|
|
2304
1746
|
}
|
|
2305
1747
|
};
|
|
2306
1748
|
|
|
2307
|
-
// src/components/context.ts
|
|
2308
|
-
var ComponentContext2 = class {
|
|
2309
|
-
user;
|
|
2310
|
-
guild;
|
|
2311
|
-
channel;
|
|
2312
|
-
interactionId;
|
|
2313
|
-
interactionToken;
|
|
2314
|
-
customId;
|
|
2315
|
-
values;
|
|
2316
|
-
fields;
|
|
2317
|
-
_client;
|
|
2318
|
-
_deferred = false;
|
|
2319
|
-
_replied = false;
|
|
2320
|
-
constructor(client, rawInteraction, user, guild, channel) {
|
|
2321
|
-
this._client = client;
|
|
2322
|
-
this.interactionId = rawInteraction.id;
|
|
2323
|
-
this.interactionToken = rawInteraction.token;
|
|
2324
|
-
this.customId = rawInteraction.data?.custom_id;
|
|
2325
|
-
this.user = user;
|
|
2326
|
-
this.guild = guild;
|
|
2327
|
-
this.channel = channel;
|
|
2328
|
-
this.values = rawInteraction.data?.values ?? [];
|
|
2329
|
-
const fields = {};
|
|
2330
|
-
if (rawInteraction.data?.components) {
|
|
2331
|
-
for (const row of rawInteraction.data.components) {
|
|
2332
|
-
for (const comp of row.components) {
|
|
2333
|
-
fields[comp.custom_id] = comp.value;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
this.fields = fields;
|
|
2338
|
-
}
|
|
2339
|
-
get replied() {
|
|
2340
|
-
return this._replied;
|
|
2341
|
-
}
|
|
2342
|
-
get deferred() {
|
|
2343
|
-
return this._deferred;
|
|
2344
|
-
}
|
|
2345
|
-
async reply(payload) {
|
|
2346
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2347
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2348
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
2349
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2350
|
-
type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
2351
|
-
data
|
|
2352
|
-
});
|
|
2353
|
-
this._replied = true;
|
|
2354
|
-
}
|
|
2355
|
-
async defer(options) {
|
|
2356
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2357
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2358
|
-
type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
|
|
2359
|
-
data: {
|
|
2360
|
-
flags: options?.ephemeral ? 64 : 0
|
|
2361
|
-
}
|
|
2362
|
-
});
|
|
2363
|
-
this._deferred = true;
|
|
2364
|
-
}
|
|
2365
|
-
async update(payload) {
|
|
2366
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2367
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2368
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2369
|
-
type: 7 /* UPDATE_MESSAGE */,
|
|
2370
|
-
data
|
|
2371
|
-
});
|
|
2372
|
-
this._replied = true;
|
|
2373
|
-
}
|
|
2374
|
-
async deferUpdate() {
|
|
2375
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2376
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2377
|
-
type: 6 /* DEFERRED_UPDATE_MESSAGE */
|
|
2378
|
-
});
|
|
2379
|
-
this._deferred = true;
|
|
2380
|
-
}
|
|
2381
|
-
async followUp(payload) {
|
|
2382
|
-
if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged. Use reply or defer first.");
|
|
2383
|
-
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2384
|
-
if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
|
|
2385
|
-
await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
|
|
2386
|
-
}
|
|
2387
|
-
async showModal(modal) {
|
|
2388
|
-
if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
|
|
2389
|
-
await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
|
|
2390
|
-
type: 9 /* MODAL */,
|
|
2391
|
-
data: modal.type === "modal" ? buildModalPayload(modal) : modal
|
|
2392
|
-
});
|
|
2393
|
-
this._replied = true;
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
function buildModalPayload(def) {
|
|
2397
|
-
return {
|
|
2398
|
-
custom_id: def.customId,
|
|
2399
|
-
title: def.title,
|
|
2400
|
-
components: def.fields.map((f) => ({
|
|
2401
|
-
type: 1 /* ACTION_ROW */,
|
|
2402
|
-
components: [{
|
|
2403
|
-
type: 4 /* TEXT_INPUT */,
|
|
2404
|
-
custom_id: f.id,
|
|
2405
|
-
style: f.type,
|
|
2406
|
-
// 1 short, 2 paragraph
|
|
2407
|
-
label: f.label,
|
|
2408
|
-
required: f.required,
|
|
2409
|
-
min_length: f.minLength,
|
|
2410
|
-
max_length: f.maxLength,
|
|
2411
|
-
placeholder: f.placeholder,
|
|
2412
|
-
value: f.value
|
|
2413
|
-
}]
|
|
2414
|
-
}))
|
|
2415
|
-
};
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
1749
|
// src/components/define.ts
|
|
2419
1750
|
function resolveButtonStyle(style) {
|
|
2420
1751
|
if (typeof style === "number") return style;
|
|
@@ -2465,52 +1796,59 @@ var ActionRow = {
|
|
|
2465
1796
|
return {
|
|
2466
1797
|
type: 1 /* ACTION_ROW */,
|
|
2467
1798
|
components: components.map((c) => {
|
|
2468
|
-
if (c.type === "button") {
|
|
1799
|
+
if ("type" in c && c.type === "button") {
|
|
1800
|
+
const btn = c;
|
|
2469
1801
|
return {
|
|
2470
1802
|
type: 2 /* BUTTON */,
|
|
2471
|
-
custom_id:
|
|
2472
|
-
url:
|
|
2473
|
-
label:
|
|
2474
|
-
style: resolveButtonStyle(
|
|
2475
|
-
disabled:
|
|
2476
|
-
emoji:
|
|
2477
|
-
sku_id:
|
|
1803
|
+
custom_id: btn.customId,
|
|
1804
|
+
url: btn.url,
|
|
1805
|
+
label: btn.label,
|
|
1806
|
+
style: resolveButtonStyle(btn.style),
|
|
1807
|
+
disabled: btn.disabled,
|
|
1808
|
+
emoji: btn.emoji,
|
|
1809
|
+
sku_id: btn.skuId
|
|
2478
1810
|
};
|
|
2479
1811
|
}
|
|
2480
|
-
if (c.type === "string_select") {
|
|
1812
|
+
if ("type" in c && c.type === "string_select") {
|
|
1813
|
+
const sel = c;
|
|
2481
1814
|
return {
|
|
2482
1815
|
type: 3 /* STRING_SELECT */,
|
|
2483
|
-
custom_id:
|
|
2484
|
-
options:
|
|
2485
|
-
placeholder:
|
|
2486
|
-
min_values:
|
|
2487
|
-
max_values:
|
|
2488
|
-
disabled:
|
|
1816
|
+
custom_id: sel.customId,
|
|
1817
|
+
options: sel.options,
|
|
1818
|
+
placeholder: sel.placeholder,
|
|
1819
|
+
min_values: sel.minValues,
|
|
1820
|
+
max_values: sel.maxValues,
|
|
1821
|
+
disabled: sel.disabled
|
|
2489
1822
|
};
|
|
2490
1823
|
}
|
|
2491
|
-
if (c.type === "user_select") {
|
|
2492
|
-
|
|
1824
|
+
if ("type" in c && c.type === "user_select") {
|
|
1825
|
+
const sel = c;
|
|
1826
|
+
return { type: 5 /* USER_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
|
|
2493
1827
|
}
|
|
2494
|
-
if (c.type === "role_select") {
|
|
2495
|
-
|
|
1828
|
+
if ("type" in c && c.type === "role_select") {
|
|
1829
|
+
const sel = c;
|
|
1830
|
+
return { type: 6 /* ROLE_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
|
|
2496
1831
|
}
|
|
2497
|
-
if (c.type === "mentionable_select") {
|
|
2498
|
-
|
|
1832
|
+
if ("type" in c && c.type === "mentionable_select") {
|
|
1833
|
+
const sel = c;
|
|
1834
|
+
return { type: 7 /* MENTIONABLE_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
|
|
2499
1835
|
}
|
|
2500
|
-
if (c.type === "channel_select") {
|
|
2501
|
-
|
|
1836
|
+
if ("type" in c && c.type === "channel_select") {
|
|
1837
|
+
const sel = c;
|
|
1838
|
+
return { type: 8 /* CHANNEL_SELECT */, custom_id: sel.customId, channel_types: sel.channelTypes, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
|
|
2502
1839
|
}
|
|
2503
|
-
if (c.type === 1 /* SHORT */ || c.type === 2 /* PARAGRAPH */) {
|
|
1840
|
+
if ("type" in c && (c.type === 1 /* SHORT */ || c.type === 2 /* PARAGRAPH */)) {
|
|
1841
|
+
const field2 = c;
|
|
2504
1842
|
return {
|
|
2505
1843
|
type: 4 /* TEXT_INPUT */,
|
|
2506
|
-
custom_id:
|
|
2507
|
-
style:
|
|
2508
|
-
label:
|
|
2509
|
-
required:
|
|
2510
|
-
min_length:
|
|
2511
|
-
max_length:
|
|
2512
|
-
placeholder:
|
|
2513
|
-
value:
|
|
1844
|
+
custom_id: field2.id,
|
|
1845
|
+
style: field2.type,
|
|
1846
|
+
label: field2.label,
|
|
1847
|
+
required: field2.required,
|
|
1848
|
+
min_length: field2.minLength,
|
|
1849
|
+
max_length: field2.maxLength,
|
|
1850
|
+
placeholder: field2.placeholder,
|
|
1851
|
+
value: field2.value
|
|
2514
1852
|
};
|
|
2515
1853
|
}
|
|
2516
1854
|
return c;
|
|
@@ -2534,45 +1872,47 @@ var ComponentManager = class {
|
|
|
2534
1872
|
handlers = /* @__PURE__ */ new Map();
|
|
2535
1873
|
register(...components) {
|
|
2536
1874
|
for (const comp of components) {
|
|
2537
|
-
if (comp.customId) {
|
|
1875
|
+
if (comp.customId && typeof comp.customId === "string") {
|
|
2538
1876
|
this.handlers.set(comp.customId, comp);
|
|
2539
1877
|
}
|
|
2540
1878
|
}
|
|
2541
1879
|
}
|
|
2542
1880
|
async handleInteraction(raw) {
|
|
2543
1881
|
const data = raw.data;
|
|
1882
|
+
if (!data) return;
|
|
2544
1883
|
const customId = data.custom_id;
|
|
2545
1884
|
if (!customId) return;
|
|
2546
1885
|
const handler = this.handlers.get(customId);
|
|
2547
1886
|
if (!handler || !handler.execute) return;
|
|
2548
|
-
const
|
|
1887
|
+
const userRaw = raw.member?.user ?? raw.user;
|
|
1888
|
+
const user = buildUser(userRaw);
|
|
2549
1889
|
let guild;
|
|
2550
1890
|
if (raw.guild_id) {
|
|
2551
1891
|
guild = this.client.cache.guilds.get(raw.guild_id) ?? { id: raw.guild_id };
|
|
2552
1892
|
}
|
|
2553
1893
|
let channel;
|
|
2554
1894
|
if (raw.channel_id) {
|
|
2555
|
-
channel = resolveChannel(raw.channel_id, this.client
|
|
1895
|
+
channel = resolveChannel(raw.channel_id, this.client) ?? { id: raw.channel_id };
|
|
2556
1896
|
}
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
1897
|
+
const resolved = data.resolved;
|
|
1898
|
+
if (resolved?.members && resolved?.users && raw.guild_id) {
|
|
1899
|
+
for (const [id] of Object.entries(resolved.members)) {
|
|
1900
|
+
const userData = resolved.users[id];
|
|
2560
1901
|
if (userData) {
|
|
2561
|
-
const mergedMember = { ...memberData, user: userData };
|
|
2562
1902
|
const u = buildUser(userData);
|
|
2563
1903
|
this.client.cache.users.set(u.id, u);
|
|
2564
1904
|
}
|
|
2565
1905
|
}
|
|
2566
1906
|
}
|
|
2567
|
-
const ctx = new
|
|
2568
|
-
if (handler.type === "user_select" &&
|
|
1907
|
+
const ctx = new ComponentContext(this.client, raw, user, guild, channel);
|
|
1908
|
+
if (handler.type === "user_select" && resolved?.users) {
|
|
2569
1909
|
ctx.values = ctx.values.map((id) => {
|
|
2570
|
-
const uData =
|
|
1910
|
+
const uData = resolved.users[id];
|
|
2571
1911
|
return uData ? buildUser(uData) : { id };
|
|
2572
1912
|
});
|
|
2573
|
-
} else if (handler.type === "channel_select" &&
|
|
1913
|
+
} else if (handler.type === "channel_select" && resolved?.channels) {
|
|
2574
1914
|
ctx.values = ctx.values.map((id) => {
|
|
2575
|
-
const cData =
|
|
1915
|
+
const cData = resolved.channels[id];
|
|
2576
1916
|
return cData ? buildChannel(cData, raw.guild_id) : { id };
|
|
2577
1917
|
});
|
|
2578
1918
|
}
|
|
@@ -2614,6 +1954,106 @@ var UserManager = class extends BaseManager {
|
|
|
2614
1954
|
return `/users/${id}`;
|
|
2615
1955
|
}
|
|
2616
1956
|
build = buildUser;
|
|
1957
|
+
async createDM(userId) {
|
|
1958
|
+
const result = await this.rest.post("/users/@me/channels", { recipient_id: userId });
|
|
1959
|
+
if (!result.ok) return result;
|
|
1960
|
+
return { ok: true, data: (await import("./builders-CCZQJXF6.js")).buildChannel(result.data) };
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
|
|
1964
|
+
// src/managers/role.ts
|
|
1965
|
+
var RoleManager = class {
|
|
1966
|
+
constructor(rest, store, guildId) {
|
|
1967
|
+
this.rest = rest;
|
|
1968
|
+
this.store = store;
|
|
1969
|
+
this.guildId = guildId;
|
|
1970
|
+
}
|
|
1971
|
+
rest;
|
|
1972
|
+
store;
|
|
1973
|
+
guildId;
|
|
1974
|
+
async fetch(roleId, force = false) {
|
|
1975
|
+
if (!force) {
|
|
1976
|
+
const cached = this.store.roles.get(roleId);
|
|
1977
|
+
if (cached) return { ok: true, data: cached };
|
|
1978
|
+
}
|
|
1979
|
+
const result = await this.rest.get(`/guilds/${this.guildId}/roles`);
|
|
1980
|
+
if (!result.ok) return result;
|
|
1981
|
+
const roles = result.data.map((raw) => buildRole(raw));
|
|
1982
|
+
for (const r of roles) {
|
|
1983
|
+
this.store.roles.set(r.id, r);
|
|
1984
|
+
}
|
|
1985
|
+
const target = roles.find((r) => r.id === roleId);
|
|
1986
|
+
if (target) return { ok: true, data: target };
|
|
1987
|
+
return { ok: false, status: 404, message: "Role not found" };
|
|
1988
|
+
}
|
|
1989
|
+
async list() {
|
|
1990
|
+
const result = await this.rest.get(`/guilds/${this.guildId}/roles`);
|
|
1991
|
+
if (!result.ok) return result;
|
|
1992
|
+
const roles = result.data.map((raw) => buildRole(raw));
|
|
1993
|
+
for (const r of roles) {
|
|
1994
|
+
this.store.roles.set(r.id, r);
|
|
1995
|
+
}
|
|
1996
|
+
return { ok: true, data: roles };
|
|
1997
|
+
}
|
|
1998
|
+
async create(payload, reason) {
|
|
1999
|
+
const headers = {};
|
|
2000
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2001
|
+
const result = await this.rest.post(`/guilds/${this.guildId}/roles`, toSnakeCase(payload), headers);
|
|
2002
|
+
if (!result.ok) return result;
|
|
2003
|
+
const role = buildRole(result.data);
|
|
2004
|
+
this.store.roles.set(role.id, role);
|
|
2005
|
+
return { ok: true, data: role };
|
|
2006
|
+
}
|
|
2007
|
+
async edit(roleId, payload, reason) {
|
|
2008
|
+
const headers = {};
|
|
2009
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2010
|
+
const result = await this.rest.patch(`/guilds/${this.guildId}/roles/${roleId}`, toSnakeCase(payload), headers);
|
|
2011
|
+
if (!result.ok) return result;
|
|
2012
|
+
const role = buildRole(result.data);
|
|
2013
|
+
this.store.roles.set(role.id, role);
|
|
2014
|
+
return { ok: true, data: role };
|
|
2015
|
+
}
|
|
2016
|
+
async delete(roleId, reason) {
|
|
2017
|
+
const headers = {};
|
|
2018
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2019
|
+
const result = await this.rest.delete(`/guilds/${this.guildId}/roles/${roleId}`, headers);
|
|
2020
|
+
if (result.ok) this.store.roles.delete(roleId);
|
|
2021
|
+
return result;
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
|
|
2025
|
+
// src/managers/member.ts
|
|
2026
|
+
var MemberManager = class {
|
|
2027
|
+
constructor(rest, store, guildId) {
|
|
2028
|
+
this.rest = rest;
|
|
2029
|
+
this.store = store;
|
|
2030
|
+
this.guildId = guildId;
|
|
2031
|
+
}
|
|
2032
|
+
rest;
|
|
2033
|
+
store;
|
|
2034
|
+
guildId;
|
|
2035
|
+
async fetch(userId, force = false) {
|
|
2036
|
+
const cacheKey = TongueStore.memberKey(this.guildId, userId);
|
|
2037
|
+
if (!force) {
|
|
2038
|
+
const cached = this.store.members.get(cacheKey);
|
|
2039
|
+
if (cached) return { ok: true, data: cached };
|
|
2040
|
+
}
|
|
2041
|
+
const result = await this.rest.get(`/guilds/${this.guildId}/members/${userId}`);
|
|
2042
|
+
if (!result.ok) return result;
|
|
2043
|
+
const member = buildMember(result.data, this.guildId, this.store);
|
|
2044
|
+
this.store.members.set(cacheKey, member);
|
|
2045
|
+
return { ok: true, data: member };
|
|
2046
|
+
}
|
|
2047
|
+
async edit(userId, payload, reason) {
|
|
2048
|
+
const headers = {};
|
|
2049
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2050
|
+
const result = await this.rest.patch(`/guilds/${this.guildId}/members/${userId}`, toSnakeCase(payload), headers);
|
|
2051
|
+
if (!result.ok) return result;
|
|
2052
|
+
const cacheKey = TongueStore.memberKey(this.guildId, userId);
|
|
2053
|
+
const member = buildMember(result.data, this.guildId, this.store);
|
|
2054
|
+
this.store.members.set(cacheKey, member);
|
|
2055
|
+
return { ok: true, data: member };
|
|
2056
|
+
}
|
|
2617
2057
|
};
|
|
2618
2058
|
|
|
2619
2059
|
// src/managers/guild.ts
|
|
@@ -2623,6 +2063,12 @@ var GuildManager = class extends BaseManager {
|
|
|
2623
2063
|
return `/guilds/${id}`;
|
|
2624
2064
|
}
|
|
2625
2065
|
build = buildGuild;
|
|
2066
|
+
roles(guildId) {
|
|
2067
|
+
return new RoleManager(this.rest, this.store, guildId);
|
|
2068
|
+
}
|
|
2069
|
+
members(guildId) {
|
|
2070
|
+
return new MemberManager(this.rest, this.store, guildId);
|
|
2071
|
+
}
|
|
2626
2072
|
async fetchChannels(guildId) {
|
|
2627
2073
|
const result = await this.rest.get(`/guilds/${guildId}/channels`);
|
|
2628
2074
|
if (!result.ok) return result;
|
|
@@ -2655,6 +2101,20 @@ var GuildManager = class extends BaseManager {
|
|
|
2655
2101
|
}
|
|
2656
2102
|
return result;
|
|
2657
2103
|
}
|
|
2104
|
+
async edit(guildId, payload, reason) {
|
|
2105
|
+
const headers = {};
|
|
2106
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2107
|
+
const result = await this.rest.patch(this.endpoint(guildId), toSnakeCase(payload), headers);
|
|
2108
|
+
if (!result.ok) return result;
|
|
2109
|
+
const entity = this.build(result.data);
|
|
2110
|
+
this.store.guilds.set(entity.id, entity);
|
|
2111
|
+
return { ok: true, data: entity };
|
|
2112
|
+
}
|
|
2113
|
+
async delete(guildId) {
|
|
2114
|
+
const result = await this.rest.delete(this.endpoint(guildId));
|
|
2115
|
+
if (result.ok) this.store.guilds.delete(guildId);
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
2658
2118
|
};
|
|
2659
2119
|
|
|
2660
2120
|
// src/managers/channel.ts
|
|
@@ -2664,29 +2124,40 @@ var ChannelManager = class extends BaseManager {
|
|
|
2664
2124
|
return `/channels/${id}`;
|
|
2665
2125
|
}
|
|
2666
2126
|
build = buildChannel;
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
this.
|
|
2673
|
-
this.store
|
|
2674
|
-
|
|
2127
|
+
async create(guildId, payload, reason) {
|
|
2128
|
+
const headers = {};
|
|
2129
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2130
|
+
const result = await this.rest.post(`/guilds/${guildId}/channels`, toSnakeCase(payload), headers);
|
|
2131
|
+
if (!result.ok) return result;
|
|
2132
|
+
const entity = this.build(result.data, guildId);
|
|
2133
|
+
this.store.channels.set(entity.id, entity);
|
|
2134
|
+
return { ok: true, data: entity };
|
|
2675
2135
|
}
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
const cacheKey = TongueStore.memberKey(this.guildId, userId);
|
|
2681
|
-
if (!force) {
|
|
2682
|
-
const cached = this.store.members.get(cacheKey);
|
|
2683
|
-
if (cached) return { ok: true, data: cached };
|
|
2684
|
-
}
|
|
2685
|
-
const result = await this.rest.get(`/guilds/${this.guildId}/members/${userId}`);
|
|
2136
|
+
async edit(channelId, payload, reason) {
|
|
2137
|
+
const headers = {};
|
|
2138
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2139
|
+
const result = await this.rest.patch(this.endpoint(channelId), toSnakeCase(payload), headers);
|
|
2686
2140
|
if (!result.ok) return result;
|
|
2687
|
-
const
|
|
2688
|
-
this.store.
|
|
2689
|
-
return { ok: true, data:
|
|
2141
|
+
const entity = this.build(result.data);
|
|
2142
|
+
this.store.channels.set(entity.id, entity);
|
|
2143
|
+
return { ok: true, data: entity };
|
|
2144
|
+
}
|
|
2145
|
+
async delete(channelId, reason) {
|
|
2146
|
+
const headers = {};
|
|
2147
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2148
|
+
const result = await this.rest.delete(this.endpoint(channelId), headers);
|
|
2149
|
+
if (result.ok) this.store.channels.delete(channelId);
|
|
2150
|
+
return result;
|
|
2151
|
+
}
|
|
2152
|
+
async updatePermissions(channelId, overwriteId, payload, reason) {
|
|
2153
|
+
const headers = {};
|
|
2154
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2155
|
+
return await this.rest.put(`/channels/${channelId}/permissions/${overwriteId}`, toSnakeCase(payload), headers);
|
|
2156
|
+
}
|
|
2157
|
+
async deletePermission(channelId, overwriteId, reason) {
|
|
2158
|
+
const headers = {};
|
|
2159
|
+
if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
|
|
2160
|
+
return await this.rest.delete(`/channels/${channelId}/permissions/${overwriteId}`, headers);
|
|
2690
2161
|
}
|
|
2691
2162
|
};
|
|
2692
2163
|
|
|
@@ -2710,7 +2181,19 @@ var MessageManager = class {
|
|
|
2710
2181
|
return { ok: true, data: message };
|
|
2711
2182
|
}
|
|
2712
2183
|
async send(channelId, payload) {
|
|
2713
|
-
const data = typeof payload === "string" ? { content: payload } : payload;
|
|
2184
|
+
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2185
|
+
if (typeof payload === "object") {
|
|
2186
|
+
if (payload.embeds) {
|
|
2187
|
+
data.embeds = payload.embeds.map((e) => e && typeof e.toJSON === "function" ? e.toJSON() : e);
|
|
2188
|
+
}
|
|
2189
|
+
if (payload.components) {
|
|
2190
|
+
data.components = payload.components.map((c) => serializeComponent(c));
|
|
2191
|
+
}
|
|
2192
|
+
if (payload.reply) {
|
|
2193
|
+
data.message_reference = { message_id: payload.reply.messageId, fail_if_not_exists: payload.reply.failIfNotExists ?? true };
|
|
2194
|
+
delete data.reply;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2714
2197
|
const result = await this.rest.post(`/channels/${channelId}/messages`, data);
|
|
2715
2198
|
if (!result.ok) return result;
|
|
2716
2199
|
const message = buildMessage(result.data, this.store);
|
|
@@ -2718,7 +2201,15 @@ var MessageManager = class {
|
|
|
2718
2201
|
return { ok: true, data: message };
|
|
2719
2202
|
}
|
|
2720
2203
|
async edit(channelId, messageId, payload) {
|
|
2721
|
-
const data = typeof payload === "string" ? { content: payload } : payload;
|
|
2204
|
+
const data = typeof payload === "string" ? { content: payload } : { ...payload };
|
|
2205
|
+
if (typeof payload === "object") {
|
|
2206
|
+
if (payload.embeds) {
|
|
2207
|
+
data.embeds = payload.embeds.map((e) => e && typeof e.toJSON === "function" ? e.toJSON() : e);
|
|
2208
|
+
}
|
|
2209
|
+
if (payload.components) {
|
|
2210
|
+
data.components = payload.components.map((c) => serializeComponent(c));
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2722
2213
|
const result = await this.rest.patch(`/channels/${channelId}/messages/${messageId}`, data);
|
|
2723
2214
|
if (!result.ok) return result;
|
|
2724
2215
|
const oldMsg = this.store.messages.get(messageId);
|
|
@@ -2733,6 +2224,26 @@ var MessageManager = class {
|
|
|
2733
2224
|
}
|
|
2734
2225
|
return result;
|
|
2735
2226
|
}
|
|
2227
|
+
async list(channelId, options) {
|
|
2228
|
+
let url = `/channels/${channelId}/messages`;
|
|
2229
|
+
if (options) {
|
|
2230
|
+
const params = new URLSearchParams();
|
|
2231
|
+
if (options.limit) params.append("limit", options.limit.toString());
|
|
2232
|
+
if (options.before) params.append("before", options.before);
|
|
2233
|
+
if (options.after) params.append("after", options.after);
|
|
2234
|
+
if (options.around) params.append("around", options.around);
|
|
2235
|
+
const qs = params.toString();
|
|
2236
|
+
if (qs) url += `?${qs}`;
|
|
2237
|
+
}
|
|
2238
|
+
const result = await this.rest.get(url);
|
|
2239
|
+
if (!result.ok) return result;
|
|
2240
|
+
const messages = result.data.map((msgData) => {
|
|
2241
|
+
const msg = buildMessage(msgData, this.store);
|
|
2242
|
+
this.store.messages.set(msg.id, msg);
|
|
2243
|
+
return msg;
|
|
2244
|
+
});
|
|
2245
|
+
return { ok: true, data: messages };
|
|
2246
|
+
}
|
|
2736
2247
|
};
|
|
2737
2248
|
|
|
2738
2249
|
// src/managers/collector.ts
|
|
@@ -2782,21 +2293,20 @@ var CollectorManager = class {
|
|
|
2782
2293
|
return new Promise((resolve2) => {
|
|
2783
2294
|
let timeoutId = null;
|
|
2784
2295
|
const handler = (data) => {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2296
|
+
if (data.type !== "INTERACTION_CREATE") return;
|
|
2297
|
+
const interaction = data.interaction;
|
|
2298
|
+
const raw = interaction;
|
|
2299
|
+
if (interaction.type !== 3 /* MESSAGE_COMPONENT */) return;
|
|
2300
|
+
if (interaction.message?.id !== messageId) return;
|
|
2301
|
+
const userRaw = interaction.member?.user || interaction.user;
|
|
2789
2302
|
const user = buildUser(userRaw);
|
|
2790
2303
|
const ctx = new ComponentContext(
|
|
2791
2304
|
this.client,
|
|
2792
2305
|
raw,
|
|
2793
2306
|
user,
|
|
2794
|
-
|
|
2795
|
-
|
|
2307
|
+
interaction.guildId ? resolveGuild(interaction.guildId, this.client) : void 0,
|
|
2308
|
+
interaction.channelId ? resolveChannel(interaction.channelId, this.client) : void 0
|
|
2796
2309
|
);
|
|
2797
|
-
if (raw.data.component_type === 3 /* STRING_SELECT */ || raw.data.component_type === 5 /* USER_SELECT */ || raw.data.component_type === 6 /* ROLE_SELECT */ || raw.data.component_type === 7 /* MENTIONABLE_SELECT */ || raw.data.component_type === 8 /* CHANNEL_SELECT */) {
|
|
2798
|
-
ctx._values = raw.data.values || [];
|
|
2799
|
-
}
|
|
2800
2310
|
if (filter && !filter(ctx)) return;
|
|
2801
2311
|
cleanup();
|
|
2802
2312
|
resolve2(ctx);
|
|
@@ -3067,22 +2577,26 @@ var Client = class {
|
|
|
3067
2577
|
}
|
|
3068
2578
|
if (Array.isArray(d.emojis)) {
|
|
3069
2579
|
for (const raw of d.emojis) {
|
|
3070
|
-
|
|
2580
|
+
const emoji = buildEmoji(raw);
|
|
2581
|
+
if (emoji.id) this.cache.emojis.set(emoji.id, emoji);
|
|
3071
2582
|
}
|
|
3072
2583
|
}
|
|
3073
2584
|
if (Array.isArray(d.stickers)) {
|
|
3074
2585
|
for (const raw of d.stickers) {
|
|
3075
|
-
|
|
2586
|
+
const sticker = buildSticker(raw);
|
|
2587
|
+
this.cache.stickers.set(sticker.id, sticker);
|
|
3076
2588
|
}
|
|
3077
2589
|
}
|
|
3078
2590
|
if (Array.isArray(d.stage_instances)) {
|
|
3079
2591
|
for (const raw of d.stage_instances) {
|
|
3080
|
-
|
|
2592
|
+
const stage = buildStageInstance(raw);
|
|
2593
|
+
this.cache.stageInstances.set(stage.id, stage);
|
|
3081
2594
|
}
|
|
3082
2595
|
}
|
|
3083
2596
|
if (Array.isArray(d.guild_scheduled_events)) {
|
|
3084
2597
|
for (const raw of d.guild_scheduled_events) {
|
|
3085
|
-
|
|
2598
|
+
const event = buildScheduledEvent(raw);
|
|
2599
|
+
this.cache.scheduledEvents.set(event.id, event);
|
|
3086
2600
|
}
|
|
3087
2601
|
}
|
|
3088
2602
|
if (guild.large) {
|
|
@@ -3267,7 +2781,7 @@ var Client = class {
|
|
|
3267
2781
|
this.dispatch("MESSAGE_CREATE", {
|
|
3268
2782
|
type: "MESSAGE_CREATE",
|
|
3269
2783
|
message,
|
|
3270
|
-
channel: resolveChannel(message.channelId, this
|
|
2784
|
+
channel: resolveChannel(message.channelId, this)
|
|
3271
2785
|
});
|
|
3272
2786
|
break;
|
|
3273
2787
|
}
|
|
@@ -3278,7 +2792,7 @@ var Client = class {
|
|
|
3278
2792
|
this.dispatch("MESSAGE_UPDATE", {
|
|
3279
2793
|
type: "MESSAGE_UPDATE",
|
|
3280
2794
|
message,
|
|
3281
|
-
channel: resolveChannel(message.channelId, this
|
|
2795
|
+
channel: resolveChannel(message.channelId, this),
|
|
3282
2796
|
...oldMessage ? { oldMessage } : {}
|
|
3283
2797
|
});
|
|
3284
2798
|
break;
|
|
@@ -3371,14 +2885,14 @@ var Client = class {
|
|
|
3371
2885
|
}
|
|
3372
2886
|
this.dispatch("INTERACTION_CREATE", {
|
|
3373
2887
|
type: "INTERACTION_CREATE",
|
|
3374
|
-
interaction: d
|
|
2888
|
+
interaction: buildInteraction(d, this.cache)
|
|
3375
2889
|
});
|
|
3376
2890
|
break;
|
|
3377
2891
|
}
|
|
3378
2892
|
case "VOICE_STATE_UPDATE": {
|
|
3379
2893
|
this.dispatch("VOICE_STATE_UPDATE", {
|
|
3380
2894
|
type: "VOICE_STATE_UPDATE",
|
|
3381
|
-
voiceState: d
|
|
2895
|
+
voiceState: buildVoiceState(d, this.cache)
|
|
3382
2896
|
});
|
|
3383
2897
|
break;
|
|
3384
2898
|
}
|
|
@@ -3426,15 +2940,15 @@ var Client = class {
|
|
|
3426
2940
|
break;
|
|
3427
2941
|
}
|
|
3428
2942
|
case "ENTITLEMENT_CREATE": {
|
|
3429
|
-
this.dispatch("ENTITLEMENT_CREATE", { type: "ENTITLEMENT_CREATE", entitlement: d });
|
|
2943
|
+
this.dispatch("ENTITLEMENT_CREATE", { type: "ENTITLEMENT_CREATE", entitlement: buildEntitlement(d) });
|
|
3430
2944
|
break;
|
|
3431
2945
|
}
|
|
3432
2946
|
case "ENTITLEMENT_UPDATE": {
|
|
3433
|
-
this.dispatch("ENTITLEMENT_UPDATE", { type: "ENTITLEMENT_UPDATE", entitlement: d });
|
|
2947
|
+
this.dispatch("ENTITLEMENT_UPDATE", { type: "ENTITLEMENT_UPDATE", entitlement: buildEntitlement(d) });
|
|
3434
2948
|
break;
|
|
3435
2949
|
}
|
|
3436
2950
|
case "ENTITLEMENT_DELETE": {
|
|
3437
|
-
this.dispatch("ENTITLEMENT_DELETE", { type: "ENTITLEMENT_DELETE", entitlement: d });
|
|
2951
|
+
this.dispatch("ENTITLEMENT_DELETE", { type: "ENTITLEMENT_DELETE", entitlement: buildEntitlement(d) });
|
|
3438
2952
|
break;
|
|
3439
2953
|
}
|
|
3440
2954
|
case "PRESENCE_UPDATE": {
|
|
@@ -3566,7 +3080,7 @@ var Client = class {
|
|
|
3566
3080
|
break;
|
|
3567
3081
|
}
|
|
3568
3082
|
case "GUILD_EMOJIS_UPDATE": {
|
|
3569
|
-
const emojis = d.emojis;
|
|
3083
|
+
const emojis = d.emojis.map((raw) => buildEmoji(raw));
|
|
3570
3084
|
for (const emoji of emojis) {
|
|
3571
3085
|
if (emoji.id) this.cache.emojis.set(emoji.id, emoji);
|
|
3572
3086
|
}
|
|
@@ -3578,7 +3092,7 @@ var Client = class {
|
|
|
3578
3092
|
break;
|
|
3579
3093
|
}
|
|
3580
3094
|
case "GUILD_STICKERS_UPDATE": {
|
|
3581
|
-
const stickers = d.stickers;
|
|
3095
|
+
const stickers = d.stickers.map((raw) => buildSticker(raw));
|
|
3582
3096
|
for (const sticker of stickers) {
|
|
3583
3097
|
this.cache.stickers.set(sticker.id, sticker);
|
|
3584
3098
|
}
|
|
@@ -3590,37 +3104,37 @@ var Client = class {
|
|
|
3590
3104
|
break;
|
|
3591
3105
|
}
|
|
3592
3106
|
case "STAGE_INSTANCE_CREATE": {
|
|
3593
|
-
const stageInstance = d;
|
|
3107
|
+
const stageInstance = buildStageInstance(d);
|
|
3594
3108
|
this.cache.stageInstances.set(stageInstance.id, stageInstance);
|
|
3595
3109
|
this.dispatch("STAGE_INSTANCE_CREATE", { type: "STAGE_INSTANCE_CREATE", stageInstance });
|
|
3596
3110
|
break;
|
|
3597
3111
|
}
|
|
3598
3112
|
case "STAGE_INSTANCE_UPDATE": {
|
|
3599
|
-
const stageInstance = d;
|
|
3113
|
+
const stageInstance = buildStageInstance(d);
|
|
3600
3114
|
this.cache.stageInstances.set(stageInstance.id, stageInstance);
|
|
3601
3115
|
this.dispatch("STAGE_INSTANCE_UPDATE", { type: "STAGE_INSTANCE_UPDATE", stageInstance });
|
|
3602
3116
|
break;
|
|
3603
3117
|
}
|
|
3604
3118
|
case "STAGE_INSTANCE_DELETE": {
|
|
3605
|
-
const stageInstance = d;
|
|
3119
|
+
const stageInstance = buildStageInstance(d);
|
|
3606
3120
|
this.cache.stageInstances.delete(stageInstance.id);
|
|
3607
3121
|
this.dispatch("STAGE_INSTANCE_DELETE", { type: "STAGE_INSTANCE_DELETE", stageInstance });
|
|
3608
3122
|
break;
|
|
3609
3123
|
}
|
|
3610
3124
|
case "GUILD_SCHEDULED_EVENT_CREATE": {
|
|
3611
|
-
const scheduledEvent = d;
|
|
3125
|
+
const scheduledEvent = buildScheduledEvent(d);
|
|
3612
3126
|
this.cache.scheduledEvents.set(scheduledEvent.id, scheduledEvent);
|
|
3613
3127
|
this.dispatch("GUILD_SCHEDULED_EVENT_CREATE", { type: "GUILD_SCHEDULED_EVENT_CREATE", scheduledEvent });
|
|
3614
3128
|
break;
|
|
3615
3129
|
}
|
|
3616
3130
|
case "GUILD_SCHEDULED_EVENT_UPDATE": {
|
|
3617
|
-
const scheduledEvent = d;
|
|
3131
|
+
const scheduledEvent = buildScheduledEvent(d);
|
|
3618
3132
|
this.cache.scheduledEvents.set(scheduledEvent.id, scheduledEvent);
|
|
3619
3133
|
this.dispatch("GUILD_SCHEDULED_EVENT_UPDATE", { type: "GUILD_SCHEDULED_EVENT_UPDATE", scheduledEvent });
|
|
3620
3134
|
break;
|
|
3621
3135
|
}
|
|
3622
3136
|
case "GUILD_SCHEDULED_EVENT_DELETE": {
|
|
3623
|
-
const scheduledEvent = d;
|
|
3137
|
+
const scheduledEvent = buildScheduledEvent(d);
|
|
3624
3138
|
this.cache.scheduledEvents.delete(scheduledEvent.id);
|
|
3625
3139
|
this.dispatch("GUILD_SCHEDULED_EVENT_DELETE", { type: "GUILD_SCHEDULED_EVENT_DELETE", scheduledEvent });
|
|
3626
3140
|
break;
|
|
@@ -3634,19 +3148,19 @@ var Client = class {
|
|
|
3634
3148
|
break;
|
|
3635
3149
|
}
|
|
3636
3150
|
case "AUTO_MODERATION_RULE_CREATE": {
|
|
3637
|
-
const rule = d;
|
|
3151
|
+
const rule = buildAutoModRule(d);
|
|
3638
3152
|
this.cache.autoModRules.set(rule.id, rule);
|
|
3639
3153
|
this.dispatch("AUTO_MODERATION_RULE_CREATE", { type: "AUTO_MODERATION_RULE_CREATE", rule });
|
|
3640
3154
|
break;
|
|
3641
3155
|
}
|
|
3642
3156
|
case "AUTO_MODERATION_RULE_UPDATE": {
|
|
3643
|
-
const rule = d;
|
|
3157
|
+
const rule = buildAutoModRule(d);
|
|
3644
3158
|
this.cache.autoModRules.set(rule.id, rule);
|
|
3645
3159
|
this.dispatch("AUTO_MODERATION_RULE_UPDATE", { type: "AUTO_MODERATION_RULE_UPDATE", rule });
|
|
3646
3160
|
break;
|
|
3647
3161
|
}
|
|
3648
3162
|
case "AUTO_MODERATION_RULE_DELETE": {
|
|
3649
|
-
const rule = d;
|
|
3163
|
+
const rule = buildAutoModRule(d);
|
|
3650
3164
|
this.cache.autoModRules.delete(rule.id);
|
|
3651
3165
|
this.dispatch("AUTO_MODERATION_RULE_DELETE", { type: "AUTO_MODERATION_RULE_DELETE", rule });
|
|
3652
3166
|
break;
|
|
@@ -3668,13 +3182,13 @@ var Client = class {
|
|
|
3668
3182
|
break;
|
|
3669
3183
|
}
|
|
3670
3184
|
case "INTEGRATION_CREATE": {
|
|
3671
|
-
const integration = d;
|
|
3185
|
+
const integration = buildIntegration(d);
|
|
3672
3186
|
this.cache.integrations.set(integration.id, integration);
|
|
3673
3187
|
this.dispatch("INTEGRATION_CREATE", { type: "INTEGRATION_CREATE", guildId: d.guild_id, integration });
|
|
3674
3188
|
break;
|
|
3675
3189
|
}
|
|
3676
3190
|
case "INTEGRATION_UPDATE": {
|
|
3677
|
-
const integration = d;
|
|
3191
|
+
const integration = buildIntegration(d);
|
|
3678
3192
|
this.cache.integrations.set(integration.id, integration);
|
|
3679
3193
|
this.dispatch("INTEGRATION_UPDATE", { type: "INTEGRATION_UPDATE", guildId: d.guild_id, integration });
|
|
3680
3194
|
break;
|
|
@@ -3757,6 +3271,7 @@ export {
|
|
|
3757
3271
|
AutoModerationEventType,
|
|
3758
3272
|
AutoModerationKeywordPresetType,
|
|
3759
3273
|
AutoModerationTriggerType,
|
|
3274
|
+
BaseInteractionContext,
|
|
3760
3275
|
BaseManager,
|
|
3761
3276
|
ButtonBuilder,
|
|
3762
3277
|
ButtonStyle,
|
|
@@ -3772,7 +3287,7 @@ export {
|
|
|
3772
3287
|
Colors,
|
|
3773
3288
|
CommandContext,
|
|
3774
3289
|
CommandManager,
|
|
3775
|
-
|
|
3290
|
+
ComponentContext,
|
|
3776
3291
|
ComponentManager,
|
|
3777
3292
|
ComponentType,
|
|
3778
3293
|
DISCORD_GATEWAY_OPCODES,
|
|
@@ -3806,6 +3321,7 @@ export {
|
|
|
3806
3321
|
ModalBuilder,
|
|
3807
3322
|
PremiumTier,
|
|
3808
3323
|
PremiumType,
|
|
3324
|
+
RoleManager,
|
|
3809
3325
|
SelectMenuBuilder,
|
|
3810
3326
|
SkuFlag,
|
|
3811
3327
|
SkuType,
|
|
@@ -3824,13 +3340,22 @@ export {
|
|
|
3824
3340
|
VideoQualityMode,
|
|
3825
3341
|
VisibilityType,
|
|
3826
3342
|
WebhookType,
|
|
3343
|
+
buildAutoModRule,
|
|
3827
3344
|
buildChannel,
|
|
3345
|
+
buildEmoji,
|
|
3346
|
+
buildEntitlement,
|
|
3828
3347
|
buildGuild,
|
|
3348
|
+
buildIntegration,
|
|
3349
|
+
buildInteraction,
|
|
3829
3350
|
buildMember,
|
|
3830
3351
|
buildMessage,
|
|
3831
|
-
buildModalPayload,
|
|
3832
3352
|
buildRole,
|
|
3353
|
+
buildScheduledEvent,
|
|
3354
|
+
buildStageInstance,
|
|
3355
|
+
buildSticker,
|
|
3356
|
+
buildStickerItem,
|
|
3833
3357
|
buildUser,
|
|
3358
|
+
buildVoiceState,
|
|
3834
3359
|
combinePermissions,
|
|
3835
3360
|
defineButton,
|
|
3836
3361
|
defineChannelSelect,
|
|
@@ -3851,5 +3376,6 @@ export {
|
|
|
3851
3376
|
resolveChannel,
|
|
3852
3377
|
resolveGuild,
|
|
3853
3378
|
resolveRole,
|
|
3854
|
-
resolveUser
|
|
3379
|
+
resolveUser,
|
|
3380
|
+
serializeComponent
|
|
3855
3381
|
};
|