@mostfeatured/dbi 0.1.2 → 0.1.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.
package/src/Events.ts CHANGED
@@ -1,16 +1,30 @@
1
1
  import { NamespaceEnums, NamespaceData } from "../generated/namespaceData";
2
2
  import { DBI } from "./DBI";
3
3
  import { TDBIMessageCommandArgumentErrorTypes } from "./methods/handleMessageCommands";
4
+ import { TDBIValueName } from "./types/ChatInput/ChatInputOptions";
4
5
  import { ClientEvents, DBIEvent } from "./types/Event";
5
6
  import { IDBIBaseExecuteCtx, TDBIRateLimitTypes } from "./types/Interaction";
6
7
  import { FakeMessageInteraction } from "./types/other/FakeMessageInteraction";
7
8
  import { DBILocale } from "./types/other/Locale";
8
9
  import Discord from "discord.js";
9
10
 
10
- export type TDBIEventNames = "beforeInteraction" | "afterInteraction" | "interactionRateLimit" | "beforeEvent" | "afterEvent" | "interactionError" | "eventError" | "messageCommandArgumentError";
11
+ export type TDBIEventNames =
12
+ | "beforeInteraction"
13
+ | "afterInteraction"
14
+ | "interactionRateLimit"
15
+ | "beforeEvent"
16
+ | "afterEvent"
17
+ | "interactionError"
18
+ | "eventError"
19
+ | "messageCommandArgumentError";
11
20
 
12
21
  export type TDBIEventHandlerCtx<TNamespace extends NamespaceEnums> = {
13
- [K in keyof (ClientEvents & NamespaceData[TNamespace]["customEvents"])]: { other: Record<string, any>, locale?: { guild: DBILocale<TNamespace> }, eventName: K, dbiEvent: DBIEvent<TNamespace> } & (ClientEvents & NamespaceData[TNamespace]["customEvents"])[K]
22
+ [K in keyof (ClientEvents & NamespaceData[TNamespace]["customEvents"])]: {
23
+ other: Record<string, any>;
24
+ locale?: { guild: DBILocale<TNamespace> };
25
+ eventName: K;
26
+ dbiEvent: DBIEvent<TNamespace>;
27
+ } & (ClientEvents & NamespaceData[TNamespace]["customEvents"])[K];
14
28
  }[keyof (ClientEvents & NamespaceData[TNamespace]["customEvents"])];
15
29
 
16
30
  export class Events<TNamespace extends NamespaceEnums> {
@@ -26,8 +40,8 @@ export class Events<TNamespace extends NamespaceEnums> {
26
40
  beforeEvent: [],
27
41
  afterEvent: [],
28
42
  interactionError: [],
29
- eventError: []
30
- }
43
+ eventError: [],
44
+ };
31
45
  }
32
46
 
33
47
  async trigger(name: TDBIEventNames, data: any): Promise<boolean> {
@@ -43,41 +57,71 @@ export class Events<TNamespace extends NamespaceEnums> {
43
57
 
44
58
  on(
45
59
  eventName: "beforeInteraction" | "afterInteraction",
46
- handler: (data: IDBIBaseExecuteCtx<TNamespace>) => Promise<boolean> | boolean,
60
+ handler: (
61
+ data: IDBIBaseExecuteCtx<TNamespace>
62
+ ) => Promise<boolean> | boolean,
47
63
  options?: { once: boolean }
48
- ): (() => any);
64
+ ): () => any;
49
65
 
50
66
  on(
51
67
  eventName: "interactionError",
52
- handler: (data: IDBIBaseExecuteCtx<TNamespace> & { error: any }) => Promise<boolean> | boolean,
68
+ handler: (
69
+ data: IDBIBaseExecuteCtx<TNamespace> & { error: any }
70
+ ) => Promise<boolean> | boolean,
53
71
  options?: { once: boolean }
54
- ): (() => any);
72
+ ): () => any;
55
73
 
56
74
  on(
57
75
  eventName: "beforeEvent" | "afterEvent",
58
- handler: (data: TDBIEventHandlerCtx<TNamespace>) => Promise<boolean> | boolean,
76
+ handler: (
77
+ data: TDBIEventHandlerCtx<TNamespace>
78
+ ) => Promise<boolean> | boolean,
59
79
  options?: { once: boolean }
60
- ): (() => any);
80
+ ): () => any;
61
81
 
