lunibee 0.2.1 → 0.2.2
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 +6 -6
- package/dist/builders/attachment.d.ts +5 -1
- package/dist/builders/commands.d.ts +131 -45
- package/dist/builders/components.d.ts +164 -45
- package/dist/builders/embed.d.ts +5 -1
- package/dist/builders/index.d.ts +9 -4
- package/dist/builders/index.js +197 -105
- package/dist/builders/index.js.map +8 -8
- package/dist/core/events.d.ts +28 -12
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +183 -56
- package/dist/core/index.js.map +13 -13
- package/dist/core/permissions.d.ts +6 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +413 -168
- package/dist/index.js.map +17 -17
- package/dist/managers/index.d.ts +5 -1
- package/dist/managers/index.js +30 -14
- package/dist/managers/index.js.map +9 -9
- package/dist/managers/message.d.ts +7 -3
- package/dist/rest/index.js +2 -2
- package/dist/rest/index.js.map +1 -1
- package/dist/sharding/index.js +3 -2
- package/dist/sharding/index.js.map +4 -4
- package/dist/structures/index.d.ts +9 -3
- package/dist/structures/index.js +126 -28
- package/dist/structures/index.js.map +9 -9
- package/dist/structures/interactions.d.ts +85 -11
- package/dist/structures/resources.d.ts +11 -1
- package/dist/types/gateway.d.ts +14 -0
- package/dist/types/index.d.ts +179 -16
- package/dist/types/index.js +37 -10
- package/dist/types/index.js.map +4 -4
- package/dist/ws/index.js +2 -1
- package/dist/ws/index.js.map +4 -4
- package/package.json +14 -14
package/dist/structures/index.js
CHANGED
|
@@ -739,7 +739,7 @@ var IntentBits = {
|
|
|
739
739
|
directMessagePolls: 1 << 25
|
|
740
740
|
};
|
|
741
741
|
// packages/types/src/index.ts
|
|
742
|
-
var
|
|
742
|
+
var InteractionResponseEnum = {
|
|
743
743
|
Pong: 1,
|
|
744
744
|
ChannelMessage: 4,
|
|
745
745
|
DeferredChannelMessage: 5,
|
|
@@ -748,10 +748,11 @@ var InteractionResponseType = {
|
|
|
748
748
|
Autocomplete: 8,
|
|
749
749
|
Modal: 9
|
|
750
750
|
};
|
|
751
|
+
var InteractionResponseType = InteractionResponseEnum;
|
|
751
752
|
// packages/rest/package.json
|
|
752
753
|
var package_default = {
|
|
753
754
|
name: "@lunibee/rest",
|
|
754
|
-
version: "0.2.
|
|
755
|
+
version: "0.2.2",
|
|
755
756
|
type: "module",
|
|
756
757
|
module: "./src/index.ts",
|
|
757
758
|
types: "./src/index.ts",
|
|
@@ -989,7 +990,7 @@ class Invite {
|
|
|
989
990
|
return this.url;
|
|
990
991
|
}
|
|
991
992
|
}
|
|
992
|
-
var
|
|
993
|
+
var WebhookEnum = {
|
|
993
994
|
Incoming: 1,
|
|
994
995
|
ChannelFollower: 2,
|
|
995
996
|
Application: 3
|
|
@@ -1005,7 +1006,7 @@ class Webhook extends BaseStructure {
|
|
|
1005
1006
|
token;
|
|
1006
1007
|
constructor(data) {
|
|
1007
1008
|
super(data.id);
|
|
1008
|
-
this.type = data.type ??
|
|
1009
|
+
this.type = data.type ?? WebhookEnum.Incoming;
|
|
1009
1010
|
this.name = data.name ?? null;
|
|
1010
1011
|
this.avatarHash = data.avatar ?? null;
|
|
1011
1012
|
this.channelId = data.channel_id ?? null;
|
|
@@ -1170,6 +1171,7 @@ class GuildOnboarding2 extends BaseStructure {
|
|
|
1170
1171
|
this.mode = data.mode;
|
|
1171
1172
|
}
|
|
1172
1173
|
}
|
|
1174
|
+
var WebhookType = WebhookEnum;
|
|
1173
1175
|
// packages/structures/src/channels.ts
|
|
1174
1176
|
class NewsChannel extends TextChannel {
|
|
1175
1177
|
}
|
|
@@ -1449,7 +1451,7 @@ class CommandOptions {
|
|
|
1449
1451
|
}
|
|
1450
1452
|
}
|
|
1451
1453
|
// packages/structures/src/interactions.ts
|
|
1452
|
-
var
|
|
1454
|
+
var InteractionEnum = {
|
|
1453
1455
|
Ping: 1,
|
|
1454
1456
|
ApplicationCommand: 2,
|
|
1455
1457
|
MessageComponent: 3,
|
|
@@ -1457,8 +1459,17 @@ var InteractionType = {
|
|
|
1457
1459
|
ModalSubmit: 5
|
|
1458
1460
|
};
|
|
1459
1461
|
var EPHEMERAL = 64;
|
|
1462
|
+
var COMMAND_CHAT_INPUT = 1;
|
|
1463
|
+
var COMMAND_USER = 2;
|
|
1464
|
+
var COMMAND_MESSAGE = 3;
|
|
1460
1465
|
var TOKEN_LIFETIME_MS = 15 * 60000;
|
|
1461
1466
|
var DISCORD_EPOCH = 1420070400000n;
|
|
1467
|
+
function splitWithResponse(options) {
|
|
1468
|
+
if (typeof options === "string")
|
|
1469
|
+
return { withResponse: false, rest: options };
|
|
1470
|
+
const { withResponse, ...rest } = options;
|
|
1471
|
+
return { withResponse: withResponse === true, rest };
|
|
1472
|
+
}
|
|
1462
1473
|
function toMessageData(options) {
|
|
1463
1474
|
if (typeof options === "string")
|
|
1464
1475
|
return { content: options };
|
|
@@ -1471,6 +1482,7 @@ function toMessageData(options) {
|
|
|
1471
1482
|
class InteractionResponse {
|
|
1472
1483
|
type;
|
|
1473
1484
|
data;
|
|
1485
|
+
withResponse = false;
|
|
1474
1486
|
constructor(type, data) {
|
|
1475
1487
|
if (!Number.isFinite(type))
|
|
1476
1488
|
throw new TypeError("Interaction response type must be finite.");
|
|
@@ -1481,13 +1493,13 @@ class InteractionResponse {
|
|
|
1481
1493
|
return this.data === undefined ? { type: this.type } : { type: this.type, data: this.data };
|
|
1482
1494
|
}
|
|
1483
1495
|
static message(options) {
|
|
1484
|
-
return new InteractionResponse(
|
|
1496
|
+
return new InteractionResponse(InteractionResponseEnum.ChannelMessage, toMessageData(options));
|
|
1485
1497
|
}
|
|
1486
1498
|
static defer(ephemeral = false) {
|
|
1487
|
-
return new InteractionResponse(
|
|
1499
|
+
return new InteractionResponse(InteractionResponseEnum.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
|
|
1488
1500
|
}
|
|
1489
1501
|
static pong() {
|
|
1490
|
-
return new InteractionResponse(
|
|
1502
|
+
return new InteractionResponse(InteractionResponseEnum.Pong);
|
|
1491
1503
|
}
|
|
1492
1504
|
}
|
|
1493
1505
|
|
|
@@ -1515,8 +1527,30 @@ class Interaction {
|
|
|
1515
1527
|
this.type = data.type;
|
|
1516
1528
|
this.data = data;
|
|
1517
1529
|
}
|
|
1530
|
+
#commandType() {
|
|
1531
|
+
if (this.type !== InteractionEnum.ApplicationCommand)
|
|
1532
|
+
return 0;
|
|
1533
|
+
const type = this.data.data?.type;
|
|
1534
|
+
return typeof type === "number" ? type : COMMAND_CHAT_INPUT;
|
|
1535
|
+
}
|
|
1536
|
+
isCommand() {
|
|
1537
|
+
return this.type === InteractionEnum.ApplicationCommand;
|
|
1538
|
+
}
|
|
1518
1539
|
isChatInputCommand() {
|
|
1519
|
-
return this
|
|
1540
|
+
return this.#commandType() === COMMAND_CHAT_INPUT;
|
|
1541
|
+
}
|
|
1542
|
+
isContextMenuCommand() {
|
|
1543
|
+
const type = this.#commandType();
|
|
1544
|
+
return type === COMMAND_USER || type === COMMAND_MESSAGE;
|
|
1545
|
+
}
|
|
1546
|
+
isUserContextMenuCommand() {
|
|
1547
|
+
return this.#commandType() === COMMAND_USER;
|
|
1548
|
+
}
|
|
1549
|
+
isMessageContextMenuCommand() {
|
|
1550
|
+
return this.#commandType() === COMMAND_MESSAGE;
|
|
1551
|
+
}
|
|
1552
|
+
get resourceContext() {
|
|
1553
|
+
return this.#client.resourceContext;
|
|
1520
1554
|
}
|
|
1521
1555
|
awaitModalSubmit(options) {
|
|
1522
1556
|
const collect = this.#client.resourceContext?.collectInteractions;
|
|
@@ -1533,13 +1567,13 @@ class Interaction {
|
|
|
1533
1567
|
return collector.next();
|
|
1534
1568
|
}
|
|
1535
1569
|
isMessageComponent() {
|
|
1536
|
-
return this.type ===
|
|
1570
|
+
return this.type === InteractionEnum.MessageComponent;
|
|
1537
1571
|
}
|
|
1538
1572
|
isModalSubmit() {
|
|
1539
|
-
return this.type ===
|
|
1573
|
+
return this.type === InteractionEnum.ModalSubmit;
|
|
1540
1574
|
}
|
|
1541
1575
|
isAutocomplete() {
|
|
1542
|
-
return this.type ===
|
|
1576
|
+
return this.type === InteractionEnum.ApplicationCommandAutocomplete;
|
|
1543
1577
|
}
|
|
1544
1578
|
#componentType() {
|
|
1545
1579
|
return this.isMessageComponent() ? this.data.data?.component_type ?? 0 : 0;
|
|
@@ -1624,12 +1658,24 @@ class Interaction {
|
|
|
1624
1658
|
postResponse(response) {
|
|
1625
1659
|
return this.#client.postInteractionResponse(this.id, this.token, response);
|
|
1626
1660
|
}
|
|
1661
|
+
async acknowledgeWith(response, state, withResponse) {
|
|
1662
|
+
response.withResponse = withResponse;
|
|
1663
|
+
const result = await this.acknowledge(response, state);
|
|
1664
|
+
if (!withResponse)
|
|
1665
|
+
return result;
|
|
1666
|
+
const message = result?.resource?.message;
|
|
1667
|
+
return message ? new Message(message, this.#client.resourceContext) : null;
|
|
1668
|
+
}
|
|
1627
1669
|
async reply(options) {
|
|
1628
|
-
|
|
1670
|
+
const { withResponse, rest } = splitWithResponse(options);
|
|
1671
|
+
return this.acknowledgeWith(InteractionResponse.message(toMessageData(rest)), "replied", withResponse);
|
|
1629
1672
|
}
|
|
1630
1673
|
async deferReply(options = false) {
|
|
1631
1674
|
const ephemeral = typeof options === "boolean" ? options : options.ephemeral === true;
|
|
1632
|
-
|
|
1675
|
+
const withResponse = typeof options === "object" && options.withResponse === true;
|
|
1676
|
+
const result = await this.acknowledgeWith(InteractionResponse.defer(ephemeral), "deferred", withResponse);
|
|
1677
|
+
if (withResponse)
|
|
1678
|
+
return result;
|
|
1633
1679
|
}
|
|
1634
1680
|
editReply(options) {
|
|
1635
1681
|
this.assertAcknowledged();
|
|
@@ -1643,11 +1689,12 @@ class Interaction {
|
|
|
1643
1689
|
return this.#client.followUpInteraction(this.token, toMessageData(options));
|
|
1644
1690
|
}
|
|
1645
1691
|
async update(options) {
|
|
1646
|
-
|
|
1692
|
+
const { withResponse, rest } = splitWithResponse(options);
|
|
1693
|
+
return this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.MessageUpdate, toMessageData(rest)), "replied", withResponse);
|
|
1647
1694
|
}
|
|
1648
1695
|
async showModal(modal) {
|
|
1649
1696
|
const data = "toJSON" in modal && typeof modal.toJSON === "function" ? modal.toJSON() : modal;
|
|
1650
|
-
return this.acknowledge(new InteractionResponse(
|
|
1697
|
+
return this.acknowledge(new InteractionResponse(InteractionResponseEnum.Modal, data), "replied");
|
|
1651
1698
|
}
|
|
1652
1699
|
}
|
|
1653
1700
|
|
|
@@ -1664,6 +1711,38 @@ class CommandInteraction extends Interaction {
|
|
|
1664
1711
|
}
|
|
1665
1712
|
}
|
|
1666
1713
|
|
|
1714
|
+
class ContextMenuCommandInteraction extends CommandInteraction {
|
|
1715
|
+
#resolved() {
|
|
1716
|
+
return this.data.data?.resolved ?? {};
|
|
1717
|
+
}
|
|
1718
|
+
get targetId() {
|
|
1719
|
+
const id = this.data.data?.target_id;
|
|
1720
|
+
return typeof id === "string" ? id : null;
|
|
1721
|
+
}
|
|
1722
|
+
get targetUser() {
|
|
1723
|
+
const id = this.targetId;
|
|
1724
|
+
const raw = id ? this.#resolved().users?.[id] : undefined;
|
|
1725
|
+
return raw ? new User(raw) : null;
|
|
1726
|
+
}
|
|
1727
|
+
get targetMember() {
|
|
1728
|
+
const id = this.targetId;
|
|
1729
|
+
const raw = id ? this.#resolved().members?.[id] : undefined;
|
|
1730
|
+
const user = id ? this.#resolved().users?.[id] : undefined;
|
|
1731
|
+
if (!raw || !user || !this.guildId)
|
|
1732
|
+
return null;
|
|
1733
|
+
return new GuildMember({
|
|
1734
|
+
...raw,
|
|
1735
|
+
user,
|
|
1736
|
+
guild_id: this.guildId
|
|
1737
|
+
}, this.resourceContext);
|
|
1738
|
+
}
|
|
1739
|
+
get targetMessage() {
|
|
1740
|
+
const id = this.targetId;
|
|
1741
|
+
const raw = id ? this.#resolved().messages?.[id] : undefined;
|
|
1742
|
+
return raw ? new Message(raw, this.resourceContext) : null;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1667
1746
|
class ComponentInteraction extends Interaction {
|
|
1668
1747
|
get customId() {
|
|
1669
1748
|
return this.data?.data?.custom_id ?? "";
|
|
@@ -1677,11 +1756,11 @@ class ComponentInteraction extends Interaction {
|
|
|
1677
1756
|
get values() {
|
|
1678
1757
|
return this.data?.data?.values ?? [];
|
|
1679
1758
|
}
|
|
1680
|
-
async deferUpdate() {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1759
|
+
async deferUpdate(options = {}) {
|
|
1760
|
+
const withResponse = options.withResponse === true;
|
|
1761
|
+
const result = await this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.DeferredMessageUpdate), "deferred", withResponse);
|
|
1762
|
+
if (withResponse)
|
|
1763
|
+
return result;
|
|
1685
1764
|
}
|
|
1686
1765
|
}
|
|
1687
1766
|
|
|
@@ -1723,7 +1802,7 @@ class AutocompleteInteraction extends Interaction {
|
|
|
1723
1802
|
async respond(choices) {
|
|
1724
1803
|
if (!Array.isArray(choices))
|
|
1725
1804
|
throw new TypeError("Autocomplete choices must be an array.");
|
|
1726
|
-
const response = new InteractionResponse(
|
|
1805
|
+
const response = new InteractionResponse(InteractionResponseEnum.Autocomplete, { choices });
|
|
1727
1806
|
await this.acknowledge(response, "replied");
|
|
1728
1807
|
}
|
|
1729
1808
|
}
|
|
@@ -1741,18 +1820,21 @@ function findFocused(options) {
|
|
|
1741
1820
|
}
|
|
1742
1821
|
function createInteraction(client, data) {
|
|
1743
1822
|
switch (data.type) {
|
|
1744
|
-
case
|
|
1745
|
-
|
|
1746
|
-
|
|
1823
|
+
case InteractionEnum.ApplicationCommand: {
|
|
1824
|
+
const commandType = data.data?.type;
|
|
1825
|
+
return commandType === COMMAND_USER || commandType === COMMAND_MESSAGE ? new ContextMenuCommandInteraction(client, data) : new CommandInteraction(client, data);
|
|
1826
|
+
}
|
|
1827
|
+
case InteractionEnum.ApplicationCommandAutocomplete:
|
|
1747
1828
|
return new AutocompleteInteraction(client, data);
|
|
1748
|
-
case
|
|
1829
|
+
case InteractionEnum.MessageComponent:
|
|
1749
1830
|
return new ComponentInteraction(client, data);
|
|
1750
|
-
case
|
|
1831
|
+
case InteractionEnum.ModalSubmit:
|
|
1751
1832
|
return new ModalSubmitInteraction(client, data);
|
|
1752
1833
|
default:
|
|
1753
1834
|
return new Interaction(client, data);
|
|
1754
1835
|
}
|
|
1755
1836
|
}
|
|
1837
|
+
var InteractionType = InteractionEnum;
|
|
1756
1838
|
// packages/structures/src/embed.ts
|
|
1757
1839
|
class Embed {
|
|
1758
1840
|
#data;
|
|
@@ -1942,6 +2024,9 @@ class Message extends BaseStructure {
|
|
|
1942
2024
|
reference;
|
|
1943
2025
|
components;
|
|
1944
2026
|
referencedMessage;
|
|
2027
|
+
stickers;
|
|
2028
|
+
poll;
|
|
2029
|
+
messageSnapshots;
|
|
1945
2030
|
member;
|
|
1946
2031
|
#context;
|
|
1947
2032
|
constructor(data, context) {
|
|
@@ -1963,6 +2048,13 @@ class Message extends BaseStructure {
|
|
|
1963
2048
|
this.mentionEveryone = data.mention_everyone ?? false;
|
|
1964
2049
|
this.type = data.type ?? 0;
|
|
1965
2050
|
this.reference = data.message_reference;
|
|
2051
|
+
this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
|
|
2052
|
+
id,
|
|
2053
|
+
name,
|
|
2054
|
+
format_type
|
|
2055
|
+
}));
|
|
2056
|
+
this.poll = data.poll ?? null;
|
|
2057
|
+
this.messageSnapshots = data.message_snapshots ?? [];
|
|
1966
2058
|
this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
|
|
1967
2059
|
this.#context = context;
|
|
1968
2060
|
this.member = data.member && data.guild_id ? new GuildMember({
|
|
@@ -2101,11 +2193,13 @@ export {
|
|
|
2101
2193
|
AutoModerationRule,
|
|
2102
2194
|
AutocompleteInteraction,
|
|
2103
2195
|
BaseStructure,
|
|
2196
|
+
CDN_BASE,
|
|
2104
2197
|
CategoryChannel,
|
|
2105
2198
|
Channel,
|
|
2106
2199
|
CommandInteraction,
|
|
2107
2200
|
CommandOptions,
|
|
2108
2201
|
ComponentInteraction,
|
|
2202
|
+
ContextMenuCommandInteraction,
|
|
2109
2203
|
DMChannel,
|
|
2110
2204
|
Embed,
|
|
2111
2205
|
Emoji,
|
|
@@ -2115,7 +2209,9 @@ export {
|
|
|
2115
2209
|
GuildOnboarding2 as GuildOnboarding,
|
|
2116
2210
|
GuildWelcomeScreen2 as GuildWelcomeScreen,
|
|
2117
2211
|
Interaction,
|
|
2212
|
+
InteractionEnum,
|
|
2118
2213
|
InteractionResponse,
|
|
2214
|
+
InteractionResponseEnum,
|
|
2119
2215
|
InteractionResponseType,
|
|
2120
2216
|
InteractionType,
|
|
2121
2217
|
Invite,
|
|
@@ -2133,10 +2229,12 @@ export {
|
|
|
2133
2229
|
User,
|
|
2134
2230
|
VoiceChannel,
|
|
2135
2231
|
Webhook,
|
|
2232
|
+
WebhookEnum,
|
|
2136
2233
|
WebhookType,
|
|
2137
2234
|
WelcomeScreenChannel,
|
|
2235
|
+
cdnURL,
|
|
2138
2236
|
createChannel,
|
|
2139
2237
|
createInteraction
|
|
2140
2238
|
};
|
|
2141
2239
|
|
|
2142
|
-
//# debugId=
|
|
2240
|
+
//# debugId=1DD80FEE9EB768DF64756E2164756E21
|