oopscord.js 0.0.20 → 0.0.22

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 +1 @@
1
- {"version":3,"file":"DiscordApp.d.ts","sourceRoot":"","sources":["../../src/structures/DiscordApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsG,MAAM,EAAgF,MAAM,YAAY,CAAC;AAMtN,OAAO,EAAc,MAAM,EAAE,MAAM,GAAG,CAAC;AAEvC,MAAM,WAAW,MAAM;IACnB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAOD,qBAAa,iBAAiB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK1C,aAAa;IACb,QAAQ;CAGX;AAID,qBAAa,UAAU;;;IAuBb,KAAK;IA4PX,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,iBAAiB,EAAE,OAAO,GAAE,iBAAsB;CAWzF"}
1
+ {"version":3,"file":"DiscordApp.d.ts","sourceRoot":"","sources":["../../src/structures/DiscordApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsG,MAAM,EAAgF,MAAM,YAAY,CAAC;AAMtN,OAAO,EAAc,MAAM,EAAE,MAAM,GAAG,CAAC;AAEvC,MAAM,WAAW,MAAM;IACnB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAOD,qBAAa,iBAAiB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK1C,aAAa;IACb,QAAQ;CAGX;AAID,qBAAa,UAAU;;;IAuBb,KAAK;IA8PX,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,iBAAiB,EAAE,OAAO,GAAE,iBAAsB;CAWzF"}
@@ -53,10 +53,11 @@ class DiscordApp {
53
53
  const name = Reflect.getMetadata(Constants_1.COMMAND_NAME_KEY, c);
54
54
  const description = Reflect.getMetadata(Constants_1.COMMAND_DESCRIPTION_KEY, c);
55
55
  const options = Reflect.getMetadata(Constants_1.COMMAND_OPTIONS_KEY, c) ?? [];
56
+ const requiredOptions = options.filter(o => o.required);
56
57
  const data = new discord_js_1.SlashCommandBuilder()
57
58
  .setName(name)
58
59
  .setDescription(description);
59
- Reflect.set(data, "options", options);
60
+ Reflect.set(data, "options", [...requiredOptions, ...options.filter(o => !o.required)]);
60
61
  this.#module.logger.info(`Mapped global command ${name}.`);
61
62
  return data.toJSON();
62
63
  });
@@ -68,10 +69,11 @@ class DiscordApp {
68
69
  const name = Reflect.getMetadata(Constants_1.COMMAND_NAME_KEY, c);
69
70
  const description = Reflect.getMetadata(Constants_1.COMMAND_DESCRIPTION_KEY, c);
70
71
  const options = Reflect.getMetadata(Constants_1.COMMAND_OPTIONS_KEY, c) ?? [];
72
+ const requiredOptions = options.filter(o => o.required);
71
73
  const data = new discord_js_1.SlashCommandBuilder()
72
74
  .setName(name)
73
75
  .setDescription(description);
74
- Reflect.set(data, "options", options);
76
+ Reflect.set(data, "options", [...requiredOptions, ...options.filter(o => !o.required)]);
75
77
  if (!Array.isArray(apiPrivateCommands[guildId]))
76
78
  apiPrivateCommands[guildId] = [];
77
79
  apiPrivateCommands[guildId].push(data.toJSON());
@@ -16,7 +16,7 @@ class BaseModal {
16
16
  modal
17
17
  .setTitle(options.title)
18
18
  .setCustomId(options.customId);
19
- modal.setComponents(new discord_js_1.ActionRowBuilder(...components.map(c => c.toJSON())));
19
+ modal.setComponents(components.map(c => new discord_js_1.ActionRowBuilder().addComponents(c)));
20
20
  this.modal = modal;
21
21
  return modal;
22
22
  }
@@ -89,9 +89,9 @@ function TextInput(options) {
89
89
  exports.TextInput = TextInput;
90
90
  function TextInputFieldInjection(customId) {
91
91
  return function (target, _propertyKey, parameterIndex) {
92
- const fields = Reflect.getMetadata(_1.MODAL_FIELD_INDEX_KEY, target.constructor) ?? [];
92
+ const fields = Reflect.getMetadata(_1.MODAL_FIELD_INDEX_KEY, target) ?? [];
93
93
  fields.push({ index: parameterIndex, customId });
94
- Reflect.defineMetadata(_1.MODAL_FIELD_INDEX_KEY, fields, target.constructor);
94
+ Reflect.defineMetadata(_1.MODAL_FIELD_INDEX_KEY, fields, target);
95
95
  };
96
96
  }
97
97
  exports.TextInputFieldInjection = TextInputFieldInjection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oopscord.js",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "An easy way to make discord apps in typescript.",
5
5
  "main": "dist",
6
6
  "scripts": {