62
82
  on(
63
83
  eventName: "eventError",
64
- handler: (data: TDBIEventHandlerCtx<TNamespace> & { error: any, dbiEvent: DBIEvent<TNamespace> }) => Promise<boolean> | boolean,
84
+ handler: (
85
+ data: TDBIEventHandlerCtx<TNamespace> & {
86
+ error: any;
87
+ dbiEvent: DBIEvent<TNamespace>;
88
+ }
89
+ ) => Promise<boolean> | boolean,
65
90
  options?: { once: boolean }
66
- ): (() => any);
91
+ ): () => any;
67
92
 
68
93
  on(
69
94
  eventName: "interactionRateLimit",
70
- handler: (data: Omit<IDBIBaseExecuteCtx<TNamespace>, "other" | "setRateLimit"> & { rateLimit: { type: TDBIRateLimitTypes, duration: number, at: number } }) => Promise<boolean> | boolean,
95
+ handler: (
96
+ data: Omit<IDBIBaseExecuteCtx<TNamespace>, "other" | "setRateLimit"> & {
97
+ rateLimit: { type: TDBIRateLimitTypes; duration: number; at: number };
98
+ }
99
+ ) => Promise<boolean> | boolean,
71
100
  options?: { once: boolean }
72
- ): (() => any);
101
+ ): () => any;
73
102
 
74
103
  on(
75
104
  eventName: "messageCommandArgumentError",
76
- handler: (data: { message: Discord.Message, interaction: FakeMessageInteraction, error: { type: TDBIMessageCommandArgumentErrorTypes, option: any, index: number, extra?: any }, value: any, locale: { guild?: DBILocale<TNamespace>, user: DBILocale<TNamespace> } }) => Promise<boolean> | boolean,
105
+ handler: (data: {
106
+ message: Discord.Message;
107
+ interaction: FakeMessageInteraction;
108
+ error: {
109
+ type: TDBIMessageCommandArgumentErrorTypes;
110
+ option: any;
111
+ index: number;
112
+ extra?: any;
113
+ };
114
+ value: any;
115
+ locale: { guild?: DBILocale<TNamespace>; user: DBILocale<TNamespace> };
116
+ }) => Promise<boolean> | boolean,
77
117
  options?: { once: boolean }
78
- ): (() => any);
118
+ ): () => any;
79
119
 
80
- on(eventName: TDBIEventNames, handler: (data: any) => Promise<boolean> | boolean, options: { once: boolean } = { once: false }): (() => any) {
120
+ on(
121
+ eventName: TDBIEventNames,
122
+ handler: (data: any) => Promise<boolean> | boolean,
123
+ options: { once: boolean } = { once: false }
124
+ ): () => any {
81
125
  if (!this.handlers.hasOwnProperty(eventName)) this.handlers[eventName] = [];
82
126
  if (options.once) {
83
127
  let h = (data) => {
@@ -87,18 +131,21 @@ export class Events<TNamespace extends NamespaceEnums> {
87
131
  this.on(eventName as any, h as any, { once: false });
88
132
  return () => {
89
133
  this.off(eventName, h);
90
- }
134
+ };
91
135
  } else {
92
136
  this.handlers[eventName].push(handler);
93
137
  return () => {
94
138
  this.off(eventName, handler);
95
- }
139
+ };
96
140
  }
97
141
  }
98
142
 
99
- off(eventName: TDBIEventNames, handler: (data: any) => Promise<boolean> | boolean) {
143
+ off(
144
+ eventName: TDBIEventNames,
145
+ handler: (data: any) => Promise<boolean> | boolean
146
+ ) {
100
147
  let l = this.handlers[eventName];
101
148
  if (!l) return [];
102
149
  return l.splice(l.indexOf(handler), 1);
103
150
  }
104
- }
151
+ }
@@ -1,4 +1,10 @@
1
- import { ApplicationCommandType, ChatInputCommandInteraction, Message, MessagePayload, ApplicationCommandOptionType } from "discord.js";
1
+ import {
2
+ ApplicationCommandType,
3
+ ChatInputCommandInteraction,
4
+ Message,
5
+ MessagePayload,
6
+ ApplicationCommandOptionType,
7
+ } from "discord.js";
2
8
  import { NamespaceEnums } from "../../generated/namespaceData";
3
9
  import { DBI } from "../DBI";
