@moody-djs/prompts 1.0.1 → 1.0.3

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.
@@ -50,4 +50,46 @@ declare class PromptSelectMenuBuilder<Context extends object> extends StringSele
50
50
  getModal(): ModalBuilder | ((interaction: StringSelectMenuInteraction) => MaybePromise<ModalBuilder | null>) | undefined;
51
51
  }
52
52
 
53
- export { type APIPromptButtonComponent, type APIPromptSelectMenuComponent, type APIPromptTopLevelComponent, PromptButtonBuilder, type PromptContext, PromptSelectMenuBuilder, type PromptState, type PromptStateMessageCallback, type RegisterComponentsOptions };
53
+ declare class PromptError extends Error {
54
+ constructor(message: string);
55
+ }
56
+ /**
57
+ * A prompt that allows you to create a sequence of states that a user can go through
58
+ * with discord.js buttons and select menus.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const prompt = new Prompt<ContextType>(defaults, initialState.name, [...]);
63
+ * await prompt.start(interaction);
64
+ * ```
65
+ */
66
+ declare class Prompt<T extends object> {
67
+ initialState: string;
68
+ /** The current context of this prompt */
69
+ private context;
70
+ /** The current state */
71
+ private currentState?;
72
+ /** All components for this prompt */
73
+ private components;
74
+ /** The interaction collector */
75
+ private collector?;
76
+ /** The states represented in a map */
77
+ states: Map<string, PromptState<T>>;
78
+ /** Creates the prompt with a given set of states */
79
+ constructor(defaults: T, initialState: string, states: PromptState<T>[]);
80
+ /**
81
+ * Starts the prompt with a given interaction
82
+ * @param interaction The interaction starting off the sequence
83
+ * @returns {boolean} If true, the prompt started successfully
84
+ */
85
+ start(interaction: RepliableInteraction): Promise<boolean>;
86
+ private changeState;
87
+ private handleCollect;
88
+ private prepareMessageOptions;
89
+ private getNewStateFromCallback;
90
+ private registerComponents;
91
+ private unwrap;
92
+ private replyOrEdit;
93
+ }
94
+
95
+ export { type APIPromptButtonComponent, type APIPromptSelectMenuComponent, type APIPromptTopLevelComponent, Prompt, PromptButtonBuilder, type PromptContext, PromptError, PromptSelectMenuBuilder, type PromptState, type PromptStateMessageCallback, type RegisterComponentsOptions };
@@ -50,4 +50,46 @@ declare class PromptSelectMenuBuilder<Context extends object> extends StringSele
50
50
  getModal(): ModalBuilder | ((interaction: StringSelectMenuInteraction) => MaybePromise<ModalBuilder | null>) | undefined;
51
51
  }
52
52
 
