@kevlid/discordmenus 0.1.0 → 0.1.2

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/index.d.ts CHANGED
@@ -220,6 +220,10 @@ export declare class MenuStorage {
220
220
  constructor(options?: MenuStorageOptions);
221
221
  get(key: string, ctx?: StorageContext): Promise<unknown>;
222
222
  save(key: string, value: unknown, ctx?: StorageContext): Promise<void>;
223
+ cacheKey(key: string, guildId?: string | null): string;
224
+ cacheGet(key: string, guildId?: string | null): unknown;
225
+ cacheSet(key: string, value: unknown, guildId?: string | null): void;
226
+ cacheDelete(key: string, guildId?: string | null): void;
223
227
  cacheClear(guildId?: string): void;
224
228
  handler(): StorageHandler;
225
229
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevlid/discordmenus",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Components v2 settings menus for Discord bots",
5
5
  "main": "src/index.js",
6
6
  "types": "index.d.ts",
@@ -361,9 +361,11 @@ async function handleComponent(interaction, menu, menu_key, renderMenu) {
361
361
  action === OptionTypes.ChannelSelect
362
362
  ) {
363
363
  const optionKey = values[0];
364
- const selected = interactionData.values ?? [];
364
+ const selected = Array.isArray(interactionData.values) ? interactionData.values : [];
365
365
  const opt = menu.getOption(category, page, optionKey);
366
- const saveValue = opt && opt.maxValues === 1 ? selected[0] ?? null : selected;
366
+ const maxSel = Number(opt?.maxValues);
367
+ const multi = Number.isFinite(maxSel) && maxSel > 1;
368
+ const saveValue = multi ? [...selected] : selected[0] ?? null;
367
369
  await menu.save(optionKey, saveValue, { guildId, userId });
368
370
  result = updateMessage(
369
371
  await renderMenu(menu_key, { category, index: page, userId, guildId }),