4
10
  import { FakeMessageInteraction } from "../types/other/FakeMessageInteraction";
@@ -7,24 +13,49 @@ import { TDBILocaleString } from "../types/other/Locale";
7
13
  const INTEGER_REGEX = /^-?\d+$/;
8
14
  const NUMBER_REGEX = /^-?\d+(?:\.\d+)?$/;
9
15
 
10
- export type TDBIMessageCommandArgumentErrorTypes = "MissingRequiredOption" | "MinLength" | "MaxLength" | "InvalidChoice" | "InvalidInteger" | "MinInteger" | "MaxInteger" | "InvalidNumber" | "MinNumber" | "MaxNumber" | "InvalidBoolean" | "InvalidUser" | "InvalidChannel" | "InvalidRole" | "InvalidMentionable" | "InvalidCompleteChoice";
16
+ export type TDBIMessageCommandArgumentErrorTypes =
17
+ | "MissingRequiredOption"
18
+ | "MinLength"
19
+ | "MaxLength"
20
+ | "InvalidChoice"
21
+ | "InvalidInteger"
22
+ | "MinInteger"
23
+ | "MaxInteger"
24
+ | "InvalidNumber"
25
+ | "MinNumber"
26
+ | "MaxNumber"
27
+ | "InvalidBoolean"
28
+ | "InvalidUser"
29
+ | "InvalidChannel"
30
+ | "InvalidRole"
31
+ | "InvalidMentionable"
32
+ | "InvalidCompleteChoice";
11
33
 