53
- export { type APIPromptButtonComponent, type APIPromptSelectMenuComponent, type APIPromptTopLevelComponent, PromptButtonBuilder, type PromptContext, PromptSelectMenuBuilder, type PromptState, type PromptStateMessageCallback, type RegisterComponentsOptions };
53
+ declare class PromptError extends Error {
54
+ constructor(message: string);
55
+ }
56
+ /**
57
+ * A prompt that allows you to create a sequence of states that a user can go through
58
+ * with discord.js buttons and select menus.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const prompt = new Prompt<ContextType>(defaults, initialState.name, [...]);
63
+ * await prompt.start(interaction);
64
+ * ```
65
+ */
66
+ declare class Prompt<T extends object> {
67
+ initialState: string;
68
+ /** The current context of this prompt */
69
+ private context;
70
+ /** The current state */
71
+ private currentState?;
72
+ /** All components for this prompt */
73
+ private components;
74
+ /** The interaction collector */
75
+ private collector?;
76
+ /** The states represented in a map */
77
+ states: Map<string, PromptState<T>>;
78
+ /** Creates the prompt with a given set of states */
79
+ constructor(defaults: T, initialState: string, states: PromptState<T>[]);
80
+ /**
81
+ * Starts the prompt with a given interaction
82
+ * @param interaction The interaction starting off the sequence
83
+ * @returns {boolean} If true, the prompt started successfully
84
+ */
85
+ start(interaction: RepliableInteraction): Promise<boolean>;
86
+ private changeState;
87
+ private handleCollect;
88
+ private prepareMessageOptions;
89
+ private getNewStateFromCallback;
90
+ private registerComponents;
91
+ private unwrap;
92
+ private replyOrEdit;
93
+ }
94
+
95
+ export { type APIPromptButtonComponent, type APIPromptSelectMenuComponent, type APIPromptTopLevelComponent, Prompt, PromptButtonBuilder, type PromptContext, PromptError, PromptSelectMenuBuilder, type PromptState, type PromptStateMessageCallback, type RegisterComponentsOptions };
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/v2/index.ts
22
+ var v2_exports = {};
23
+ __export(v2_exports, {
24
+ Prompt: () => Prompt,
25
+ PromptButtonBuilder: () => PromptButtonBuilder,
26
+ PromptError: () => PromptError,
27
+ PromptSelectMenuBuilder: () => PromptSelectMenuBuilder
28
+ });
29
+ module.exports = __toCommonJS(v2_exports);
30
+
31
+ // src/v2/Prompt.ts
32
+ var import_node_util = require("util");
33
+ var import_discord2 = require("discord.js");
34
+
35
+ // src/v2/prompt.types.ts
36
+ var import_discord = require("discord.js");
37
+ var PromptButtonBuilder = class extends import_discord.ButtonBuilder {
38
+ static {
39
+ __name(this, "PromptButtonBuilder");
40
+ }
41
+ callback;
42
+ modal;
43
+ setCallback(callback) {
44
+ this.callback = callback;
45
+ return this;
46
+ }
47
+ getCallback() {
48
+ return this.callback;
49
+ }
50
+ setModal(modal) {
51
+ this.modal = modal;
52
+ return this;
53
+ }
54
+ getModal() {
55
+ return this.modal;
56
+ }
57
+ };
58
+ var PromptSelectMenuBuilder = class extends import_discord.StringSelectMenuBuilder {
59
+ static {
60
+ __name(this, "PromptSelectMenuBuilder");
61
+ }
62
+ callback;
63
+ modal;
64
+ setCallback(callback) {
65
+ this.callback = callback;
66
+ return this;
67
+ }
68
+ getCallback() {
69
+ return this.callback;
70
+ }
71
+ setModal(modal) {
72
+ this.modal = modal;
73
+ return this;
74
+ }
75
+ getModal() {
76
+ return this.modal;
77
+ }
78
+ };
79
+
80
+ // src/v2/Prompt.ts
81
+ var PromptError = class _PromptError extends Error {
82
+ static {
83
+ __name(this, "PromptError");
84
+ }
85
+ constructor(message) {
86
+ super(message);
87
+ Error.captureStackTrace?.(this, _PromptError);
88
+ }
89
+ };
90
+ var Prompt = class {
91
+ /** Creates the prompt with a given set of states */
92
+ constructor(defaults, initialState, states) {
93
+ this.initialState = initialState;
94
+ const previousStates = [];
95
+ const goBack = /* @__PURE__ */ __name(() => {
96
+ return this.context.previousStates.pop() ?? this.initialState;
97
+ }, "goBack");
98
+ this.context = { ...defaults, previousStates, goBack };
99
+ this.states = new Map(states.map((s) => [s.name, s]));
100
+ }
101
+ static {
102
+ __name(this, "Prompt");
103
+ }
104
+ /** The current context of this prompt */
105
+ context;
106
+ /** The current state */
107
+ currentState;
108
+ /** All components for this prompt */
109
+ components = new import_discord2.Collection();
110
+ /** The interaction collector */
111
+ collector;
112
+ /** The states represented in a map */
113
+ states;
114
+ /**
115
+ * Starts the prompt with a given interaction
116
+ * @param interaction The interaction starting off the sequence
117
+ * @returns {boolean} If true, the prompt started successfully
118
+ */
119
+ async start(interaction) {
120
+ this.context.interaction = interaction;
121
+ return this.changeState(this.initialState, interaction);
122
+ }
123
+ async changeState(newState, interaction) {
124
+ const state = this.states.get(newState);
125
+ if (!state) return Promise.reject(new PromptError(`State ${newState} not found.`));
126
+ this.context.previousStates.push(this.currentState?.name ?? this.initialState);
127
+ this.currentState = state;
128
+ const shouldChangeState = await state.onEntered?.(this.context);
129
+ if (shouldChangeState) return this.changeState(shouldChangeState, interaction);
130
+ this.components.clear();
131
+ const messageOptions = await this.prepareMessageOptions(state);
132
+ const msg = await this.replyOrEdit(interaction, messageOptions);
133
+ if (this.collector) this.collector.stop();
134
+ this.collector = msg.createMessageComponentCollector({
135
+ time: state.timeout || 12e4,
136
+ filter: /* @__PURE__ */ __name((i) => i.user.id === interaction.user.id, "filter")
137
+ });
138
+ this.collector.on("collect", this.handleCollect.bind(this));
139
+ return true;
140
+ }
141
+ async handleCollect(interaction) {
142
+ const component = this.components.get(interaction.customId);
143
+ if (!component) throw new PromptError(`Couldn't find component with customId: ${interaction.customId}`);
144
+ if (component.modal) {
145
+ const modal = await this.unwrap(component.modal, interaction);
146
+ if (!modal) {
147
+ await interaction.deferUpdate();
148
+ this.collector?.stop();
149
+ this.context.interaction = interaction;
150
+ const newState3 = await this.getNewStateFromCallback(component) ?? this.currentState?.name;
151
+ if (!newState3) return interaction.deleteReply();
152
+ return void this.changeState(newState3, interaction);
153
+ }
154
+ const snowflake = import_discord2.SnowflakeUtil.generate().toString();
155
+ modal.setCustomId(snowflake);
156
+ await interaction.showModal(modal);
157
+ const response = await interaction.awaitModalSubmit({
158
+ time: 3e5,
159
+ filter: /* @__PURE__ */ __name((i) => i.user.id === interaction.user.id && i.customId === snowflake, "filter")
160
+ }).catch(() => null);
161
+ if (!response) return;
162
+ await response.deferUpdate();
163
+ this.collector?.stop();
164
+ this.context.interaction = response;
165
+ const newState2 = await this.getNewStateFromCallback(component, response) ?? this.currentState?.name;
166
+ if (!newState2) return interaction.deleteReply();
167
+ return void this.changeState(newState2, interaction);
168
+ }
169
+ await interaction.deferUpdate();
170
+ this.collector?.stop();
171
+ this.context.interaction = interaction;
172
+ const newState = await this.getNewStateFromCallback(component) ?? this.currentState?.name;
173
+ if (!newState) return interaction.deleteReply();
174
+ return void this.changeState(newState, interaction);
175
+ }
176
+ async prepareMessageOptions(state) {
177
+ const messageData = await this.unwrap(state.message, this.context);
178
+ const components = await this.unwrap(messageData.components, this.context);
179
+ this.registerComponents(components);
180
+ console.log((0, import_node_util.inspect)(components, { depth: null }));
181
+ const messageOptions = {
182
+ components,
183
+ fetchReply: true,
184
+ flags: (messageData.ephemeral ? import_discord2.MessageFlags.Ephemeral : 0) | import_discord2.MessageFlags.IsComponentsV2
185
+ };
186
+ return messageOptions;
187
+ }
188
+ async getNewStateFromCallback(component, modalInteraction) {
189
+ if (!component.callback) return void 0;
190
+ if (typeof component.callback === "string") return component.callback;
191
+ if (component.modal) {
192
+ if (!modalInteraction) throw new PromptError("No modal submit interaction found when required.");
193
+ return component.callback(
194
+ this.context,
195
+ modalInteraction
196
+ );
197
+ }
198
+ return component.callback(
199
+ this.context
200
+ );
201
+ }
202
+ registerComponents(components) {
203
+ for (const builder of components) {
204
+ if (builder instanceof PromptButtonBuilder) {
205
+ const id = import_discord2.SnowflakeUtil.generate().toString();
206
+ builder.setCustomId(id);
207
+ this.components.set(id, {
208
+ ...builder.toJSON(),
209
+ custom_id: id,
210
+ callback: builder.getCallback(),
211
+ modal: builder.getModal()
212
+ });
213
+ } else if (builder instanceof PromptSelectMenuBuilder) {
214
+ const id = import_discord2.SnowflakeUtil.generate().toString();
215
+ builder.setCustomId(id);
216
+ this.components.set(id, {
217
+ ...builder.toJSON(),
218
+ custom_id: id,
219
+ callback: builder.getCallback(),
220
+ modal: builder.getModal()
221
+ });
222
+ } else if (builder instanceof import_discord2.SectionBuilder && builder.accessory instanceof PromptButtonBuilder) {
223
+ const id = import_discord2.SnowflakeUtil.generate().toString();
224
+ builder.accessory.setCustomId(id);
225
+ this.components.set(id, {
226
+ ...builder.accessory.toJSON(),
227
+ custom_id: id,
228
+ callback: builder.accessory.getCallback(),
229
+ modal: builder.accessory.getModal()
230
+ });
231
+ } else if ("components" in builder && Array.isArray(builder.components)) {
232
+ this.registerComponents(builder.components);
233
+ }
234
+ }
235
+ }
236
+ async unwrap(value, ...args) {
237
+ if (typeof value === "function") {
238
+ return value(...args);
239
+ }
240
+ return value;
241
+ }
242
+ async replyOrEdit(interaction, options) {
243
+ if (interaction.replied || interaction.deferred) {
244
+ return interaction.editReply({ components: options.components });
245
+ }
246
+ return interaction.reply(options);
247
+ }
248
+ };
249
+ // Annotate the CommonJS export names for ESM import in node:
250
+ 0 && (module.exports = {
251
+ Prompt,
252
+ PromptButtonBuilder,
253
+ PromptError,
254
+ PromptSelectMenuBuilder
255
+ });
@@ -0,0 +1,235 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/v2/Prompt.ts
5
+ import { inspect } from "util";
6
+ import {
7
+ Collection,
8
+ MessageFlags,
9
+ SectionBuilder,
10
+ SnowflakeUtil
11
+ } from "discord.js";
12
+
13
+ // src/v2/prompt.types.ts
14
+ import {
15
+ ButtonBuilder,
16
+ StringSelectMenuBuilder
17
+ } from "discord.js";
18
+ var PromptButtonBuilder = class extends ButtonBuilder {
19
+ static {
20
+ __name(this, "PromptButtonBuilder");
21
+ }
22
+ callback;
23
+ modal;
24
+ setCallback(callback) {
25
+ this.callback = callback;
26
+ return this;
27
+ }
28
+ getCallback() {
29
+ return this.callback;
30
+ }
31
+ setModal(modal) {
32
+ this.modal = modal;
33
+ return this;
34
+ }
35
+ getModal() {
36
+ return this.modal;
37
+ }
38
+ };
39
+ var PromptSelectMenuBuilder = class extends StringSelectMenuBuilder {
40
+ static {
41
+ __name(this, "PromptSelectMenuBuilder");
42
+ }
43
+ callback;
44
+ modal;
45
+ setCallback(callback) {
46
+ this.callback = callback;
47
+ return this;
48
+ }
49
+ getCallback() {
50
+ return this.callback;
51
+ }
52
+ setModal(modal) {
53
+ this.modal = modal;
54
+ return this;
55
+ }
56
+ getModal() {
57
+ return this.modal;
58
+ }
59
+ };
60
+
61
+ // src/v2/Prompt.ts
62
+ var PromptError = class _PromptError extends Error {
63
+ static {
64
+ __name(this, "PromptError");
65
+ }
66
+ constructor(message) {
67
+ super(message);
68
+ Error.captureStackTrace?.(this, _PromptError);
69
+ }
70
+ };
71
+ var Prompt = class {
72
+ /** Creates the prompt with a given set of states */
73
+ constructor(defaults, initialState, states) {
74
+ this.initialState = initialState;
75
+ const previousStates = [];
76
+ const goBack = /* @__PURE__ */ __name(() => {
77
+ return this.context.previousStates.pop() ?? this.initialState;
78
+ }, "goBack");
79
+ this.context = { ...defaults, previousStates, goBack };
80
+ this.states = new Map(states.map((s) => [s.name, s]));
81
+ }
82
+ static {
83
+ __name(this, "Prompt");
84
+ }
85
+ /** The current context of this prompt */
86
+ context;
87
+ /** The current state */
88
+ currentState;
89
+ /** All components for this prompt */
90
+ components = new Collection();
91
+ /** The interaction collector */
92
+ collector;
93
+ /** The states represented in a map */
94
+ states;
95
+ /**
96
+ * Starts the prompt with a given interaction
97
+ * @param interaction The interaction starting off the sequence
98
+ * @returns {boolean} If true, the prompt started successfully
99
+ */
100
+ async start(interaction) {
101
+ this.context.interaction = interaction;
102
+ return this.changeState(this.initialState, interaction);
103
+ }
104
+ async changeState(newState, interaction) {
105
+ const state = this.states.get(newState);
106
+ if (!state) return Promise.reject(new PromptError(`State ${newState} not found.`));
107
+ this.context.previousStates.push(this.currentState?.name ?? this.initialState);
108
+ this.currentState = state;
109
+ const shouldChangeState = await state.onEntered?.(this.context);
110
+ if (shouldChangeState) return this.changeState(shouldChangeState, interaction);
111
+ this.components.clear();
112
+ const messageOptions = await this.prepareMessageOptions(state);
113
+ const msg = await this.replyOrEdit(interaction, messageOptions);
114
+ if (this.collector) this.collector.stop();
115
+ this.collector = msg.createMessageComponentCollector({
116
+ time: state.timeout || 12e4,
117
+ filter: /* @__PURE__ */ __name((i) => i.user.id === interaction.user.id, "filter")
118
+ });
119
+ this.collector.on("collect", this.handleCollect.bind(this));
120
+ return true;
121
+ }
122
+ async handleCollect(interaction) {
123
+ const component = this.components.get(interaction.customId);
124
+ if (!component) throw new PromptError(`Couldn't find component with customId: ${interaction.customId}`);
125
+ if (component.modal) {
126
+ const modal = await this.unwrap(component.modal, interaction);
127
+ if (!modal) {
128
+ await interaction.deferUpdate();
129
+ this.collector?.stop();
130
+ this.context.interaction = interaction;
131
+ const newState3 = await this.getNewStateFromCallback(component) ?? this.currentState?.name;
132
+ if (!newState3) return interaction.deleteReply();
133
+ return void this.changeState(newState3, interaction);
134
+ }
135
+ const snowflake = SnowflakeUtil.generate().toString();
136
+ modal.setCustomId(snowflake);
137
+ await interaction.showModal(modal);
138
+ const response = await interaction.awaitModalSubmit({
139
+ time: 3e5,
140
+ filter: /* @__PURE__ */ __name((i) => i.user.id === interaction.user.id && i.customId === snowflake, "filter")
141
+ }).catch(() => null);
142
+ if (!response) return;
143
+ await response.deferUpdate();
144
+ this.collector?.stop();
145
+ this.context.interaction = response;
146
+ const newState2 = await this.getNewStateFromCallback(component, response) ?? this.currentState?.name;
147
+ if (!newState2) return interaction.deleteReply();
148
+ return void this.changeState(newState2, interaction);
149
+ }
150
+ await interaction.deferUpdate();
151
+ this.collector?.stop();
152
+ this.context.interaction = interaction;
153
+ const newState = await this.getNewStateFromCallback(component) ?? this.currentState?.name;
154
+ if (!newState) return interaction.deleteReply();
155
+ return void this.changeState(newState, interaction);
156
+ }
157
+ async prepareMessageOptions(state) {
158
+ const messageData = await this.unwrap(state.message, this.context);
159
+ const components = await this.unwrap(messageData.components, this.context);
160
+ this.registerComponents(components);
161
+ console.log(inspect(components, { depth: null }));
162
+ const messageOptions = {
163
+ components,
164
+ fetchReply: true,
165
+ flags: (messageData.ephemeral ? MessageFlags.Ephemeral : 0) | MessageFlags.IsComponentsV2
166
+ };
167
+ return messageOptions;
168
+ }
169
+ async getNewStateFromCallback(component, modalInteraction) {
170
+ if (!component.callback) return void 0;
171
+ if (typeof component.callback === "string") return component.callback;
172
+ if (component.modal) {
173
+ if (!modalInteraction) throw new PromptError("No modal submit interaction found when required.");
174
+ return component.callback(
175
+ this.context,
176
+ modalInteraction
177
+ );
178
+ }
179
+ return component.callback(
180
+ this.context
181
+ );
182
+ }
183
+ registerComponents(components) {
184
+ for (const builder of components) {
185
+ if (builder instanceof PromptButtonBuilder) {
186
+ const id = SnowflakeUtil.generate().toString();
187
+ builder.setCustomId(id);
188
+ this.components.set(id, {
189
+ ...builder.toJSON(),
190
+ custom_id: id,
191
+ callback: builder.getCallback(),
192
+ modal: builder.getModal()
193
+ });
194
+ } else if (builder instanceof PromptSelectMenuBuilder) {
195
+ const id = SnowflakeUtil.generate().toString();
196
+ builder.setCustomId(id);
197
+ this.components.set(id, {
198
+ ...builder.toJSON(),
199
+ custom_id: id,
200
+ callback: builder.getCallback(),
201
+ modal: builder.getModal()
202
+ });
203
+ } else if (builder instanceof SectionBuilder && builder.accessory instanceof PromptButtonBuilder) {
204
+ const id = SnowflakeUtil.generate().toString();
205
+ builder.accessory.setCustomId(id);
206
+ this.components.set(id, {
207
+ ...builder.accessory.toJSON(),
208
+ custom_id: id,
209
+ callback: builder.accessory.getCallback(),
210
+ modal: builder.accessory.getModal()
211
+ });
212
+ } else if ("components" in builder && Array.isArray(builder.components)) {
213
+ this.registerComponents(builder.components);
214
+ }
215
+ }
216
+ }
217
+ async unwrap(value, ...args) {
218
+ if (typeof value === "function") {
219
+ return value(...args);
220
+ }
221
+ return value;
222
+ }
223
+ async replyOrEdit(interaction, options) {
224
+ if (interaction.replied || interaction.deferred) {
225
+ return interaction.editReply({ components: options.components });
226
+ }
227
+ return interaction.reply(options);
228
+ }
229
+ };
230
+ export {
231
+ Prompt,
232
+ PromptButtonBuilder,
233
+ PromptError,
234
+ PromptSelectMenuBuilder
235
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moody-djs/prompts",
3
3
  "description": "A simple library for creating state based prompts in discord.js",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "test": "tsc --noEmit --skipLibCheck",
@@ -29,6 +29,16 @@
29
29
  "import": "./dist/v2/index.mjs"
30
30
  }
