seyfert 4.5.0 → 5.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/lib/api/Routes/cdn.d.ts +2 -2
- package/lib/api/Routes/guilds.d.ts +2 -2
- package/lib/api/Routes/invites.d.ts +2 -2
- package/lib/api/api.d.ts +20 -8
- package/lib/api/api.js +198 -44
- package/lib/api/shared.d.ts +30 -1
- package/lib/api/utils/constants.d.ts +1 -1
- package/lib/api/utils/constants.js +1 -1
- package/lib/api/utils/utils.d.ts +2 -1
- package/lib/api/utils/utils.js +1 -1
- package/lib/builders/Attachment.d.ts +1 -1
- package/lib/builders/Attachment.js +30 -8
- package/lib/builders/MediaGallery.d.ts +2 -2
- package/lib/builders/MediaGallery.js +10 -0
- package/lib/builders/Modal.d.ts +18 -8
- package/lib/builders/Modal.js +36 -7
- package/lib/builders/Poll.js +18 -0
- package/lib/builders/RadioGroup.d.ts +4 -3
- package/lib/builders/RadioGroup.js +24 -3
- package/lib/builders/SelectMenu.d.ts +8 -6
- package/lib/builders/SelectMenu.js +24 -3
- package/lib/builders/types.d.ts +3 -2
- package/lib/cache/adapters/default.d.ts +1 -1
- package/lib/cache/adapters/default.js +23 -26
- package/lib/cache/adapters/limited.d.ts +1 -0
- package/lib/cache/adapters/limited.js +47 -33
- package/lib/cache/index.d.ts +19 -25
- package/lib/cache/index.js +58 -6
- package/lib/cache/resources/bans.d.ts +1 -1
- package/lib/cache/resources/bans.js +4 -4
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/channels.js +4 -4
- package/lib/cache/resources/default/base.d.ts +1 -1
- package/lib/cache/resources/default/base.js +8 -8
- package/lib/cache/resources/default/guild-based.d.ts +5 -5
- package/lib/cache/resources/default/guild-based.js +29 -16
- package/lib/cache/resources/default/guild-related.d.ts +5 -5
- package/lib/cache/resources/default/guild-related.js +14 -14
- package/lib/cache/resources/emojis.d.ts +1 -1
- package/lib/cache/resources/emojis.js +4 -4
- package/lib/cache/resources/guilds.js +28 -15
- package/lib/cache/resources/members.d.ts +1 -1
- package/lib/cache/resources/members.js +6 -6
- package/lib/cache/resources/messages.d.ts +7 -2
- package/lib/cache/resources/messages.js +43 -20
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +5 -8
- package/lib/cache/resources/roles.d.ts +1 -1
- package/lib/cache/resources/roles.js +4 -4
- package/lib/cache/resources/stickers.d.ts +1 -1
- package/lib/cache/resources/stickers.js +4 -4
- package/lib/cache/resources/users.js +4 -4
- package/lib/cache/resources/voice-states.d.ts +1 -1
- package/lib/cache/resources/voice-states.js +4 -4
- package/lib/client/base.d.ts +83 -24
- package/lib/client/base.js +594 -39
- package/lib/client/client.d.ts +28 -3
- package/lib/client/client.js +33 -9
- package/lib/client/collectors.d.ts +9 -8
- package/lib/client/collectors.js +19 -52
- package/lib/client/httpclient.d.ts +3 -0
- package/lib/client/index.d.ts +3 -1
- package/lib/client/index.js +4 -0
- package/lib/client/intents.d.ts +3 -0
- package/lib/client/intents.js +9 -0
- package/lib/client/plugins/api.d.ts +4 -0
- package/lib/client/plugins/api.js +550 -0
- package/lib/client/plugins/errors.d.ts +25 -0
- package/lib/client/plugins/errors.js +79 -0
- package/lib/client/plugins/order.d.ts +10 -0
- package/lib/client/plugins/order.js +32 -0
- package/lib/client/plugins/registry.d.ts +273 -0
- package/lib/client/plugins/registry.js +868 -0
- package/lib/client/plugins/shared.d.ts +23 -0
- package/lib/client/plugins/shared.js +193 -0
- package/lib/client/plugins/types.d.ts +398 -0
- package/lib/client/plugins/types.js +8 -0
- package/lib/client/plugins.d.ts +78 -0
- package/lib/client/plugins.js +558 -0
- package/lib/client/transformers.d.ts +33 -33
- package/lib/client/workerclient.d.ts +10 -1
- package/lib/client/workerclient.js +27 -17
- package/lib/collection.d.ts +10 -8
- package/lib/collection.js +19 -25
- package/lib/commands/applications/chat.d.ts +20 -18
- package/lib/commands/applications/chat.js +39 -14
- package/lib/commands/applications/chatcontext.d.ts +23 -15
- package/lib/commands/applications/chatcontext.js +23 -2
- package/lib/commands/applications/entryPoint.d.ts +4 -3
- package/lib/commands/applications/entryPoint.js +1 -1
- package/lib/commands/applications/entrycontext.d.ts +7 -9
- package/lib/commands/applications/entrycontext.js +3 -1
- package/lib/commands/applications/menu.d.ts +4 -3
- package/lib/commands/applications/menucontext.d.ts +7 -9
- package/lib/commands/applications/menucontext.js +3 -1
- package/lib/commands/applications/options.d.ts +23 -23
- package/lib/commands/applications/shared.d.ts +39 -17
- package/lib/commands/decorators.d.ts +50 -38
- package/lib/commands/decorators.js +15 -5
- package/lib/commands/handle.d.ts +19 -8
- package/lib/commands/handle.js +224 -143
- package/lib/commands/handler.d.ts +21 -8
- package/lib/commands/handler.js +157 -69
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/optionresolver.d.ts +2 -2
- package/lib/common/it/colors.js +12 -2
- package/lib/common/it/error.d.ts +9 -0
- package/lib/common/it/error.js +8 -0
- package/lib/common/it/fake-promise.d.ts +4 -0
- package/lib/common/it/fake-promise.js +10 -0
- package/lib/common/it/formatter.d.ts +14 -11
- package/lib/common/it/formatter.js +4 -3
- package/lib/common/it/logger.d.ts +7 -1
- package/lib/common/it/logger.js +24 -6
- package/lib/common/it/utils.d.ts +6 -8
- package/lib/common/it/utils.js +44 -42
- package/lib/common/shorters/application.d.ts +3 -3
- package/lib/common/shorters/application.js +3 -2
- package/lib/common/shorters/bans.d.ts +8 -4
- package/lib/common/shorters/bans.js +13 -5
- package/lib/common/shorters/channels.d.ts +4 -4
- package/lib/common/shorters/channels.js +4 -4
- package/lib/common/shorters/emojis.js +1 -0
- package/lib/common/shorters/guilds.d.ts +8 -8
- package/lib/common/shorters/guilds.js +14 -31
- package/lib/common/shorters/interaction.d.ts +1 -1
- package/lib/common/shorters/invites.d.ts +201 -201
- package/lib/common/shorters/members.d.ts +7 -7
- package/lib/common/shorters/members.js +13 -14
- package/lib/common/shorters/messages.d.ts +2 -2
- package/lib/common/shorters/soundboard.d.ts +5 -5
- package/lib/common/shorters/users.d.ts +1 -1
- package/lib/common/shorters/webhook.d.ts +3 -2
- package/lib/common/shorters/webhook.js +0 -7
- package/lib/common/types/options.d.ts +4 -0
- package/lib/common/types/util.d.ts +8 -0
- package/lib/common/types/write.d.ts +2 -1
- package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
- package/lib/components/BaseSelectMenuComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +3 -3
- package/lib/components/ChannelSelectMenuComponent.d.ts +2 -2
- package/lib/components/File.d.ts +1 -1
- package/lib/components/MediaGallery.d.ts +1 -1
- package/lib/components/MentionableSelectMenuComponent.d.ts +1 -1
- package/lib/components/RoleSelectMenuComponent.d.ts +1 -1
- package/lib/components/Separator.d.ts +1 -1
- package/lib/components/StringSelectMenuComponent.d.ts +1 -1
- package/lib/components/TextInputComponent.d.ts +1 -1
- package/lib/components/Thumbnail.d.ts +1 -1
- package/lib/components/UserSelectMenuComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +8 -7
- package/lib/components/componentcontext.d.ts +24 -36
- package/lib/components/componentcontext.js +7 -17
- package/lib/components/handler.d.ts +17 -7
- package/lib/components/handler.js +108 -49
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/interactioncontext.d.ts +45 -0
- package/lib/components/interactioncontext.js +93 -0
- package/lib/components/modalcommand.d.ts +5 -4
- package/lib/components/modalcontext.d.ts +39 -20
- package/lib/components/modalcontext.js +59 -6
- package/lib/events/event.d.ts +9 -3
- package/lib/events/handler.d.ts +51 -6
- package/lib/events/handler.js +165 -36
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +2 -2
- package/lib/events/hooks/guild.d.ts +150 -150
- package/lib/events/hooks/interactions.d.ts +1 -1
- package/lib/events/hooks/invite.d.ts +20 -20
- package/lib/events/hooks/message.d.ts +27 -27
- package/lib/events/hooks/presence.d.ts +11 -11
- package/lib/events/hooks/soundboard.d.ts +6 -6
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/subscriptions.d.ts +3 -3
- package/lib/events/hooks/thread.d.ts +30 -30
- package/lib/events/hooks/voice.d.ts +3 -4
- package/lib/events/hooks/voice.js +2 -1
- package/lib/events/utils.d.ts +4 -0
- package/lib/events/utils.js +59 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +13 -8
- package/lib/langs/handler.d.ts +14 -11
- package/lib/langs/handler.js +46 -9
- package/lib/langs/router.d.ts +10 -3
- package/lib/structures/Application.d.ts +1 -1
- package/lib/structures/Emoji.d.ts +3 -3
- package/lib/structures/Emoji.js +2 -2
- package/lib/structures/Guild.d.ts +154 -154
- package/lib/structures/GuildBan.d.ts +4 -4
- package/lib/structures/GuildBan.js +3 -3
- package/lib/structures/GuildMember.d.ts +7 -7
- package/lib/structures/GuildMember.js +28 -7
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildRole.js +2 -2
- package/lib/structures/Interaction.d.ts +11 -9
- package/lib/structures/Interaction.js +33 -12
- package/lib/structures/Message.d.ts +21 -14
- package/lib/structures/Message.js +29 -14
- package/lib/structures/User.d.ts +1 -1
- package/lib/structures/VoiceState.d.ts +4 -0
- package/lib/structures/VoiceState.js +13 -1
- package/lib/structures/Webhook.d.ts +9 -1
- package/lib/structures/Webhook.js +4 -1
- package/lib/structures/channels.d.ts +148 -134
- package/lib/structures/channels.js +27 -26
- package/lib/structures/extra/BitField.d.ts +4 -4
- package/lib/structures/extra/BitField.js +20 -4
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -4
- package/lib/structures/extra/Permissions.js +1 -17
- package/lib/types/payloads/_interactions/responses.d.ts +2 -2
- package/lib/types/payloads/components.d.ts +4 -4
- package/lib/websocket/SharedTypes.d.ts +4 -4
- package/lib/websocket/constants/index.d.ts +1 -1
- package/lib/websocket/constants/index.js +3 -2
- package/lib/websocket/discord/events/memberUpdate.js +2 -2
- package/lib/websocket/discord/heartbeater.d.ts +1 -0
- package/lib/websocket/discord/heartbeater.js +7 -0
- package/lib/websocket/discord/shard.d.ts +2 -2
- package/lib/websocket/discord/shard.js +15 -13
- package/lib/websocket/discord/sharder.d.ts +8 -7
- package/lib/websocket/discord/sharder.js +25 -5
- package/lib/websocket/discord/shared.d.ts +19 -6
- package/lib/websocket/discord/socket/custom.js +5 -0
- package/lib/websocket/discord/worker.d.ts +1 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +25 -11
- package/lib/websocket/discord/workermanager.js +41 -10
- package/package.json +12 -16
|
@@ -8,6 +8,7 @@ import { ComponentCommand } from './componentcommand';
|
|
|
8
8
|
import type { ComponentContext } from './componentcontext';
|
|
9
9
|
import { ModalCommand } from './modalcommand';
|
|
10
10
|
import type { ModalContext } from './modalcontext';
|
|
11
|
+
type ComponentSetTransformer = (component: ComponentCommands) => ComponentCommands | false | void;
|
|
11
12
|
type UserMatches = string | string[] | RegExp;
|
|
12
13
|
type COMPONENTS = {
|
|
13
14
|
components: {
|
|
@@ -49,17 +50,26 @@ export declare class ComponentHandler extends BaseHandler {
|
|
|
49
50
|
onModalSubmit(interaction: ModalSubmitInteraction): any;
|
|
50
51
|
deleteValue(id: string, reason?: string): void;
|
|
51
52
|
clearValue(id: string): COMPONENTS | undefined;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
establishDefaults(component: ComponentCommands): void;
|
|
54
|
+
private normalizeLoadOptions;
|
|
55
|
+
private materializeComponent;
|
|
56
|
+
set(instances: SeteableComponentCommand[], optionsOrTransform?: ComponentSetTransformer | ComponentLoadOptions): ComponentCommands[];
|
|
57
|
+
load(componentsDir: string, options?: ComponentLoadOptions): Promise<void>;
|
|
55
58
|
reload(path: string): Promise<any>;
|
|
56
59
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
57
60
|
execute(i: ComponentCommands, context: ComponentContext | ModalContext): Promise<any>;
|
|
58
61
|
executeComponent(context: ComponentContext): Promise<void>;
|
|
59
62
|
executeModal(context: ModalContext): Promise<void>;
|
|
60
|
-
onFile(file: FileLoaded<
|
|
61
|
-
callback(file:
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
onFile(file: FileLoaded<HandleableComponentCommand>): HandleableComponentCommand[] | undefined;
|
|
64
|
+
callback(file: SeteableComponentCommand, create?: ComponentLoadCreator): ComponentCommands | false;
|
|
65
|
+
}
|
|
66
|
+
export type HandleableComponentCommand = (new () => ComponentCommand) | (new () => ModalCommand);
|
|
67
|
+
export type SeteableComponentCommand = HandleableComponentCommand | ComponentCommands;
|
|
68
|
+
export type ComponentLoadKind = 'component' | 'modal';
|
|
69
|
+
export type ComponentLoadCreator = <T extends HandleableComponentCommand>(kind: ComponentLoadKind, constructor: T, next: () => InstanceType<T>) => InstanceType<T>;
|
|
70
|
+
export type ComponentLoadTransformer = (kind: ComponentLoadKind, component: ComponentCommands) => ComponentCommands | false | void;
|
|
71
|
+
export interface ComponentLoadOptions {
|
|
72
|
+
create?: ComponentLoadCreator;
|
|
73
|
+
transform?: ComponentLoadTransformer;
|
|
64
74
|
}
|
|
65
75
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ComponentHandler = void 0;
|
|
4
|
+
const plugins_1 = require("../client/plugins");
|
|
4
5
|
const collection_1 = require("../collection");
|
|
5
6
|
const commands_1 = require("../commands");
|
|
6
7
|
const common_1 = require("../common");
|
|
@@ -78,15 +79,29 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
78
79
|
if (!collector)
|
|
79
80
|
return resolve(null);
|
|
80
81
|
let nodeTimeout;
|
|
81
|
-
|
|
82
|
+
let cleaned = false;
|
|
83
|
+
const component = {
|
|
84
|
+
callback: interaction => {
|
|
85
|
+
cleanup();
|
|
86
|
+
//@ts-expect-error generic
|
|
87
|
+
resolve(interaction);
|
|
88
|
+
},
|
|
89
|
+
match: this.createMatchCallback(customId),
|
|
90
|
+
};
|
|
91
|
+
const cleanup = () => {
|
|
92
|
+
if (cleaned)
|
|
93
|
+
return;
|
|
94
|
+
cleaned = true;
|
|
82
95
|
clearTimeout(nodeTimeout);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
const index = collector.components.indexOf(component);
|
|
97
|
+
if (index !== -1)
|
|
98
|
+
collector.components.splice(index, 1);
|
|
99
|
+
};
|
|
100
|
+
collector.components.push(component);
|
|
86
101
|
if (timeout && timeout > 0)
|
|
87
102
|
nodeTimeout = setTimeout(() => {
|
|
103
|
+
cleanup();
|
|
88
104
|
resolve(null);
|
|
89
|
-
// by default 15 seconds in case user don't do anything
|
|
90
105
|
}, timeout);
|
|
91
106
|
}),
|
|
92
107
|
resetTimeouts: () => {
|
|
@@ -144,8 +159,9 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
144
159
|
return this.modals.has(interaction.user.id);
|
|
145
160
|
}
|
|
146
161
|
onModalSubmit(interaction) {
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
const callback = this.modals.get(interaction.user.id);
|
|
163
|
+
this.modals.delete(interaction.user.id);
|
|
164
|
+
return callback?.(interaction);
|
|
149
165
|
}
|
|
150
166
|
deleteValue(id, reason) {
|
|
151
167
|
const component = this.clearValue(id);
|
|
@@ -164,7 +180,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
164
180
|
this.values.delete(id);
|
|
165
181
|
return component;
|
|
166
182
|
}
|
|
167
|
-
|
|
183
|
+
establishDefaults(component) {
|
|
168
184
|
component.props ??= this.client.options.commands?.defaults?.props ?? {};
|
|
169
185
|
const is = component instanceof modalcommand_1.ModalCommand ? 'modals' : 'components';
|
|
170
186
|
component.onInternalError ??= this.client.options?.[is]?.defaults?.onInternalError;
|
|
@@ -173,11 +189,37 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
173
189
|
component.onAfterRun ??= this.client.options?.[is]?.defaults?.onAfterRun;
|
|
174
190
|
component.onBeforeMiddlewares ??= this.client.options?.[is]?.defaults?.onBeforeMiddlewares;
|
|
175
191
|
}
|
|
176
|
-
|
|
192
|
+
normalizeLoadOptions(options) {
|
|
193
|
+
return typeof options === 'function' ? { transform: (_kind, component) => options(component) } : (options ?? {});
|
|
194
|
+
}
|
|
195
|
+
materializeComponent(value, options = {}, filePath) {
|
|
196
|
+
let component;
|
|
197
|
+
component = this.callback(value, options.create);
|
|
198
|
+
if (!component)
|
|
199
|
+
return false;
|
|
200
|
+
if (!(component instanceof modalcommand_1.ModalCommand || component instanceof componentcommand_1.ComponentCommand))
|
|
201
|
+
return false;
|
|
202
|
+
this.establishDefaults(component);
|
|
203
|
+
if (filePath)
|
|
204
|
+
component.__filePath = filePath;
|
|
205
|
+
const kind = component instanceof modalcommand_1.ModalCommand ? 'modal' : 'component';
|
|
206
|
+
const wrapped = options.transform?.(kind, component) ?? component;
|
|
207
|
+
if (!wrapped)
|
|
208
|
+
return false;
|
|
209
|
+
if (wrapped !== component) {
|
|
210
|
+
component = wrapped;
|
|
211
|
+
component.__filePath ??= filePath;
|
|
212
|
+
this.establishDefaults(component);
|
|
213
|
+
}
|
|
214
|
+
return component;
|
|
215
|
+
}
|
|
216
|
+
set(instances, optionsOrTransform) {
|
|
217
|
+
const options = this.normalizeLoadOptions(optionsOrTransform);
|
|
218
|
+
const added = [];
|
|
177
219
|
for (const i of instances) {
|
|
178
220
|
let component;
|
|
179
221
|
try {
|
|
180
|
-
component = this.
|
|
222
|
+
component = this.materializeComponent(i, options);
|
|
181
223
|
if (!component)
|
|
182
224
|
continue;
|
|
183
225
|
}
|
|
@@ -185,11 +227,12 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
185
227
|
this.logger.warn(e, i);
|
|
186
228
|
continue;
|
|
187
229
|
}
|
|
188
|
-
this.stablishDefaults(component);
|
|
189
230
|
this.commands.push(component);
|
|
231
|
+
added.push(component);
|
|
190
232
|
}
|
|
233
|
+
return added;
|
|
191
234
|
}
|
|
192
|
-
async load(componentsDir) {
|
|
235
|
+
async load(componentsDir, options = {}) {
|
|
193
236
|
const paths = await this.loadFilesK(await this.getFiles(componentsDir));
|
|
194
237
|
for (const { components, file } of paths.map(x => ({ components: this.onFile(x.file), file: x }))) {
|
|
195
238
|
if (!components)
|
|
@@ -197,7 +240,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
197
240
|
for (const value of components) {
|
|
198
241
|
let component;
|
|
199
242
|
try {
|
|
200
|
-
component = this.callback(value);
|
|
243
|
+
component = this.callback(value, options.create);
|
|
201
244
|
if (!component)
|
|
202
245
|
continue;
|
|
203
246
|
}
|
|
@@ -214,8 +257,17 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
214
257
|
}
|
|
215
258
|
if (!(component instanceof modalcommand_1.ModalCommand || component instanceof componentcommand_1.ComponentCommand))
|
|
216
259
|
continue;
|
|
217
|
-
this.
|
|
260
|
+
this.establishDefaults(component);
|
|
218
261
|
component.__filePath = file.path;
|
|
262
|
+
const kind = component instanceof modalcommand_1.ModalCommand ? 'modal' : 'component';
|
|
263
|
+
const wrapped = options.transform?.(kind, component) ?? component;
|
|
264
|
+
if (!wrapped)
|
|
265
|
+
continue;
|
|
266
|
+
if (wrapped !== component) {
|
|
267
|
+
component = wrapped;
|
|
268
|
+
component.__filePath ??= file.path;
|
|
269
|
+
this.establishDefaults(component);
|
|
270
|
+
}
|
|
219
271
|
this.commands.push(component);
|
|
220
272
|
}
|
|
221
273
|
}
|
|
@@ -223,7 +275,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
223
275
|
async reload(path) {
|
|
224
276
|
if (!this.client.components)
|
|
225
277
|
return;
|
|
226
|
-
if ((0, common_1.
|
|
278
|
+
if ((0, common_1.isCloudflareWorker)()) {
|
|
227
279
|
throw new common_1.SeyfertError('RELOAD_NOT_SUPPORTED', {
|
|
228
280
|
metadata: { detail: 'Reload in Cloudflare worker is not supported' },
|
|
229
281
|
});
|
|
@@ -240,9 +292,11 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
240
292
|
return null;
|
|
241
293
|
this.client.components.commands.splice(index, 1);
|
|
242
294
|
const imported = await (0, common_1.magicImport)(component.__filePath).then(x => x.default ?? x);
|
|
243
|
-
const
|
|
244
|
-
command
|
|
245
|
-
|
|
295
|
+
const options = this.client.createPluginComponentLoadOptions?.() ?? {};
|
|
296
|
+
const command = this.materializeComponent(imported, options, component.__filePath);
|
|
297
|
+
if (!command)
|
|
298
|
+
return null;
|
|
299
|
+
this.client.components.commands.splice(index, 0, command);
|
|
246
300
|
return imported;
|
|
247
301
|
}
|
|
248
302
|
async reloadAll(stopIfFail = true) {
|
|
@@ -258,39 +312,41 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
258
312
|
}
|
|
259
313
|
}
|
|
260
314
|
async execute(i, context) {
|
|
261
|
-
|
|
262
|
-
await i.onBeforeMiddlewares?.(context);
|
|
263
|
-
const resultRunGlobalMiddlewares = await commands_1.BaseCommand.__runMiddlewares(context, (context.client.options?.globalMiddlewares ?? []), true);
|
|
264
|
-
if (resultRunGlobalMiddlewares.pass) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if ('error' in resultRunGlobalMiddlewares) {
|
|
268
|
-
return await i.onMiddlewaresError?.(context, resultRunGlobalMiddlewares.error ?? 'Unknown error');
|
|
269
|
-
}
|
|
270
|
-
const resultRunMiddlewares = await commands_1.BaseCommand.__runMiddlewares(context, i.middlewares, false);
|
|
271
|
-
if (resultRunMiddlewares.pass) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
if ('error' in resultRunMiddlewares) {
|
|
275
|
-
return await i.onMiddlewaresError?.(context, resultRunMiddlewares.error ?? 'Unknown error');
|
|
276
|
-
}
|
|
315
|
+
return (0, plugins_1.runContextScopes)(context.client.options.contextScopes, context, async () => {
|
|
277
316
|
try {
|
|
278
|
-
await i.
|
|
279
|
-
await
|
|
317
|
+
await i.onBeforeMiddlewares?.(context);
|
|
318
|
+
const resultRunGlobalMiddlewares = await commands_1.BaseCommand.__runMiddlewares(context, (context.client.options?.globalMiddlewares ?? []), true);
|
|
319
|
+
if (resultRunGlobalMiddlewares.pass) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if ('error' in resultRunGlobalMiddlewares) {
|
|
323
|
+
return await i.onMiddlewaresError?.(context, resultRunGlobalMiddlewares.error ?? 'Unknown error', resultRunGlobalMiddlewares.metadata ?? { middleware: 'unknown', scope: 'global' });
|
|
324
|
+
}
|
|
325
|
+
const resultRunMiddlewares = await commands_1.BaseCommand.__runMiddlewares(context, i.middlewares, false);
|
|
326
|
+
if (resultRunMiddlewares.pass) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if ('error' in resultRunMiddlewares) {
|
|
330
|
+
return await i.onMiddlewaresError?.(context, resultRunMiddlewares.error ?? 'Unknown error', resultRunMiddlewares.metadata ?? { middleware: 'unknown', scope: 'command' });
|
|
331
|
+
}
|
|
332
|
+
try {
|
|
333
|
+
await i.run(context);
|
|
334
|
+
await i.onAfterRun?.(context, undefined);
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
await i.onRunError?.(context, error);
|
|
338
|
+
await i.onAfterRun?.(context, error);
|
|
339
|
+
}
|
|
280
340
|
}
|
|
281
341
|
catch (error) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
await i.onInternalError?.(this.client, error);
|
|
289
|
-
}
|
|
290
|
-
catch (err) {
|
|
291
|
-
this.client.logger.error(`[${i.customId ?? 'Component/Modal command'}] Internal error:`, err);
|
|
342
|
+
try {
|
|
343
|
+
await i.onInternalError?.(this.client, i, error);
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
this.client.logger.error(`[${i.customId ?? 'Component/Modal command'}] Internal error:`, err);
|
|
347
|
+
}
|
|
292
348
|
}
|
|
293
|
-
}
|
|
349
|
+
});
|
|
294
350
|
}
|
|
295
351
|
async executeComponent(context) {
|
|
296
352
|
for (const i of this.commands) {
|
|
@@ -323,8 +379,11 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
323
379
|
onFile(file) {
|
|
324
380
|
return file.default ? [file.default] : undefined;
|
|
325
381
|
}
|
|
326
|
-
callback(file) {
|
|
327
|
-
|
|
382
|
+
callback(file, create) {
|
|
383
|
+
if (typeof file !== 'function')
|
|
384
|
+
return file;
|
|
385
|
+
const kind = file.prototype instanceof modalcommand_1.ModalCommand ? 'modal' : 'component';
|
|
386
|
+
return create?.(kind, file, () => new file()) ?? new file();
|
|
328
387
|
}
|
|
329
388
|
}
|
|
330
389
|
exports.ComponentHandler = ComponentHandler;
|
|
@@ -19,6 +19,7 @@ export type ActionRowMessageComponents = Exclude<MessageComponents, TextInputCom
|
|
|
19
19
|
export type AllComponents = MessageComponents | TopLevelComponents | ContainerComponents | BaseComponent<ComponentType>;
|
|
20
20
|
export * from './componentcommand';
|
|
21
21
|
export * from './componentcontext';
|
|
22
|
+
export * from './interactioncontext';
|
|
22
23
|
export * from './modalcommand';
|
|
23
24
|
export * from './modalcontext';
|
|
24
25
|
export type TopLevelComponents = SectionComponent | ActionRowMessageComponents | TextDisplayComponent | ContainerComponent | FileComponent | MediaGalleryComponent | BaseComponent<APITopLevelComponent['type']>;
|
package/lib/components/index.js
CHANGED
|
@@ -34,6 +34,7 @@ const Thumbnail_1 = require("./Thumbnail");
|
|
|
34
34
|
const UserSelectMenuComponent_1 = require("./UserSelectMenuComponent");
|
|
35
35
|
__exportStar(require("./componentcommand"), exports);
|
|
36
36
|
__exportStar(require("./componentcontext"), exports);
|
|
37
|
+
__exportStar(require("./interactioncontext"), exports);
|
|
37
38
|
__exportStar(require("./modalcommand"), exports);
|
|
38
39
|
__exportStar(require("./modalcontext"), exports);
|
|
39
40
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AllChannels, ReturnCache } from '..';
|
|
2
|
+
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, UserStructure, WebhookMessageStructure } from '../client/transformers';
|
|
3
|
+
import type { CommandMetadata, ExtendContext, GlobalMetadata, RegisteredMiddlewares, UsingClient } from '../commands';
|
|
4
|
+
import { BaseContext } from '../commands/basecontext';
|
|
5
|
+
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, ModalCreateOptions, UnionToTuple, When } from '../common';
|
|
6
|
+
import type { ModalSubmitInteraction } from '../structures';
|
|
7
|
+
import { type RESTGetAPIGuildQuery } from '../types';
|
|
8
|
+
export interface InteractionResponseContext<I> extends BaseContext, ExtendContext {
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class InteractionResponseContext<I = unknown, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
|
|
11
|
+
readonly client: UsingClient;
|
|
12
|
+
interaction: I;
|
|
13
|
+
constructor(client: UsingClient, interaction: I);
|
|
14
|
+
metadata: CommandMetadata<UnionToTuple<M>>;
|
|
15
|
+
globalMetadata: GlobalMetadata;
|
|
16
|
+
private get _interaction();
|
|
17
|
+
get t(): import("..").SeyfertLocale;
|
|
18
|
+
get customId(): string;
|
|
19
|
+
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessageStructure, void>>;
|
|
20
|
+
deferReply<FR extends boolean = false>(ephemeral?: boolean, fetchReply?: FR): Promise<When<FR, WebhookMessageStructure, undefined>>;
|
|
21
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessageStructure>;
|
|
22
|
+
editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessageStructure, void>>;
|
|
23
|
+
followup(body: MessageWebhookCreateBodyRequest): Promise<WebhookMessageStructure>;
|
|
24
|
+
fetchResponse(): Promise<WebhookMessageStructure>;
|
|
25
|
+
deleteResponse(): Promise<void>;
|
|
26
|
+
modal(body: ModalCreateBodyRequest, options?: undefined): Promise<undefined>;
|
|
27
|
+
modal(body: ModalCreateBodyRequest, options: ModalCreateOptions): Promise<ModalSubmitInteraction | null>;
|
|
28
|
+
channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
|
|
29
|
+
channel(mode: 'cache'): ReturnCache<AllChannels>;
|
|
30
|
+
me(mode?: 'rest' | 'flow'): Promise<GuildMemberStructure | undefined>;
|
|
31
|
+
me(mode: 'cache'): ReturnCache<GuildMemberStructure | undefined>;
|
|
32
|
+
guild(mode?: 'rest' | 'flow', query?: RESTGetAPIGuildQuery): Promise<GuildStructure<'cached' | 'api'> | undefined>;
|
|
33
|
+
guild(mode: 'cache', query?: RESTGetAPIGuildQuery): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
34
|
+
get guildId(): string | undefined;
|
|
35
|
+
get channelId(): string;
|
|
36
|
+
get author(): UserStructure;
|
|
37
|
+
get member(): InteractionGuildMemberStructure | undefined;
|
|
38
|
+
inGuild(): boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface GuildInteractionResponseContext<M extends keyof RegisteredMiddlewares = never> extends Omit<MakeRequired<InteractionResponseContext<unknown, M>, 'guildId' | 'member'>, 'guild' | 'me'> {
|
|
41
|
+
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
42
|
+
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
43
|
+
me(mode?: 'rest' | 'flow'): Promise<GuildMemberStructure>;
|
|
44
|
+
me(mode: 'cache'): ReturnCache<GuildMemberStructure | undefined>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionResponseContext = void 0;
|
|
4
|
+
const basecontext_1 = require("../commands/basecontext");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
class InteractionResponseContext extends basecontext_1.BaseContext {
|
|
7
|
+
client;
|
|
8
|
+
interaction;
|
|
9
|
+
constructor(client, interaction) {
|
|
10
|
+
super(client);
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.interaction = interaction;
|
|
13
|
+
}
|
|
14
|
+
metadata = {};
|
|
15
|
+
globalMetadata = {};
|
|
16
|
+
get _interaction() {
|
|
17
|
+
return this.interaction;
|
|
18
|
+
}
|
|
19
|
+
get t() {
|
|
20
|
+
return this.client.t(this._interaction.locale ?? this.client.langs?.defaultLang ?? 'en-US');
|
|
21
|
+
}
|
|
22
|
+
get customId() {
|
|
23
|
+
return this._interaction.customId;
|
|
24
|
+
}
|
|
25
|
+
write(body, fetchReply) {
|
|
26
|
+
return this._interaction.write(body, fetchReply);
|
|
27
|
+
}
|
|
28
|
+
deferReply(ephemeral = false, fetchReply) {
|
|
29
|
+
return this._interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined, fetchReply);
|
|
30
|
+
}
|
|
31
|
+
editResponse(body) {
|
|
32
|
+
return this._interaction.editResponse(body);
|
|
33
|
+
}
|
|
34
|
+
editOrReply(body, fetchReply) {
|
|
35
|
+
return this._interaction.editOrReply(body, fetchReply);
|
|
36
|
+
}
|
|
37
|
+
followup(body) {
|
|
38
|
+
return this._interaction.followup(body);
|
|
39
|
+
}
|
|
40
|
+
fetchResponse() {
|
|
41
|
+
return this._interaction.fetchResponse();
|
|
42
|
+
}
|
|
43
|
+
deleteResponse() {
|
|
44
|
+
return this._interaction.deleteResponse();
|
|
45
|
+
}
|
|
46
|
+
modal(body, options) {
|
|
47
|
+
if (options === undefined)
|
|
48
|
+
return this._interaction.modal(body);
|
|
49
|
+
return this._interaction.modal(body, options);
|
|
50
|
+
}
|
|
51
|
+
channel(mode = 'flow') {
|
|
52
|
+
if (mode === 'cache')
|
|
53
|
+
return this.client.cache.adapter.isAsync ? Promise.resolve(this._interaction.channel) : this._interaction.channel;
|
|
54
|
+
return this.client.channels.fetch(this.channelId, mode === 'rest');
|
|
55
|
+
}
|
|
56
|
+
me(mode = 'flow') {
|
|
57
|
+
if (!this.guildId)
|
|
58
|
+
return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve();
|
|
59
|
+
switch (mode) {
|
|
60
|
+
case 'cache':
|
|
61
|
+
return this.client.cache.members?.get(this.client.botId, this.guildId);
|
|
62
|
+
default:
|
|
63
|
+
return this.client.members.fetch(this.guildId, this.client.botId, mode === 'rest');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
guild(mode = 'flow', query) {
|
|
67
|
+
if (!this.guildId)
|
|
68
|
+
return (mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve());
|
|
69
|
+
switch (mode) {
|
|
70
|
+
case 'cache':
|
|
71
|
+
return (this.client.cache.guilds?.get(this.guildId) ||
|
|
72
|
+
(this.client.cache.adapter.isAsync ? Promise.resolve() : undefined));
|
|
73
|
+
default:
|
|
74
|
+
return this.client.guilds.fetch(this.guildId, { force: mode === 'rest', query });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
get guildId() {
|
|
78
|
+
return this._interaction.guildId;
|
|
79
|
+
}
|
|
80
|
+
get channelId() {
|
|
81
|
+
return this._interaction.channelId ?? this._interaction.channel.id;
|
|
82
|
+
}
|
|
83
|
+
get author() {
|
|
84
|
+
return this._interaction.user;
|
|
85
|
+
}
|
|
86
|
+
get member() {
|
|
87
|
+
return this._interaction.member;
|
|
88
|
+
}
|
|
89
|
+
inGuild() {
|
|
90
|
+
return !!this.guildId;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.InteractionResponseContext = InteractionResponseContext;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginMiddlewareDenialMetadata } from '../client/plugins/types';
|
|
2
|
+
import type { ExtraProps, ResolvedRegisteredMiddlewares, UsingClient } from '../commands';
|
|
2
3
|
import type { ModalContext } from './modalcontext';
|
|
3
4
|
export interface ModalCommand {
|
|
4
5
|
__filePath?: string;
|
|
@@ -8,11 +9,11 @@ export declare abstract class ModalCommand {
|
|
|
8
9
|
filter?(context: ModalContext): Promise<boolean> | boolean;
|
|
9
10
|
customId?: string | RegExp;
|
|
10
11
|
abstract run(context: ModalContext): any;
|
|
11
|
-
middlewares: (keyof
|
|
12
|
+
middlewares: readonly (keyof ResolvedRegisteredMiddlewares)[];
|
|
12
13
|
props: ExtraProps;
|
|
13
14
|
onBeforeMiddlewares?(context: ModalContext): any;
|
|
14
15
|
onAfterRun?(context: ModalContext, error: unknown | undefined): any;
|
|
15
16
|
onRunError?(context: ModalContext, error: unknown): any;
|
|
16
|
-
onMiddlewaresError?(context: ModalContext, error: string): any;
|
|
17
|
-
onInternalError?(client: UsingClient, error?: unknown): any;
|
|
17
|
+
onMiddlewaresError?(context: ModalContext, error: string, metadata: PluginMiddlewareDenialMetadata): any;
|
|
18
|
+
onInternalError?(client: UsingClient, modal: ModalCommand, error?: unknown): any;
|
|
18
19
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { AllChannels, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..';
|
|
2
|
-
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, UserStructure, WebhookMessageStructure } from '../client/transformers';
|
|
3
|
-
import type { CommandMetadata, ExtendContext, GlobalMetadata,
|
|
1
|
+
import type { AllChannels, Attachment, ModalCommand, ModalSubmitInteraction, ReturnCache } from '..';
|
|
2
|
+
import type { GuildMemberStructure, GuildRoleStructure, GuildStructure, InteractionGuildMemberStructure, UserStructure, WebhookMessageStructure } from '../client/transformers';
|
|
3
|
+
import type { CommandMetadata, ExtendContext, GlobalMetadata, ResolvedRegisteredMiddlewares, UsingClient } from '../commands';
|
|
4
4
|
import { BaseContext } from '../commands/basecontext';
|
|
5
|
-
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, ModalCreateOptions,
|
|
5
|
+
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, ModalCreateOptions, When } from '../common';
|
|
6
|
+
import { type RESTGetAPIGuildQuery } from '../types';
|
|
6
7
|
export interface ModalContext extends BaseContext, ExtendContext {
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Represents a context for interacting with components in a Discord bot.
|
|
10
11
|
* @template Type - The type of component interaction.
|
|
11
12
|
*/
|
|
12
|
-
export declare class ModalContext<M extends keyof
|
|
13
|
+
export declare class ModalContext<M extends keyof ResolvedRegisteredMiddlewares = never> extends BaseContext {
|
|
13
14
|
readonly client: UsingClient;
|
|
14
15
|
interaction: ModalSubmitInteraction;
|
|
15
16
|
/**
|
|
@@ -19,50 +20,66 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
19
20
|
*/
|
|
20
21
|
constructor(client: UsingClient, interaction: ModalSubmitInteraction);
|
|
21
22
|
command: ModalCommand;
|
|
22
|
-
metadata: CommandMetadata<
|
|
23
|
+
metadata: CommandMetadata<M>;
|
|
23
24
|
globalMetadata: GlobalMetadata;
|
|
24
|
-
get customId(): string;
|
|
25
25
|
get components(): {
|
|
26
|
-
type: import("
|
|
26
|
+
type: import("..").ComponentType.Label;
|
|
27
27
|
id?: number | undefined;
|
|
28
28
|
component?: {
|
|
29
|
-
type: import("
|
|
29
|
+
type: import("..").ComponentType.FileUpload;
|
|
30
30
|
values: string[];
|
|
31
31
|
id?: number | undefined;
|
|
32
32
|
customId: string;
|
|
33
33
|
} | {
|
|
34
|
-
type: import("
|
|
34
|
+
type: import("..").ComponentType.RadioGroup;
|
|
35
35
|
value: string;
|
|
36
36
|
id?: number | undefined;
|
|
37
37
|
customId: string;
|
|
38
38
|
} | {
|
|
39
|
-
type: import("
|
|
39
|
+
type: import("..").ComponentType.CheckboxGroup;
|
|
40
40
|
values: string[];
|
|
41
41
|
id?: number | undefined;
|
|
42
42
|
customId: string;
|
|
43
43
|
} | {
|
|
44
|
-
type: import("
|
|
44
|
+
type: import("..").ComponentType.Checkbox;
|
|
45
45
|
value: boolean;
|
|
46
46
|
id?: number | undefined;
|
|
47
47
|
customId: string;
|
|
48
48
|
} | {
|
|
49
|
-
type: import("
|
|
49
|
+
type: import("..").ComponentType.TextInput;
|
|
50
50
|
value: string;
|
|
51
51
|
id?: number | undefined;
|
|
52
52
|
customId: string;
|
|
53
53
|
} | {
|
|
54
|
-
type: import("
|
|
54
|
+
type: import("..").ComponentType.StringSelect | import("..").ComponentType.UserSelect | import("..").ComponentType.RoleSelect | import("..").ComponentType.MentionableSelect | import("..").ComponentType.ChannelSelect;
|
|
55
55
|
values: string[];
|
|
56
56
|
id?: number | undefined;
|
|
57
57
|
customId: string;
|
|
58
58
|
} | undefined;
|
|
59
59
|
}[];
|
|
60
|
+
get customId(): string;
|
|
60
61
|
/**
|
|
61
62
|
* Gets the language object for the interaction's locale.
|
|
62
63
|
*/
|
|
63
|
-
get t(): import("..").
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
get t(): import("..").SeyfertLocale;
|
|
65
|
+
getChannels(customId: string, required: true): AllChannels[];
|
|
66
|
+
getChannels(customId: string, required?: false): AllChannels[] | void;
|
|
67
|
+
getRoles(customId: string, required: true): GuildRoleStructure[];
|
|
68
|
+
getRoles(customId: string, required?: false): GuildRoleStructure[] | void;
|
|
69
|
+
getUsers(customId: string, required: true): UserStructure[];
|
|
70
|
+
getUsers(customId: string, required?: false): UserStructure[] | void;
|
|
71
|
+
getMentionables(customId: string, required: true): (UserStructure | GuildRoleStructure | InteractionGuildMemberStructure)[];
|
|
72
|
+
getMentionables(customId: string, required?: false): (UserStructure | GuildRoleStructure | InteractionGuildMemberStructure)[] | void;
|
|
73
|
+
getRadioValues(customId: string, required: true): string;
|
|
74
|
+
getRadioValues(customId: string, required?: false): string | void;
|
|
75
|
+
getCheckboxValues(customId: string, required: true): string[];
|
|
76
|
+
getCheckboxValues(customId: string, required?: false): string[] | void;
|
|
77
|
+
getCheckbox(customId: string, required: true): boolean;
|
|
78
|
+
getCheckbox(customId: string, required?: false): boolean | void;
|
|
79
|
+
getInputValue(customId: string, required: true): string | string[];
|
|
80
|
+
getInputValue(customId: string, required?: false): string | string[] | undefined;
|
|
81
|
+
getFiles(customId: string, required: true): Attachment[];
|
|
82
|
+
getFiles(customId: string, required?: false): Attachment[] | undefined;
|
|
66
83
|
/**
|
|
67
84
|
* Writes a response to the interaction.
|
|
68
85
|
* @param body - The body of the response.
|
|
@@ -74,6 +91,8 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
74
91
|
* @param ephemeral - Whether the reply should be ephemeral or not.
|
|
75
92
|
*/
|
|
76
93
|
deferReply<FR extends boolean = false>(ephemeral?: boolean, fetchReply?: FR): Promise<When<FR, WebhookMessageStructure, undefined>>;
|
|
94
|
+
update<WR extends boolean = false>(body: ComponentInteractionMessageUpdate, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
|
|
95
|
+
deferUpdate(): Promise<undefined>;
|
|
77
96
|
/**
|
|
78
97
|
* Edits the response of the interaction.
|
|
79
98
|
* @param body - The updated body of the response.
|
|
@@ -116,7 +135,7 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
116
135
|
* @param mode - The mode to fetch the guild.
|
|
117
136
|
* @returns A promise that resolves to the guild.
|
|
118
137
|
*/
|
|
119
|
-
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;
|
|
138
|
+
guild(mode?: 'rest' | 'flow', query?: RESTGetAPIGuildQuery): Promise<GuildStructure<'cached' | 'api'> | undefined>;
|
|
120
139
|
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
121
140
|
/**
|
|
122
141
|
* Gets the ID of the guild of the interaction.
|
|
@@ -137,8 +156,8 @@ export declare class ModalContext<M extends keyof RegisteredMiddlewares = never>
|
|
|
137
156
|
isModal(): this is ModalContext<M>;
|
|
138
157
|
inGuild(): this is GuildModalContext<M>;
|
|
139
158
|
}
|
|
140
|
-
export interface GuildModalContext<M extends keyof
|
|
141
|
-
guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
|
|
159
|
+
export interface GuildModalContext<M extends keyof ResolvedRegisteredMiddlewares = never> extends Omit<MakeRequired<ModalContext<M>, 'guildId' | 'member'>, 'guild' | 'me'> {
|
|
160
|
+
guild(mode?: 'rest' | 'flow', query?: RESTGetAPIGuildQuery): Promise<GuildStructure<'cached' | 'api'>>;
|
|
142
161
|
guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
143
162
|
me(mode?: 'rest' | 'flow'): Promise<GuildMemberStructure>;
|
|
144
163
|
me(mode: 'cache'): ReturnCache<GuildMemberStructure | undefined>;
|