zumito-framework 1.2.18 → 1.2.19

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.
@@ -1,4 +1,6 @@
1
+ import { ModalSubmitParameters } from '@definitions/parameters/ModalSubmitParameters.js';
1
2
  import { SelectMenuParameters } from '../parameters/SelectMenuParameters.js';
2
3
  export declare type CommandBinds = {
3
4
  selectMenu?: (params: SelectMenuParameters) => Promise<void>;
5
+ modalSubmit?: (params: ModalSubmitParameters) => Promise<void>;
4
6
  };
@@ -0,0 +1,10 @@
1
+ import { ModalSubmitInteraction } from 'discord.js';
2
+ export interface ModalSubmitParameters {
3
+ path: string[];
4
+ interaction: ModalSubmitInteraction;
5
+ /**
6
+ * @deprecated
7
+ */
8
+ guildSettings?: any;
9
+ trans: (key: string, params?: any) => string;
10
+ }
package/dist/index.d.ts CHANGED
@@ -30,4 +30,6 @@ import { Route, RouteMethod } from './definitions/Route.js';
30
30
  import { InteractionHandler } from './services/InteractionHandler.js';
31
31
  import { CommandManager } from './services/CommandManager.js';
32
32
  import { ErrorType } from './definitions/ErrorType.js';
33
+ export { ModalSubmitParameters } from './definitions/parameters/ModalSubmitParameters.js';
34
+ export { CommandBinds } from './definitions/commands/CommandBinds.js';
33
35
  export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition, CommandChoiceDefinition, ButtonPressed, ButtonPressedParams, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, PresenceDataRule, RuledPresenceData, StatusManagerOptions, discord, EventParameters, ServiceContainer, GuildDataGetter, SlashCommandRefresher, CommandParser, ErrorHandler, ErrorType, Route, RouteMethod, InteractionHandler, CommandManager };
@@ -184,7 +184,15 @@ export class InteractionHandler {
184
184
  throw new Error(`Command ${path[0]} not found or modal id bad formatted`);
185
185
  }
186
186
  const framework = ServiceContainer.getService(ZumitoFramework);
187
- if (commandInstance.modalSubmit) {
187
+ if (commandInstance.binds?.modalSubmit) {
188
+ const trans = this.translationManager.getShortHandMethod('command.' + commandInstance.name, guildSettings?.lang);
189
+ commandInstance.binds.modalSubmit({
190
+ interaction,
191
+ path,
192
+ trans,
193
+ });
194
+ }
195
+ else if (commandInstance.modalSubmit) {
188
196
  if (!guildSettings && interaction.guildId) {
189
197
  guildSettings = await ServiceContainer.getService(GuildDataGetter).getGuildSettings(interaction.guildId);
190
198
  }
@@ -196,11 +204,9 @@ export class InteractionHandler {
196
204
  guildSettings,
197
205
  });
198
206
  }
199
- else {
200
- this.eventManager.emitEvent('modalSubmit', 'framework', {
201
- client: this.client,
202
- path, interaction, framework, guildSettings,
203
- });
204
- }
207
+ this.eventManager.emitEvent('modalSubmit', 'framework', {
208
+ client: this.client,
209
+ path, interaction, framework, guildSettings,
210
+ });
205
211
  }
206
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "Discord.js bot framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",