31
31
  },
32
+ "typesVersions": {
33
+ "*": {
34
+ "v2": [
35
+ "./dist/v2/index.d.ts"
36
+ ],
37
+ "index": [
38
+ "./dist/index.d.ts"
39
+ ]
40
+ }
41
+ },
32
42
  "peerDependencies": {
33
43
  "discord.js": "latest"
34
44
  },
package/dist/Prompt.d.mts DELETED
@@ -1,42 +0,0 @@
1
- import { RepliableInteraction } from 'discord.js';
2
- import { PromptState } from './types/prompt.types.mjs';
3
- import './types/util.types.mjs';
4
-
5
- /**
6
- * A prompt that allows you to create a sequence of states that a user can go through
7
- * with discord.js buttons and select menus.
8
- *
9
- * @example
10
- * ```ts
11
- * const prompt = new Prompt<ContextType>(defaults, initialState.name, [...]);
12
- * await prompt.start(interaction);
13
- * ```
14
- */
15
- declare class Prompt<T extends object> {
16
- initialState: string;
17
- /** The current context of this prompt */
18
- private context;
19
- /** The current state */
20
- private currentState?;
21
- /** All components for this prompt */
22
- private components;
23
- /** The interaction collector */
24
- private collector?;
25
- /** The states represented in a map */
26
- states: Map<string, PromptState<T>>;
27
- /** Creates the prompt with a given set of states */
28
- constructor(defaults: T, initialState: string, states: PromptState<T>[]);
29
- /**
30
- * Starts the prompt with a given interaction
31
- * @param interaction The interaction starting off the sequence
32
- * @returns {boolean} If true, the prompt started successfully
33
- */
34
- start(interaction: RepliableInteraction): Promise<boolean>;
35
- private changeState;
36
- private handleCollect;
37
- private prepareMessageOptions;
38
- private getNewStateFromCallback;
39
- private formatComponents;
40
- }
41
-
42
- export { Prompt };
package/dist/Prompt.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { RepliableInteraction } from 'discord.js';
2
- import { PromptState } from './types/prompt.types.js';
3
- import './types/util.types.js';
4
-
5
- /**
6
- * A prompt that allows you to create a sequence of states that a user can go through
7
- * with discord.js buttons and select menus.
8
- *
9
- * @example
10
- * ```ts
11
- * const prompt = new Prompt<ContextType>(defaults, initialState.name, [...]);
12
- * await prompt.start(interaction);
13
- * ```
14
- */
15
- declare class Prompt<T extends object> {
16
- initialState: string;
17
- /** The current context of this prompt */
18
- private context;
19
- /** The current state */
20
- private currentState?;
21
- /** All components for this prompt */
22
- private components;
23
- /** The interaction collector */
24
- private collector?;
25
- /** The states represented in a map */
26
- states: Map<string, PromptState<T>>;
27
- /** Creates the prompt with a given set of states */
28
- constructor(defaults: T, initialState: string, states: PromptState<T>[]);
29
- /**
30
- * Starts the prompt with a given interaction
31
- * @param interaction The interaction starting off the sequence
32
- * @returns {boolean} If true, the prompt started successfully
33
- */
34
- start(interaction: RepliableInteraction): Promise<boolean>;
35
- private changeState;
36
- private handleCollect;
37
- private prepareMessageOptions;
38
- private getNewStateFromCallback;
39
- private formatComponents;
40
- }
41
-
42
- export { Prompt };