12
- export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: Message) {
13
- const chatInputs = dbi.data.interactions.filter(i => i.type === "ChatInput");
34
+ export async function handleMessageCommands(
35
+ dbi: DBI<NamespaceEnums>,
36
+ message: Message
37
+ ) {
38
+ const chatInputs = dbi.data.interactions.filter(
39
+ (i) => i.type === "ChatInput"
40
+ );
14
41
  const prefixes = dbi.config.messageCommands.prefixes ?? [];
15
42
  if (!prefixes.length) return;
16
43
  const content = message.content;
17
- const usedPrefix = prefixes.find(p => content.startsWith(p));
44
+ const usedPrefix = prefixes.find((p) => content.startsWith(p));
18
45
  if (!usedPrefix) return;
19
46
  const contentWithoutPrefix = content.slice(usedPrefix?.length ?? 0);
20
47
  const contentLower = contentWithoutPrefix.toLowerCase();
21
48
 
22
- let locale: string = message.guild.preferredLocale?.split("-")?.at(0) || dbi.config.defaults.locale as any;
49
+ let locale: string =
50
+ message.guild.preferredLocale?.split("-")?.at(0) ||
51
+ (dbi.config.defaults.locale as any);
23
52
  let usedAlias: string | undefined;
24
- let chatInput = chatInputs.find(i => {
53
+ let chatInput = chatInputs.find((i) => {
25
54
  let found = contentLower.startsWith(i.name);
26
55
  if (found) return true;
27
- let alias = i.other?.messageCommand?.aliases?.find(a => contentLower.startsWith(a));
56
+ let alias = i.other?.messageCommand?.aliases?.find((a) =>
57
+ contentLower.startsWith(a)
58
+ );
28
59
  if (alias) {
29
60
  usedAlias = alias;
30
61
  return true;
@@ -34,12 +65,15 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
34
65
  let commandName = usedAlias ?? chatInput?.name;
35
66
 
36
67
  if (!chatInput) {
37
- fLoop: for (const [localeInterName, localeData] of dbi.data.interactionLocales) {
38
- for (const [localeName, translation] of Object.entries(localeData.data || {})) {
68
+ fLoop: for (const [localeInterName, localeData] of dbi.data
69
+ .interactionLocales) {
70
+ for (const [localeName, translation] of Object.entries(
71
+ localeData.data || {}
72
+ )) {
39
73
  if (contentLower.startsWith(translation.name)) {
40
74
  commandName = translation.name;
41
75
  locale = localeName;
42
- chatInput = chatInputs.find(i => i.name === localeData.name);
76
+ chatInput = chatInputs.find((i) => i.name === localeData.name);
43
77
  break fLoop;
44
78
  }
45
79
  }
@@ -48,7 +82,14 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
48
82
 
49
83
  if (!chatInput) return;
50
84
 
51
- const interaction = new FakeMessageInteraction(dbi, message, chatInput as any, locale, commandName, usedPrefix);
85
+ const interaction = new FakeMessageInteraction(
86
+ dbi,
87
+ message,
88
+ chatInput as any,
89
+ locale,
90
+ commandName,
91
+ usedPrefix
92
+ );
52
93
 
53
94
  if (chatInput.options.length) {
54
95
  let errorType: TDBIMessageCommandArgumentErrorTypes;
@@ -66,21 +107,22 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
66
107
 
67
108
  switch (option.type) {
68
109
  case ApplicationCommandOptionType.String: {
69
-
70
110
  if (!option.required && !value) break;
71
111
 
72
112
  if (option.autocomplete && option.onComplete) {
73
113
  let choices = await option.onComplete({
74
114
  interaction,
75
- value
76
- });
77
- if (!choices.length) choices = await option.onComplete({
78
- interaction,
79
- value: ""
115
+ value,
80
116
  });
81
- if (choices.length > 20) throw new Error("Autocomplete returned more than 20 choices.");
117
+ if (!choices.length)
118
+ choices = await option.onComplete({
119
+ interaction,
120
+ value: "",
121
+ });
122
+ if (choices.length > 20)
123
+ throw new Error("Autocomplete returned more than 20 choices.");
82
124
  lastExtra = choices;
83
- if (!choices.find(c => c.name === value || c.value === value)) {
125
+ if (!choices.find((c) => c.name === value || c.value === value)) {
84
126
  if (value) {
85
127
  errorType = "InvalidCompleteChoice";
86
128
  break;
@@ -93,10 +135,25 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
93
135
  }
94
136
 
95
137
  if (option.choices) {
96
- const localeData = dbi.data.interactionLocales.get(chatInput.name)?.data;
97
- const choicesLocaleData = localeData?.[locale as TDBILocaleString]?.options?.[option.name]?.choices;
98
- if (!option.choices.find(c => c.name === value || c.value === value || (choicesLocaleData?.[c.value] && choicesLocaleData?.[c.value] === value))) {
99
- lastExtra = option.choices.map(c => ({ name: choicesLocaleData?.[c.value] ?? c.name, value: c.value }));
138
+ const localeData = dbi.data.interactionLocales.get(
139
+ chatInput.name
140
+ )?.data;
141
+ const choicesLocaleData =
142
+ localeData?.[locale as TDBILocaleString]?.options?.[option.name]
143
+ ?.choices;
144
+ if (
145
+ !option.choices.find(
146
+ (c) =>
147
+ c.name === value ||
148
+ c.value === value ||
149
+ (choicesLocaleData?.[c.value] &&
150
+ choicesLocaleData?.[c.value] === value)
151
+ )
152
+ ) {
153
+ lastExtra = option.choices.map((c) => ({
154
+ name: choicesLocaleData?.[c.value] ?? c.name,
155
+ value: c.value,
156
+ }));
100
157
  if (value) {
101
158
  errorType = "InvalidChoice";
102
159
  break;
@@ -108,11 +165,11 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
108
165
  break;
109
166
  }
110
167
 
111
- if (option.minLength && value.length < option.minLength) {
168
+ if (option.minLength && value?.length < option.minLength) {
112
169
  errorType = "MinLength";
113
170
  break;
114
171
  }
115
- if (option.maxLength && value.length > option.maxLength) {
172
+ if (option.maxLength && value?.length > option.maxLength) {
116
173
  errorType = "MaxLength";
117
174
  break;
118
175
  }
@@ -127,15 +184,19 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
127
184
  if (option.autocomplete && option.onComplete) {
128
185
  let choices = await option.onComplete({
129
186
  interaction,
130
- value
187
+ value,
131
188
  });
132
- if (!choices.length) choices = await option.onComplete({
133
- interaction,
134
- value: ""
135
- });
136
- if (choices.length > 20) throw new Error("Autocomplete returned more than 20 choices.");
189
+ if (!choices.length)
190
+ choices = await option.onComplete({
191
+ interaction,
192
+ value: "",
193
+ });
194
+ if (choices.length > 20)
195
+ throw new Error("Autocomplete returned more than 20 choices.");
137
196
  lastExtra = choices;
138
- if (!choices.find(c => c.value === parsedInt || c.name === value)) {
197
+ if (
198
+ !choices.find((c) => c.value === parsedInt || c.name === value)
199
+ ) {
139
200
  if (value) {
140
201
  errorType = "InvalidCompleteChoice";
141
202
  break;
@@ -149,10 +210,25 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
149
210
  }
150
211
 
151
212
  if (option.choices) {
152
- const localeData = dbi.data.interactionLocales.get(chatInput.name)?.data;
153
- const choicesLocaleData = localeData?.[locale as TDBILocaleString]?.options?.[option.name]?.choices;
154
- if (!option.choices.find(c => c.value === parsedInt || c.name === value || (choicesLocaleData?.[c.value] && choicesLocaleData?.[c.value] === value))) {
155
- lastExtra = option.choices.map(c => ({ name: choicesLocaleData?.[c.value] ?? c.name, value: c.value }));
213
+ const localeData = dbi.data.interactionLocales.get(
214
+ chatInput.name
215
+ )?.data;
216
+ const choicesLocaleData =
217
+ localeData?.[locale as TDBILocaleString]?.options?.[option.name]
218
+ ?.choices;
219
+ if (
220
+ !option.choices.find(
221
+ (c) =>
222
+ c.value === parsedInt ||
223
+ c.name === value ||
224
+ (choicesLocaleData?.[c.value] &&
225
+ choicesLocaleData?.[c.value] === value)
226
+ )
227
+ ) {
228
+ lastExtra = option.choices.map((c) => ({
229
+ name: choicesLocaleData?.[c.value] ?? c.name,
230
+ value: c.value,
231
+ }));
156
232
  if (value) {
157
233
  errorType = "InvalidChoice";
158
234
  break;
@@ -189,15 +265,19 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
189
265
  if (option.autocomplete && option.onComplete) {
190
266
  let choices = await option.onComplete({
191
267
  interaction,
192
- value
193
- });
194
- if (!choices.length) choices = await option.onComplete({
195
- interaction,
196
- value: ""
268
+ value,
197
269
  });
198
- if (choices.length > 20) throw new Error("Autocomplete returned more than 20 choices.");
270
+ if (!choices.length)
271
+ choices = await option.onComplete({
272
+ interaction,
273
+ value: "",
274
+ });
275
+ if (choices.length > 20)
276
+ throw new Error("Autocomplete returned more than 20 choices.");
199
277
  lastExtra = choices;
200
- if (!choices.find(c => c.value === parsedFloat || c.name === value)) {
278
+ if (
279
+ !choices.find((c) => c.value === parsedFloat || c.name === value)
280
+ ) {
201
281
  if (value) {
202
282
  errorType = "InvalidCompleteChoice";
203
283
  break;
@@ -211,10 +291,25 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
211
291
  }
212
292
 
213
293
  if (option.choices) {
214
- const localeData = dbi.data.interactionLocales.get(chatInput.name)?.data;
215
- const choicesLocaleData = localeData?.[locale as TDBILocaleString]?.options?.[option.name]?.choices;
216
- if (!option.choices.find(c => c.value === parsedFloat || c.name === value || (choicesLocaleData?.[c.value] && choicesLocaleData?.[c.value] === value))) {
217
- lastExtra = option.choices.map(c => ({ name: choicesLocaleData?.[c.value] ?? c.name, value: c.value }));
294
+ const localeData = dbi.data.interactionLocales.get(
295
+ chatInput.name
296
+ )?.data;
297
+ const choicesLocaleData =
298
+ localeData?.[locale as TDBILocaleString]?.options?.[option.name]
299
+ ?.choices;
300
+ if (
301
+ !option.choices.find(
302
+ (c) =>
303
+ c.value === parsedFloat ||
304
+ c.name === value ||
305
+ (choicesLocaleData?.[c.value] &&
306
+ choicesLocaleData?.[c.value] === value)
307
+ )
308
+ ) {
309
+ lastExtra = option.choices.map((c) => ({
310
+ name: choicesLocaleData?.[c.value] ?? c.name,
311
+ value: c.value,
312
+ }));
218
313
  if (value) {
219
314
  errorType = "InvalidChoice";
220
315
  break;
@@ -243,15 +338,19 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
243
338
  break;
244
339
  }
245
340
  case ApplicationCommandOptionType.Boolean: {
246
- let boolKeys = Object.keys(dbi.config.messageCommands.typeAliases.booleans);
247
- if (option.required && !boolKeys.includes(value.toLowerCase())) {
341
+ let boolKeys = Object.keys(
342
+ dbi.config.messageCommands.typeAliases.booleans
343
+ );
344
+ if (option.required && !boolKeys.includes(value?.toLowerCase?.())) {
248
345
  errorType = "InvalidBoolean";
249
346
  break;
250
347
  }
251
348
  break;
252
349
  }
253
350
  case ApplicationCommandOptionType.User: {
254
- await message.client.users.fetch(interaction.options.getUserId(option.name)).catch(() => { });
351
+ await message.client.users
352
+ .fetch(interaction.options.getUserId(option.name))
353
+ .catch(() => {});
255
354
  if (option.required && !interaction.options.getUser(option.name)) {
256
355
  errorType = "InvalidUser";
257
356
  break;
@@ -259,15 +358,26 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
259
358
  break;
260
359
  }
261
360
  case ApplicationCommandOptionType.Channel: {
262
- await message.client.channels.fetch(interaction.options.getChannelId(option.name)).catch(() => { });
263
- if (option.required && !interaction.options.getChannel(option.name, null, option.channelTypes)) {
361
+ await message.client.channels
362
+ .fetch(interaction.options.getChannelId(option.name))
363
+ .catch(() => {});
364
+ if (
365
+ option.required &&
366
+ !interaction.options.getChannel(
367
+ option.name,
368
+ null,
369
+ option.channelTypes
370
+ )
371
+ ) {
264
372
  errorType = "InvalidChannel";
265
373
  break;
266
374
  }
267
375
  break;
268
376
  }
269
377
  case ApplicationCommandOptionType.Role: {
270
- await message.guild.roles.fetch(interaction.options.getRoleId(option.name)).catch(() => { });
378
+ await message.guild.roles
379
+ .fetch(interaction.options.getRoleId(option.name))
380
+ .catch(() => {});
271
381
  if (option.required && !interaction.options.getRole(option.name)) {
272
382
  errorType = "InvalidRole";
273
383
  break;
@@ -276,10 +386,13 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
276
386
  }
277
387
  case ApplicationCommandOptionType.Mentionable: {
278
388
  let mentionableId = interaction.options.getMentionableId(option.name);
279
- await message.guild.roles.fetch(mentionableId).catch(() => { });
280
- await message.client.channels.fetch(mentionableId).catch(() => { });
281
- await message.client.users.fetch(mentionableId).catch(() => { });
282
- if (option.required && !interaction.options.getMentionable(option.name)) {
389
+ await message.guild.roles.fetch(mentionableId).catch(() => {});
390
+ await message.client.channels.fetch(mentionableId).catch(() => {});
391
+ await message.client.users.fetch(mentionableId).catch(() => {});
392
+ if (
393
+ option.required &&
394
+ !interaction.options.getMentionable(option.name)
395
+ ) {
283
396
  errorType = "InvalidMentionable";
284
397
  break;
285
398
  }
@@ -308,16 +421,22 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
308
421
  interaction,
309
422
  message,
310
423
  locale: {
311
- user: dbi.data.locales.get(interaction.locale) || dbi.data.locales.get(dbi.config.defaults.locale),
312
- guild: message.guild?.preferredLocale ? (dbi.data.locales.get(message.guild?.preferredLocale?.split("-")?.at(0)) || dbi.data.locales.get(dbi.config.defaults.locale)) : null
424
+ user:
425
+ dbi.data.locales.get(interaction.locale) ||
426
+ dbi.data.locales.get(dbi.config.defaults.locale),
427
+ guild: message.guild?.preferredLocale
428
+ ? dbi.data.locales.get(
429
+ message.guild?.preferredLocale?.split("-")?.at(0)
430
+ ) || dbi.data.locales.get(dbi.config.defaults.locale)
431
+ : null,
313
432
  },
314
433
  error: {
315
434
  type: errorType,
316
435
  option: lastOption,
317
436
  extra: lastExtra,
318
- index: lastIndex
437
+ index: lastIndex,
319
438
  },
320
- value: lastValue
439
+ value: lastValue,
321
440
  });
322
441
  if (!res) return;
323
442
  }
@@ -325,4 +444,4 @@ export async function handleMessageCommands(dbi: DBI<NamespaceEnums>, message: M
325
444
 
326
445
  interaction.init();
327
446
  dbi.data.clients.first().client.emit("interactionCreate", interaction as any);
328
- }
447
+ }