baff.js 0.0.0-stage → 0.1.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/CHANGELOG.md +20 -0
- package/LICENSE +7 -0
- package/README.md +244 -3
- package/dist/cjs/builders/EmbedBuilder.d.ts +51 -0
- package/dist/cjs/builders/EmbedBuilder.js +150 -0
- package/dist/cjs/builders/SlashCommandBuilder.d.ts +69 -0
- package/dist/cjs/builders/SlashCommandBuilder.js +185 -0
- package/dist/cjs/builders/components/ActionRowBuilder.d.ts +14 -0
- package/dist/cjs/builders/components/ActionRowBuilder.js +45 -0
- package/dist/cjs/builders/components/ButtonBuilder.d.ts +19 -0
- package/dist/cjs/builders/components/ButtonBuilder.js +69 -0
- package/dist/cjs/builders/components/LayoutBuilders.d.ts +63 -0
- package/dist/cjs/builders/components/LayoutBuilders.js +179 -0
- package/dist/cjs/builders/components/ModalBuilder.d.ts +36 -0
- package/dist/cjs/builders/components/ModalBuilder.js +118 -0
- package/dist/cjs/builders/components/SelectMenuBuilder.d.ts +80 -0
- package/dist/cjs/builders/components/SelectMenuBuilder.js +192 -0
- package/dist/cjs/builders/components/shared.d.ts +16 -0
- package/dist/cjs/builders/components/shared.js +32 -0
- package/dist/cjs/builders/messagePayload.d.ts +35 -0
- package/dist/cjs/builders/messagePayload.js +88 -0
- package/dist/cjs/builders/validate.d.ts +12 -0
- package/dist/cjs/builders/validate.js +54 -0
- package/dist/cjs/client/Client.d.ts +63 -0
- package/dist/cjs/client/Client.js +152 -0
- package/dist/cjs/client/dispatch.d.ts +2 -0
- package/dist/cjs/client/dispatch.js +224 -0
- package/dist/cjs/client/events.d.ts +129 -0
- package/dist/cjs/client/events.js +2 -0
- package/dist/cjs/collectors/Collector.d.ts +37 -0
- package/dist/cjs/collectors/Collector.js +84 -0
- package/dist/cjs/collectors/InteractionCollector.d.ts +21 -0
- package/dist/cjs/collectors/InteractionCollector.js +44 -0
- package/dist/cjs/collectors/MessageCollector.d.ts +14 -0
- package/dist/cjs/collectors/MessageCollector.js +23 -0
- package/dist/cjs/errors/BaffError.d.ts +26 -0
- package/dist/cjs/errors/BaffError.js +39 -0
- package/dist/cjs/gateway/Gateway.d.ts +53 -0
- package/dist/cjs/gateway/Gateway.js +128 -0
- package/dist/cjs/http/handler.d.ts +11 -0
- package/dist/cjs/http/handler.js +72 -0
- package/dist/cjs/http/verify.d.ts +11 -0
- package/dist/cjs/http/verify.js +28 -0
- package/dist/cjs/index.d.ts +51 -0
- package/dist/cjs/index.js +185 -0
- package/dist/cjs/managers/CachedManager.d.ts +16 -0
- package/dist/cjs/managers/CachedManager.js +18 -0
- package/dist/cjs/managers/ChannelManager.d.ts +23 -0
- package/dist/cjs/managers/ChannelManager.js +85 -0
- package/dist/cjs/managers/CommandManager.d.ts +32 -0
- package/dist/cjs/managers/CommandManager.js +72 -0
- package/dist/cjs/managers/EventManager.d.ts +15 -0
- package/dist/cjs/managers/EventManager.js +36 -0
- package/dist/cjs/managers/ExpressionManagers.d.ts +36 -0
- package/dist/cjs/managers/ExpressionManagers.js +73 -0
- package/dist/cjs/managers/InviteManager.d.ts +17 -0
- package/dist/cjs/managers/InviteManager.js +26 -0
- package/dist/cjs/managers/MemberManager.d.ts +31 -0
- package/dist/cjs/managers/MemberManager.js +62 -0
- package/dist/cjs/managers/MessageManager.d.ts +32 -0
- package/dist/cjs/managers/MessageManager.js +79 -0
- package/dist/cjs/managers/RoleManager.d.ts +22 -0
- package/dist/cjs/managers/RoleManager.js +73 -0
- package/dist/cjs/managers/ServerChannelManager.d.ts +20 -0
- package/dist/cjs/managers/ServerChannelManager.js +30 -0
- package/dist/cjs/managers/ServerManager.d.ts +12 -0
- package/dist/cjs/managers/ServerManager.js +62 -0
- package/dist/cjs/managers/ThreadManager.d.ts +12 -0
- package/dist/cjs/managers/ThreadManager.js +20 -0
- package/dist/cjs/managers/UserManager.d.ts +11 -0
- package/dist/cjs/managers/UserManager.js +38 -0
- package/dist/cjs/managers/VoiceManager.d.ts +8 -0
- package/dist/cjs/managers/VoiceManager.js +17 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/rest/REST.d.ts +58 -0
- package/dist/cjs/rest/REST.js +193 -0
- package/dist/cjs/rest/Routes.d.ts +54 -0
- package/dist/cjs/rest/Routes.js +58 -0
- package/dist/cjs/rest/files.d.ts +19 -0
- package/dist/cjs/rest/files.js +37 -0
- package/dist/cjs/structures/Base.d.ts +13 -0
- package/dist/cjs/structures/Base.js +30 -0
- package/dist/cjs/structures/Message.d.ts +91 -0
- package/dist/cjs/structures/Message.js +200 -0
- package/dist/cjs/structures/Role.d.ts +34 -0
- package/dist/cjs/structures/Role.js +84 -0
- package/dist/cjs/structures/ScheduledEvent.d.ts +37 -0
- package/dist/cjs/structures/ScheduledEvent.js +73 -0
- package/dist/cjs/structures/Server.d.ts +68 -0
- package/dist/cjs/structures/Server.js +124 -0
- package/dist/cjs/structures/ServerAssets.d.ts +48 -0
- package/dist/cjs/structures/ServerAssets.js +104 -0
- package/dist/cjs/structures/ServerMember.d.ts +47 -0
- package/dist/cjs/structures/ServerMember.js +138 -0
- package/dist/cjs/structures/User.d.ts +35 -0
- package/dist/cjs/structures/User.js +87 -0
- package/dist/cjs/structures/Webhook.d.ts +30 -0
- package/dist/cjs/structures/Webhook.js +68 -0
- package/dist/cjs/structures/channels/BaseChannel.d.ts +49 -0
- package/dist/cjs/structures/channels/BaseChannel.js +81 -0
- package/dist/cjs/structures/channels/DMChannel.d.ts +9 -0
- package/dist/cjs/structures/channels/DMChannel.js +21 -0
- package/dist/cjs/structures/channels/ServerChannels.d.ts +57 -0
- package/dist/cjs/structures/channels/ServerChannels.js +138 -0
- package/dist/cjs/structures/channels/TextBasedChannel.d.ts +25 -0
- package/dist/cjs/structures/channels/TextBasedChannel.js +53 -0
- package/dist/cjs/structures/interactions/BaseInteraction.d.ts +74 -0
- package/dist/cjs/structures/interactions/BaseInteraction.js +221 -0
- package/dist/cjs/structures/interactions/CommandInteraction.d.ts +44 -0
- package/dist/cjs/structures/interactions/CommandInteraction.js +109 -0
- package/dist/cjs/structures/interactions/ComponentInteraction.d.ts +44 -0
- package/dist/cjs/structures/interactions/ComponentInteraction.js +64 -0
- package/dist/cjs/structures/interactions/ModalSubmitInteraction.d.ts +29 -0
- package/dist/cjs/structures/interactions/ModalSubmitInteraction.js +42 -0
- package/dist/cjs/structures/interactions/createInteraction.d.ts +4 -0
- package/dist/cjs/structures/interactions/createInteraction.js +34 -0
- package/dist/cjs/types.d.ts +369 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/util/Collection.d.ts +32 -0
- package/dist/cjs/util/Collection.js +145 -0
- package/dist/cjs/util/Permissions.d.ts +87 -0
- package/dist/cjs/util/Permissions.js +113 -0
- package/dist/cjs/util/Snowflake.d.ts +20 -0
- package/dist/cjs/util/Snowflake.js +40 -0
- package/dist/cjs/util/TypedEmitter.d.ts +17 -0
- package/dist/cjs/util/TypedEmitter.js +5 -0
- package/dist/cjs/util/constants.d.ts +78 -0
- package/dist/cjs/util/constants.js +81 -0
- package/dist/cjs/util/emoji.d.ts +8 -0
- package/dist/cjs/util/emoji.js +10 -0
- package/dist/cjs/util/formatters.d.ts +29 -0
- package/dist/cjs/util/formatters.js +55 -0
- package/dist/esm/builders/EmbedBuilder.d.ts +51 -0
- package/dist/esm/builders/EmbedBuilder.js +145 -0
- package/dist/esm/builders/SlashCommandBuilder.d.ts +69 -0
- package/dist/esm/builders/SlashCommandBuilder.js +170 -0
- package/dist/esm/builders/components/ActionRowBuilder.d.ts +14 -0
- package/dist/esm/builders/components/ActionRowBuilder.js +41 -0
- package/dist/esm/builders/components/ButtonBuilder.d.ts +19 -0
- package/dist/esm/builders/components/ButtonBuilder.js +65 -0
- package/dist/esm/builders/components/LayoutBuilders.d.ts +63 -0
- package/dist/esm/builders/components/LayoutBuilders.js +169 -0
- package/dist/esm/builders/components/ModalBuilder.d.ts +36 -0
- package/dist/esm/builders/components/ModalBuilder.js +113 -0
- package/dist/esm/builders/components/SelectMenuBuilder.d.ts +80 -0
- package/dist/esm/builders/components/SelectMenuBuilder.js +183 -0
- package/dist/esm/builders/components/shared.d.ts +16 -0
- package/dist/esm/builders/components/shared.js +26 -0
- package/dist/esm/builders/messagePayload.d.ts +35 -0
- package/dist/esm/builders/messagePayload.js +83 -0
- package/dist/esm/builders/validate.d.ts +12 -0
- package/dist/esm/builders/validate.js +46 -0
- package/dist/esm/client/Client.d.ts +63 -0
- package/dist/esm/client/Client.js +147 -0
- package/dist/esm/client/dispatch.d.ts +2 -0
- package/dist/esm/client/dispatch.js +221 -0
- package/dist/esm/client/events.d.ts +129 -0
- package/dist/esm/client/events.js +1 -0
- package/dist/esm/collectors/Collector.d.ts +37 -0
- package/dist/esm/collectors/Collector.js +78 -0
- package/dist/esm/collectors/InteractionCollector.d.ts +21 -0
- package/dist/esm/collectors/InteractionCollector.js +40 -0
- package/dist/esm/collectors/MessageCollector.d.ts +14 -0
- package/dist/esm/collectors/MessageCollector.js +19 -0
- package/dist/esm/errors/BaffError.d.ts +26 -0
- package/dist/esm/errors/BaffError.js +33 -0
- package/dist/esm/gateway/Gateway.d.ts +53 -0
- package/dist/esm/gateway/Gateway.js +124 -0
- package/dist/esm/http/handler.d.ts +11 -0
- package/dist/esm/http/handler.js +68 -0
- package/dist/esm/http/verify.d.ts +11 -0
- package/dist/esm/http/verify.js +22 -0
- package/dist/esm/index.d.ts +51 -0
- package/dist/esm/index.js +49 -0
- package/dist/esm/managers/CachedManager.d.ts +16 -0
- package/dist/esm/managers/CachedManager.js +14 -0
- package/dist/esm/managers/ChannelManager.d.ts +23 -0
- package/dist/esm/managers/ChannelManager.js +81 -0
- package/dist/esm/managers/CommandManager.d.ts +32 -0
- package/dist/esm/managers/CommandManager.js +67 -0
- package/dist/esm/managers/EventManager.d.ts +15 -0
- package/dist/esm/managers/EventManager.js +32 -0
- package/dist/esm/managers/ExpressionManagers.d.ts +36 -0
- package/dist/esm/managers/ExpressionManagers.js +68 -0
- package/dist/esm/managers/InviteManager.d.ts +17 -0
- package/dist/esm/managers/InviteManager.js +22 -0
- package/dist/esm/managers/MemberManager.d.ts +31 -0
- package/dist/esm/managers/MemberManager.js +58 -0
- package/dist/esm/managers/MessageManager.d.ts +32 -0
- package/dist/esm/managers/MessageManager.js +75 -0
- package/dist/esm/managers/RoleManager.d.ts +22 -0
- package/dist/esm/managers/RoleManager.js +69 -0
- package/dist/esm/managers/ServerChannelManager.d.ts +20 -0
- package/dist/esm/managers/ServerChannelManager.js +26 -0
- package/dist/esm/managers/ServerManager.d.ts +12 -0
- package/dist/esm/managers/ServerManager.js +58 -0
- package/dist/esm/managers/ThreadManager.d.ts +12 -0
- package/dist/esm/managers/ThreadManager.js +16 -0
- package/dist/esm/managers/UserManager.d.ts +11 -0
- package/dist/esm/managers/UserManager.js +34 -0
- package/dist/esm/managers/VoiceManager.d.ts +8 -0
- package/dist/esm/managers/VoiceManager.js +13 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/rest/REST.d.ts +58 -0
- package/dist/esm/rest/REST.js +188 -0
- package/dist/esm/rest/Routes.d.ts +54 -0
- package/dist/esm/rest/Routes.js +55 -0
- package/dist/esm/rest/files.d.ts +19 -0
- package/dist/esm/rest/files.js +31 -0
- package/dist/esm/structures/Base.d.ts +13 -0
- package/dist/esm/structures/Base.js +25 -0
- package/dist/esm/structures/Message.d.ts +91 -0
- package/dist/esm/structures/Message.js +194 -0
- package/dist/esm/structures/Role.d.ts +34 -0
- package/dist/esm/structures/Role.js +79 -0
- package/dist/esm/structures/ScheduledEvent.d.ts +37 -0
- package/dist/esm/structures/ScheduledEvent.js +68 -0
- package/dist/esm/structures/Server.d.ts +68 -0
- package/dist/esm/structures/Server.js +120 -0
- package/dist/esm/structures/ServerAssets.d.ts +48 -0
- package/dist/esm/structures/ServerAssets.js +98 -0
- package/dist/esm/structures/ServerMember.d.ts +47 -0
- package/dist/esm/structures/ServerMember.js +133 -0
- package/dist/esm/structures/User.d.ts +35 -0
- package/dist/esm/structures/User.js +82 -0
- package/dist/esm/structures/Webhook.d.ts +30 -0
- package/dist/esm/structures/Webhook.js +63 -0
- package/dist/esm/structures/channels/BaseChannel.d.ts +49 -0
- package/dist/esm/structures/channels/BaseChannel.js +77 -0
- package/dist/esm/structures/channels/DMChannel.d.ts +9 -0
- package/dist/esm/structures/channels/DMChannel.js +17 -0
- package/dist/esm/structures/channels/ServerChannels.d.ts +57 -0
- package/dist/esm/structures/channels/ServerChannels.js +129 -0
- package/dist/esm/structures/channels/TextBasedChannel.d.ts +25 -0
- package/dist/esm/structures/channels/TextBasedChannel.js +49 -0
- package/dist/esm/structures/interactions/BaseInteraction.d.ts +74 -0
- package/dist/esm/structures/interactions/BaseInteraction.js +217 -0
- package/dist/esm/structures/interactions/CommandInteraction.d.ts +44 -0
- package/dist/esm/structures/interactions/CommandInteraction.js +104 -0
- package/dist/esm/structures/interactions/ComponentInteraction.d.ts +44 -0
- package/dist/esm/structures/interactions/ComponentInteraction.js +53 -0
- package/dist/esm/structures/interactions/ModalSubmitInteraction.d.ts +29 -0
- package/dist/esm/structures/interactions/ModalSubmitInteraction.js +37 -0
- package/dist/esm/structures/interactions/createInteraction.d.ts +4 -0
- package/dist/esm/structures/interactions/createInteraction.js +31 -0
- package/dist/esm/types.d.ts +369 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/util/Collection.d.ts +32 -0
- package/dist/esm/util/Collection.js +141 -0
- package/dist/esm/util/Permissions.d.ts +87 -0
- package/dist/esm/util/Permissions.js +109 -0
- package/dist/esm/util/Snowflake.d.ts +20 -0
- package/dist/esm/util/Snowflake.js +37 -0
- package/dist/esm/util/TypedEmitter.d.ts +17 -0
- package/dist/esm/util/TypedEmitter.js +2 -0
- package/dist/esm/util/constants.d.ts +78 -0
- package/dist/esm/util/constants.js +78 -0
- package/dist/esm/util/emoji.d.ts +8 -0
- package/dist/esm/util/emoji.js +7 -0
- package/dist/esm/util/formatters.d.ts +29 -0
- package/dist/esm/util/formatters.js +34 -0
- package/package.json +58 -6
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { resolveMessage } from '../../builders/messagePayload.js';
|
|
2
|
+
import { BaffAPIError, BaffError } from '../../errors/BaffError.js';
|
|
3
|
+
import { Routes } from '../../rest/Routes.js';
|
|
4
|
+
import { PermissionsBitField } from '../../util/Permissions.js';
|
|
5
|
+
import { Identified } from '../Base.js';
|
|
6
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
export class BaseInteraction extends Identified {
|
|
8
|
+
raw;
|
|
9
|
+
id;
|
|
10
|
+
token;
|
|
11
|
+
applicationId;
|
|
12
|
+
channelId;
|
|
13
|
+
serverId;
|
|
14
|
+
user;
|
|
15
|
+
roleIds;
|
|
16
|
+
memberPermissions;
|
|
17
|
+
appPermissions;
|
|
18
|
+
replied = false;
|
|
19
|
+
deferred = false;
|
|
20
|
+
ephemeral = false;
|
|
21
|
+
answeredWith = null;
|
|
22
|
+
replyMessage = null;
|
|
23
|
+
sink = null;
|
|
24
|
+
viaResponse = false;
|
|
25
|
+
constructor(client, raw) {
|
|
26
|
+
super(client);
|
|
27
|
+
this.raw = raw;
|
|
28
|
+
this.id = raw.id;
|
|
29
|
+
this.token = raw.token;
|
|
30
|
+
this.applicationId = raw.applicationId;
|
|
31
|
+
this.channelId = raw.channelId;
|
|
32
|
+
this.serverId = raw.serverId;
|
|
33
|
+
this.user = client.users._add(raw.user);
|
|
34
|
+
this.roleIds = raw.user.roles ?? [];
|
|
35
|
+
this.memberPermissions = raw.user.permissions !== undefined ? PermissionsBitField.fromBits(raw.user.permissions) : null;
|
|
36
|
+
this.appPermissions = raw.appPermissions !== undefined ? PermissionsBitField.fromBits(raw.appPermissions) : null;
|
|
37
|
+
}
|
|
38
|
+
get fullCommandName() {
|
|
39
|
+
return this.commandName;
|
|
40
|
+
}
|
|
41
|
+
get channel() {
|
|
42
|
+
return this.client.channels._textChannel(this.channelId, this.serverId);
|
|
43
|
+
}
|
|
44
|
+
get server() {
|
|
45
|
+
return this.serverId ? (this.client.servers.cache.get(this.serverId) ?? null) : null;
|
|
46
|
+
}
|
|
47
|
+
get member() {
|
|
48
|
+
return this.server?.members.cache.get(this.user.id) ?? null;
|
|
49
|
+
}
|
|
50
|
+
get message() {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
get responded() {
|
|
54
|
+
return this.replied || this.deferred;
|
|
55
|
+
}
|
|
56
|
+
_setSink(sink) {
|
|
57
|
+
this.sink = sink;
|
|
58
|
+
if (sink)
|
|
59
|
+
this.viaResponse = true;
|
|
60
|
+
}
|
|
61
|
+
isChatInputCommand() {
|
|
62
|
+
return this.raw.type === 'command';
|
|
63
|
+
}
|
|
64
|
+
isMessageComponent() {
|
|
65
|
+
return this.raw.type === 'component';
|
|
66
|
+
}
|
|
67
|
+
isButton() {
|
|
68
|
+
return this.isMessageComponent() && this.raw.data.componentType === 2;
|
|
69
|
+
}
|
|
70
|
+
isAnySelectMenu() {
|
|
71
|
+
return this.isMessageComponent() && [3, 5, 6, 7, 8].includes(this.raw.data.componentType ?? 0);
|
|
72
|
+
}
|
|
73
|
+
isStringSelectMenu() {
|
|
74
|
+
return this.isMessageComponent() && this.raw.data.componentType === 3;
|
|
75
|
+
}
|
|
76
|
+
isUserSelectMenu() {
|
|
77
|
+
return this.isMessageComponent() && this.raw.data.componentType === 5;
|
|
78
|
+
}
|
|
79
|
+
isRoleSelectMenu() {
|
|
80
|
+
return this.isMessageComponent() && this.raw.data.componentType === 6;
|
|
81
|
+
}
|
|
82
|
+
isMentionableSelectMenu() {
|
|
83
|
+
return this.isMessageComponent() && this.raw.data.componentType === 7;
|
|
84
|
+
}
|
|
85
|
+
isChannelSelectMenu() {
|
|
86
|
+
return this.isMessageComponent() && this.raw.data.componentType === 8;
|
|
87
|
+
}
|
|
88
|
+
isModalSubmit() {
|
|
89
|
+
return this.raw.type === 'modal_submit';
|
|
90
|
+
}
|
|
91
|
+
isRepliable() {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
async reply(options) {
|
|
95
|
+
this.assertFresh();
|
|
96
|
+
const { body, files } = resolveMessage(options, { allowEphemeral: true });
|
|
97
|
+
if (files.length)
|
|
98
|
+
throw new BaffError('INVALID_MESSAGE', 'Interaction answers cannot carry files. Send the files with channel.send or after a defer.');
|
|
99
|
+
await this.callback({ type: 'message', ...body });
|
|
100
|
+
this.mark('message', typeof options === 'object' && options.ephemeral === true);
|
|
101
|
+
}
|
|
102
|
+
async deferReply(options = {}) {
|
|
103
|
+
this.assertFresh();
|
|
104
|
+
await this.callback({ type: 'defer' });
|
|
105
|
+
this.mark('defer', options.ephemeral === true);
|
|
106
|
+
}
|
|
107
|
+
async update(options) {
|
|
108
|
+
this.assertFresh();
|
|
109
|
+
this.assertFromMessage();
|
|
110
|
+
const { body } = resolveMessage(options);
|
|
111
|
+
await this.callback({ type: 'update', ...body });
|
|
112
|
+
this.mark('update', false);
|
|
113
|
+
}
|
|
114
|
+
async deferUpdate() {
|
|
115
|
+
this.assertFresh();
|
|
116
|
+
this.assertFromMessage();
|
|
117
|
+
await this.callback({ type: 'deferUpdate' });
|
|
118
|
+
this.mark('deferUpdate', false);
|
|
119
|
+
}
|
|
120
|
+
async showModal(modal) {
|
|
121
|
+
this.assertFresh();
|
|
122
|
+
if (this.isModalSubmit())
|
|
123
|
+
throw new BaffError('INVALID_INTERACTION', 'A modal submit cannot be answered with another modal.');
|
|
124
|
+
await this.callback({ type: 'modal', ...('toJSON' in modal ? modal.toJSON() : modal) });
|
|
125
|
+
this.mark('modal', false);
|
|
126
|
+
}
|
|
127
|
+
async editReply(options) {
|
|
128
|
+
if (!this.responded)
|
|
129
|
+
throw new BaffError('INTERACTION_NOT_REPLIED', 'Reply to or defer the interaction before editing its reply.');
|
|
130
|
+
if (this.answeredWith === 'update' || this.answeredWith === 'deferUpdate') {
|
|
131
|
+
const { body } = resolveMessage(options);
|
|
132
|
+
await this.afterAnswer(() => this.client.rest.patch(Routes.interactionOriginal(this.id, this.token), { body, auth: false }));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (this.answeredWith === 'defer' && this.deferred) {
|
|
136
|
+
const { body, files } = resolveMessage(options, { allowEphemeral: true });
|
|
137
|
+
await this.afterAnswer(() => this.client.rest.post(Routes.interactionFollowup(this.id, this.token), { body: { ...body, ephemeral: this.ephemeral }, files, auth: false }));
|
|
138
|
+
this.deferred = false;
|
|
139
|
+
this.replied = true;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (this.ephemeral)
|
|
143
|
+
throw new BaffError('CANNOT_EDIT_REPLY', 'baff.gg cannot edit an ephemeral reply after it was sent. Send a new follow-up or answer with update on a component.');
|
|
144
|
+
return (await this.fetchReply()).edit(options);
|
|
145
|
+
}
|
|
146
|
+
async followUp(options) {
|
|
147
|
+
if (!this.responded)
|
|
148
|
+
throw new BaffError('INTERACTION_NOT_REPLIED', 'Reply to or defer the interaction before sending a follow-up.');
|
|
149
|
+
const { body, files } = resolveMessage(options, { allowEphemeral: true });
|
|
150
|
+
await this.afterAnswer(() => this.client.rest.post(Routes.interactionFollowup(this.id, this.token), { body, files, auth: false }));
|
|
151
|
+
if (this.deferred) {
|
|
152
|
+
this.deferred = false;
|
|
153
|
+
this.replied = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async deleteReply() {
|
|
157
|
+
if (this.ephemeral)
|
|
158
|
+
throw new BaffError('CANNOT_DELETE_REPLY', 'baff.gg cannot delete an ephemeral reply.');
|
|
159
|
+
await (await this.fetchReply()).delete();
|
|
160
|
+
this.replyMessage = null;
|
|
161
|
+
}
|
|
162
|
+
async fetchReply() {
|
|
163
|
+
if (this.replyMessage)
|
|
164
|
+
return this.replyMessage;
|
|
165
|
+
if (!this.replied)
|
|
166
|
+
throw new BaffError('INTERACTION_NOT_REPLIED', 'There is no reply yet.');
|
|
167
|
+
if (this.ephemeral)
|
|
168
|
+
throw new BaffError('CANNOT_FETCH_REPLY', 'Ephemeral replies are not stored, so they cannot be fetched.');
|
|
169
|
+
const self = await this.client.fetchSelf();
|
|
170
|
+
for (let attempt = 0; attempt < (this.viaResponse ? 20 : 3); attempt++) {
|
|
171
|
+
const list = await this.client.rest.get(Routes.channelMessages(this.channelId), { query: { after: this.id, limit: 25 } });
|
|
172
|
+
const found = list.find((m) => m.author.id === self.id && m.interaction?.name === this.fullCommandName && m.interaction.user.id === this.user.id);
|
|
173
|
+
if (found)
|
|
174
|
+
return (this.replyMessage = this.channel.messages._add({ serverId: this.serverId, ...found }));
|
|
175
|
+
await sleep(this.viaResponse ? 100 : 150);
|
|
176
|
+
}
|
|
177
|
+
throw new BaffError('REPLY_NOT_FOUND', 'Could not find the reply message in this channel.');
|
|
178
|
+
}
|
|
179
|
+
async afterAnswer(request) {
|
|
180
|
+
for (let attempt = 0;; attempt++) {
|
|
181
|
+
try {
|
|
182
|
+
return await request();
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
const early = error instanceof BaffAPIError && error.code === 'not_answered';
|
|
186
|
+
if (!early || !this.viaResponse || attempt >= 20)
|
|
187
|
+
throw error;
|
|
188
|
+
await sleep(100);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async callback(body) {
|
|
193
|
+
if (this.sink) {
|
|
194
|
+
const sink = this.sink;
|
|
195
|
+
this.sink = null;
|
|
196
|
+
sink(body);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { body, auth: false });
|
|
200
|
+
}
|
|
201
|
+
mark(kind, ephemeral) {
|
|
202
|
+
this.answeredWith = kind;
|
|
203
|
+
this.ephemeral = ephemeral;
|
|
204
|
+
if (kind === 'defer')
|
|
205
|
+
this.deferred = true;
|
|
206
|
+
else
|
|
207
|
+
this.replied = true;
|
|
208
|
+
}
|
|
209
|
+
assertFresh() {
|
|
210
|
+
if (this.responded)
|
|
211
|
+
throw new BaffError('INTERACTION_ALREADY_REPLIED', 'This interaction was already answered. Use followUp or editReply.');
|
|
212
|
+
}
|
|
213
|
+
assertFromMessage() {
|
|
214
|
+
if (!this.raw.message)
|
|
215
|
+
throw new BaffError('INVALID_INTERACTION', 'Only interactions from a component can update a message.');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Client } from '../../client/Client.js';
|
|
2
|
+
import type { APIInteraction, APIInteractionOption } from '../../types.js';
|
|
3
|
+
import type { Role } from '../Role.js';
|
|
4
|
+
import type { User } from '../User.js';
|
|
5
|
+
import type { Channel } from '../channels/ServerChannels.js';
|
|
6
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
7
|
+
export declare class CommandInteractionOptions {
|
|
8
|
+
private readonly client;
|
|
9
|
+
private readonly serverId;
|
|
10
|
+
readonly data: APIInteractionOption[];
|
|
11
|
+
readonly subcommandGroup: string | null;
|
|
12
|
+
readonly subcommand: string | null;
|
|
13
|
+
private readonly values;
|
|
14
|
+
constructor(client: Client, serverId: string | null, options?: APIInteractionOption[]);
|
|
15
|
+
get(name: string, required?: boolean): APIInteractionOption | null;
|
|
16
|
+
getSubcommand(required?: boolean): string | null;
|
|
17
|
+
getSubcommandGroup(required?: boolean): string | null;
|
|
18
|
+
getString(name: string, required: true): string;
|
|
19
|
+
getString(name: string, required?: boolean): string | null;
|
|
20
|
+
getInteger(name: string, required: true): number;
|
|
21
|
+
getInteger(name: string, required?: boolean): number | null;
|
|
22
|
+
getNumber(name: string, required: true): number;
|
|
23
|
+
getNumber(name: string, required?: boolean): number | null;
|
|
24
|
+
getBoolean(name: string, required: true): boolean;
|
|
25
|
+
getBoolean(name: string, required?: boolean): boolean | null;
|
|
26
|
+
getUserId(name: string, required: true): string;
|
|
27
|
+
getUserId(name: string, required?: boolean): string | null;
|
|
28
|
+
getRoleId(name: string, required: true): string;
|
|
29
|
+
getRoleId(name: string, required?: boolean): string | null;
|
|
30
|
+
getChannelId(name: string, required: true): string;
|
|
31
|
+
getChannelId(name: string, required?: boolean): string | null;
|
|
32
|
+
getUser(name: string): User | null;
|
|
33
|
+
fetchUser(name: string): Promise<User | null>;
|
|
34
|
+
getRole(name: string): Role | null;
|
|
35
|
+
getChannel(name: string): Channel | null;
|
|
36
|
+
private typed;
|
|
37
|
+
}
|
|
38
|
+
export declare class ChatInputCommandInteraction extends BaseInteraction {
|
|
39
|
+
readonly commandId: string;
|
|
40
|
+
readonly commandName: string;
|
|
41
|
+
readonly options: CommandInteractionOptions;
|
|
42
|
+
constructor(client: Client, raw: APIInteraction);
|
|
43
|
+
get fullCommandName(): string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BaffError } from '../../errors/BaffError.js';
|
|
2
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
3
|
+
export class CommandInteractionOptions {
|
|
4
|
+
client;
|
|
5
|
+
serverId;
|
|
6
|
+
data;
|
|
7
|
+
subcommandGroup;
|
|
8
|
+
subcommand;
|
|
9
|
+
values;
|
|
10
|
+
constructor(client, serverId, options = []) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.serverId = serverId;
|
|
13
|
+
let level = options;
|
|
14
|
+
let group = null;
|
|
15
|
+
let sub = null;
|
|
16
|
+
if (level[0]?.type === 'subcommand_group') {
|
|
17
|
+
group = level[0].name;
|
|
18
|
+
level = level[0].options ?? [];
|
|
19
|
+
}
|
|
20
|
+
if (level[0]?.type === 'subcommand') {
|
|
21
|
+
sub = level[0].name;
|
|
22
|
+
level = level[0].options ?? [];
|
|
23
|
+
}
|
|
24
|
+
this.data = level;
|
|
25
|
+
this.subcommandGroup = group;
|
|
26
|
+
this.subcommand = sub;
|
|
27
|
+
this.values = new Map(level.map((o) => [o.name, o]));
|
|
28
|
+
}
|
|
29
|
+
get(name, required = false) {
|
|
30
|
+
const option = this.values.get(name) ?? null;
|
|
31
|
+
if (!option && required)
|
|
32
|
+
throw new BaffError('COMMAND_OPTION_MISSING', `Required option "${name}" was not provided.`);
|
|
33
|
+
return option;
|
|
34
|
+
}
|
|
35
|
+
getSubcommand(required = true) {
|
|
36
|
+
if (!this.subcommand && required)
|
|
37
|
+
throw new BaffError('COMMAND_SUBCOMMAND_MISSING', 'This interaction has no subcommand.');
|
|
38
|
+
return this.subcommand;
|
|
39
|
+
}
|
|
40
|
+
getSubcommandGroup(required = false) {
|
|
41
|
+
if (!this.subcommandGroup && required)
|
|
42
|
+
throw new BaffError('COMMAND_SUBCOMMAND_GROUP_MISSING', 'This interaction has no subcommand group.');
|
|
43
|
+
return this.subcommandGroup;
|
|
44
|
+
}
|
|
45
|
+
getString(name, required = false) {
|
|
46
|
+
return this.typed(name, 'string', required);
|
|
47
|
+
}
|
|
48
|
+
getInteger(name, required = false) {
|
|
49
|
+
return this.typed(name, 'integer', required);
|
|
50
|
+
}
|
|
51
|
+
getNumber(name, required = false) {
|
|
52
|
+
return this.typed(name, 'number', required);
|
|
53
|
+
}
|
|
54
|
+
getBoolean(name, required = false) {
|
|
55
|
+
return this.typed(name, 'boolean', required);
|
|
56
|
+
}
|
|
57
|
+
getUserId(name, required = false) {
|
|
58
|
+
return this.typed(name, 'user', required);
|
|
59
|
+
}
|
|
60
|
+
getRoleId(name, required = false) {
|
|
61
|
+
return this.typed(name, 'role', required);
|
|
62
|
+
}
|
|
63
|
+
getChannelId(name, required = false) {
|
|
64
|
+
return this.typed(name, 'channel', required);
|
|
65
|
+
}
|
|
66
|
+
getUser(name) {
|
|
67
|
+
const id = this.getUserId(name);
|
|
68
|
+
return id ? (this.client.users.cache.get(id) ?? null) : null;
|
|
69
|
+
}
|
|
70
|
+
async fetchUser(name) {
|
|
71
|
+
const id = this.getUserId(name);
|
|
72
|
+
return id ? this.client.users.fetch(id) : null;
|
|
73
|
+
}
|
|
74
|
+
getRole(name) {
|
|
75
|
+
const id = this.getRoleId(name);
|
|
76
|
+
return id && this.serverId ? (this.client.servers.cache.get(this.serverId)?.roles.cache.get(id) ?? null) : null;
|
|
77
|
+
}
|
|
78
|
+
getChannel(name) {
|
|
79
|
+
const id = this.getChannelId(name);
|
|
80
|
+
return id ? (this.client.channels.cache.get(id) ?? null) : null;
|
|
81
|
+
}
|
|
82
|
+
typed(name, type, required) {
|
|
83
|
+
const option = this.get(name, required);
|
|
84
|
+
if (!option)
|
|
85
|
+
return null;
|
|
86
|
+
if (option.type !== type)
|
|
87
|
+
throw new BaffError('COMMAND_OPTION_TYPE', `Option "${name}" is a ${option.type}, not a ${type}.`);
|
|
88
|
+
return option.value ?? null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class ChatInputCommandInteraction extends BaseInteraction {
|
|
92
|
+
commandId;
|
|
93
|
+
commandName;
|
|
94
|
+
options;
|
|
95
|
+
constructor(client, raw) {
|
|
96
|
+
super(client, raw);
|
|
97
|
+
this.commandId = raw.data.id ?? '';
|
|
98
|
+
this.commandName = raw.data.name ?? '';
|
|
99
|
+
this.options = new CommandInteractionOptions(client, raw.serverId, raw.data.options);
|
|
100
|
+
}
|
|
101
|
+
get fullCommandName() {
|
|
102
|
+
return [this.commandName, this.options.subcommandGroup, this.options.subcommand].filter(Boolean).join(' ');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Client } from '../../client/Client.js';
|
|
2
|
+
import type { APIInteraction } from '../../types.js';
|
|
3
|
+
import { Collection } from '../../util/Collection.js';
|
|
4
|
+
import type { Message } from '../Message.js';
|
|
5
|
+
import type { User } from '../User.js';
|
|
6
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
7
|
+
export declare class MessageComponentInteraction extends BaseInteraction {
|
|
8
|
+
readonly customId: string;
|
|
9
|
+
readonly componentType: number;
|
|
10
|
+
readonly commandName: string;
|
|
11
|
+
private readonly source;
|
|
12
|
+
constructor(client: Client, raw: APIInteraction);
|
|
13
|
+
get message(): Message;
|
|
14
|
+
}
|
|
15
|
+
export declare class ButtonInteraction extends MessageComponentInteraction {
|
|
16
|
+
readonly label: string | null;
|
|
17
|
+
constructor(client: Client, raw: APIInteraction);
|
|
18
|
+
}
|
|
19
|
+
export declare class SelectMenuInteraction extends MessageComponentInteraction {
|
|
20
|
+
readonly values: string[];
|
|
21
|
+
readonly users: Collection<string, User>;
|
|
22
|
+
readonly roles: Collection<string, {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
color: string | null;
|
|
26
|
+
}>;
|
|
27
|
+
readonly channels: Collection<string, {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
type: number;
|
|
31
|
+
parentId: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
constructor(client: Client, raw: APIInteraction);
|
|
34
|
+
}
|
|
35
|
+
export declare class StringSelectMenuInteraction extends SelectMenuInteraction {
|
|
36
|
+
}
|
|
37
|
+
export declare class UserSelectMenuInteraction extends SelectMenuInteraction {
|
|
38
|
+
}
|
|
39
|
+
export declare class RoleSelectMenuInteraction extends SelectMenuInteraction {
|
|
40
|
+
}
|
|
41
|
+
export declare class MentionableSelectMenuInteraction extends SelectMenuInteraction {
|
|
42
|
+
}
|
|
43
|
+
export declare class ChannelSelectMenuInteraction extends SelectMenuInteraction {
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Collection } from '../../util/Collection.js';
|
|
2
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
3
|
+
export class MessageComponentInteraction extends BaseInteraction {
|
|
4
|
+
customId;
|
|
5
|
+
componentType;
|
|
6
|
+
commandName;
|
|
7
|
+
source;
|
|
8
|
+
constructor(client, raw) {
|
|
9
|
+
super(client, raw);
|
|
10
|
+
this.customId = raw.data.customId ?? '';
|
|
11
|
+
this.componentType = raw.data.componentType ?? 0;
|
|
12
|
+
this.commandName = raw.message?.interactionName ?? '';
|
|
13
|
+
const channel = client.channels._textChannel(raw.channelId, raw.serverId);
|
|
14
|
+
this.source = channel.messages._add({ serverId: raw.serverId, ...raw.message });
|
|
15
|
+
}
|
|
16
|
+
get message() {
|
|
17
|
+
return this.source;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class ButtonInteraction extends MessageComponentInteraction {
|
|
21
|
+
label;
|
|
22
|
+
constructor(client, raw) {
|
|
23
|
+
super(client, raw);
|
|
24
|
+
this.label = raw.data.label ?? null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class SelectMenuInteraction extends MessageComponentInteraction {
|
|
28
|
+
values;
|
|
29
|
+
users = new Collection();
|
|
30
|
+
roles = new Collection();
|
|
31
|
+
channels = new Collection();
|
|
32
|
+
constructor(client, raw) {
|
|
33
|
+
super(client, raw);
|
|
34
|
+
this.values = raw.data.values ?? [];
|
|
35
|
+
const resolved = raw.data.resolved ?? {};
|
|
36
|
+
for (const [id, user] of Object.entries(resolved.users ?? {}))
|
|
37
|
+
this.users.set(id, client.users._add(user));
|
|
38
|
+
for (const [id, role] of Object.entries(resolved.roles ?? {}))
|
|
39
|
+
this.roles.set(id, role);
|
|
40
|
+
for (const [id, channel] of Object.entries(resolved.channels ?? {}))
|
|
41
|
+
this.channels.set(id, channel);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class StringSelectMenuInteraction extends SelectMenuInteraction {
|
|
45
|
+
}
|
|
46
|
+
export class UserSelectMenuInteraction extends SelectMenuInteraction {
|
|
47
|
+
}
|
|
48
|
+
export class RoleSelectMenuInteraction extends SelectMenuInteraction {
|
|
49
|
+
}
|
|
50
|
+
export class MentionableSelectMenuInteraction extends SelectMenuInteraction {
|
|
51
|
+
}
|
|
52
|
+
export class ChannelSelectMenuInteraction extends SelectMenuInteraction {
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Client } from '../../client/Client.js';
|
|
2
|
+
import type { APIInteraction } from '../../types.js';
|
|
3
|
+
import { Collection } from '../../util/Collection.js';
|
|
4
|
+
import type { Message } from '../Message.js';
|
|
5
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
6
|
+
export declare class ModalSubmitFields {
|
|
7
|
+
readonly fields: Collection<string, {
|
|
8
|
+
customId: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}>;
|
|
11
|
+
constructor(list: {
|
|
12
|
+
customId: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}[]);
|
|
15
|
+
getField(customId: string): {
|
|
16
|
+
customId: string;
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
getTextInputValue(customId: string): string;
|
|
20
|
+
}
|
|
21
|
+
export declare class ModalSubmitInteraction extends BaseInteraction {
|
|
22
|
+
readonly customId: string;
|
|
23
|
+
readonly fields: ModalSubmitFields;
|
|
24
|
+
readonly commandName: string;
|
|
25
|
+
private readonly source;
|
|
26
|
+
constructor(client: Client, raw: APIInteraction);
|
|
27
|
+
get message(): Message | null;
|
|
28
|
+
isFromMessage(): boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaffError } from '../../errors/BaffError.js';
|
|
2
|
+
import { Collection } from '../../util/Collection.js';
|
|
3
|
+
import { BaseInteraction } from './BaseInteraction.js';
|
|
4
|
+
export class ModalSubmitFields {
|
|
5
|
+
fields;
|
|
6
|
+
constructor(list) {
|
|
7
|
+
this.fields = new Collection(list.map((f) => [f.customId, f]));
|
|
8
|
+
}
|
|
9
|
+
getField(customId) {
|
|
10
|
+
const field = this.fields.get(customId);
|
|
11
|
+
if (!field)
|
|
12
|
+
throw new BaffError('MODAL_FIELD_MISSING', `The modal has no field "${customId}".`);
|
|
13
|
+
return field;
|
|
14
|
+
}
|
|
15
|
+
getTextInputValue(customId) {
|
|
16
|
+
return this.getField(customId).value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class ModalSubmitInteraction extends BaseInteraction {
|
|
20
|
+
customId;
|
|
21
|
+
fields;
|
|
22
|
+
commandName;
|
|
23
|
+
source;
|
|
24
|
+
constructor(client, raw) {
|
|
25
|
+
super(client, raw);
|
|
26
|
+
this.customId = raw.data.customId ?? '';
|
|
27
|
+
this.fields = new ModalSubmitFields(raw.data.fields ?? []);
|
|
28
|
+
this.commandName = raw.message?.interactionName ?? '';
|
|
29
|
+
this.source = raw.message ? client.channels._textChannel(raw.channelId, raw.serverId).messages._add({ serverId: raw.serverId, ...raw.message }) : null;
|
|
30
|
+
}
|
|
31
|
+
get message() {
|
|
32
|
+
return this.source;
|
|
33
|
+
}
|
|
34
|
+
isFromMessage() {
|
|
35
|
+
return this.source !== null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaffError } from '../../errors/BaffError.js';
|
|
2
|
+
import { ChatInputCommandInteraction } from './CommandInteraction.js';
|
|
3
|
+
import { ButtonInteraction, ChannelSelectMenuInteraction, MentionableSelectMenuInteraction, MessageComponentInteraction, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserSelectMenuInteraction } from './ComponentInteraction.js';
|
|
4
|
+
import { ModalSubmitInteraction } from './ModalSubmitInteraction.js';
|
|
5
|
+
export function createInteraction(client, raw) {
|
|
6
|
+
switch (raw.type) {
|
|
7
|
+
case 'command':
|
|
8
|
+
return new ChatInputCommandInteraction(client, raw);
|
|
9
|
+
case 'modal_submit':
|
|
10
|
+
return new ModalSubmitInteraction(client, raw);
|
|
11
|
+
case 'component':
|
|
12
|
+
switch (raw.data.componentType) {
|
|
13
|
+
case 2:
|
|
14
|
+
return new ButtonInteraction(client, raw);
|
|
15
|
+
case 3:
|
|
16
|
+
return new StringSelectMenuInteraction(client, raw);
|
|
17
|
+
case 5:
|
|
18
|
+
return new UserSelectMenuInteraction(client, raw);
|
|
19
|
+
case 6:
|
|
20
|
+
return new RoleSelectMenuInteraction(client, raw);
|
|
21
|
+
case 7:
|
|
22
|
+
return new MentionableSelectMenuInteraction(client, raw);
|
|
23
|
+
case 8:
|
|
24
|
+
return new ChannelSelectMenuInteraction(client, raw);
|
|
25
|
+
default:
|
|
26
|
+
return new MessageComponentInteraction(client, raw);
|
|
27
|
+
}
|
|
28
|
+
default:
|
|
29
|
+
throw new BaffError('UNKNOWN_INTERACTION', `Unknown interaction type "${String(raw.type)}".`);
|
|
30
|
+
}
|
|
31
|
+
}
|