@open-discord-bots/framework 0.4.6 → 0.4.8

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/dist/api/main.js CHANGED
@@ -44,7 +44,7 @@ export class ODMain {
44
44
  constructor(managers, project) {
45
45
  this.project = project;
46
46
  this.versions = managers.versions;
47
- this.versions.add(ODVersion.fromString("opendiscord:api", "v0.4.6"));
47
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.4.8"));
48
48
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
49
49
  this.debugfile = managers.debugfile;
50
50
  this.console = managers.console;
@@ -2,7 +2,7 @@ import { ODId, ODValidId, ODManagerData, ODNoGeneric, ODManager, ODValidButtonCo
2
2
  import * as discord from "discord.js";
3
3
  import { ODWorkerManager, ODWorkerCallback } from "./worker.js";
4
4
  import { ODDebugger } from "./console.js";
5
- import { ODMessage, ODMessageInstance } from "./builder.js";
5
+ import { ODMessage, ODMessageInstance, ODModalBuildResult } from "./builder.js";
6
6
  /**## ODComponentFactoryInstance `class`
7
7
  * An Open Discord component factory instance.
8
8
  *
@@ -395,9 +395,12 @@ export type ODValidModalComponents = ODLabelComponent | ODTextComponent;
395
395
  * A modal builder with **components v2** support.
396
396
  * Add questions, select menu's & labels to this modal using `addComponent()`.
397
397
  */
398
- export declare class ODModalComponent extends ODGroupComponent<ODModalComponentData, ODValidModalComponents, discord.ModalBuilder> {
398
+ export declare class ODModalComponent extends ODGroupComponent<ODModalComponentData, ODValidModalComponents, ODModalBuildResult> {
399
399
  constructor(id: ODValidId, data?: Partial<ODModalComponentData>);
400
- build(): Promise<discord.ModalBuilder>;
400
+ build(): Promise<{
401
+ id: ODId;
402
+ modal: discord.ModalBuilder;
403
+ }>;
401
404
  /**Set the title of the modal. */
402
405
  setTitle(title: string): this;
403
406
  /**Set the custom id of this modal. */
@@ -858,6 +861,8 @@ export interface ODDropdownComponentData {
858
861
  maxValues?: number;
859
862
  /**Is this dropdown disabled? */
860
863
  disabled?: boolean;
864
+ /**Is this dropdown required? (MODAL ONLY) */
865
+ required?: boolean;
861
866
  /**Allowed channel types when the type is "channel" */
862
867
  channelTypes?: discord.ChannelType[];
863
868
  /**The options when the type is "string" */
@@ -890,6 +895,8 @@ export declare class ODDropdownComponent extends ODComponent<ODDropdownComponent
890
895
  setPlaceholder(placeholder: string | null): this;
891
896
  /**Disable this dropdown. */
892
897
  setDisabled(disabled: boolean): this;
898
+ /**Mark this dropdown as required in modals. */
899
+ setRequired(required: boolean): this;
893
900
  /**Set the available channel types of this dropdown. */
894
901
  setChannelTypes(channelTypes: discord.ChannelType[]): this;
895
902
  /**Set the options of this dropdown (when `type == "string"`) */
@@ -538,11 +538,14 @@ export class ODModalComponent extends ODGroupComponent {
538
538
  components.push(res.toJSON());
539
539
  }
540
540
  }
541
- return new discord.ModalBuilder({
542
- components,
543
- title: this.data.title,
544
- customId: this.data.customId
545
- });
541
+ return {
542
+ id: new ODId(this.id),
543
+ modal: new discord.ModalBuilder({
544
+ components,
545
+ title: this.data.title,
546
+ customId: this.data.customId
547
+ })
548
+ };
546
549
  }
547
550
  /**Set the title of the modal. */
548
551
  setTitle(title) {
@@ -1253,7 +1256,7 @@ export class ODDropdownComponent extends ODComponent {
1253
1256
  return new discord.StringSelectMenuBuilder({
1254
1257
  ...genericOpts,
1255
1258
  options: this.data.options
1256
- });
1259
+ }).setRequired(this.data.required ?? false);
1257
1260
  }
1258
1261
  else if (this.data.type == "user") {
1259
1262
  if (!this.data.users || this.data.users.length < 1)
@@ -1261,7 +1264,7 @@ export class ODDropdownComponent extends ODComponent {
1261
1264
  return new discord.UserSelectMenuBuilder({
1262
1265
  ...genericOpts,
1263
1266
  defaultValues: this.data.users.map((u) => ({ id: u.id, type: discord.SelectMenuDefaultValueType.User }))
1264
- });
1267
+ }).setRequired(this.data.required ?? false);
1265
1268
  }
1266
1269
  else if (this.data.type == "role") {
1267
1270
  if (!this.data.roles || this.data.roles.length < 1)
@@ -1269,7 +1272,7 @@ export class ODDropdownComponent extends ODComponent {
1269
1272
  return new discord.RoleSelectMenuBuilder({
1270
1273
  ...genericOpts,
1271
1274
  defaultValues: this.data.roles.map((r) => ({ id: r.id, type: discord.SelectMenuDefaultValueType.Role }))
1272
- });
1275
+ }).setRequired(this.data.required ?? false);
1273
1276
  }
1274
1277
  else if (this.data.type == "channel") {
1275
1278
  if (!this.data.channels || this.data.channels.length < 1)
@@ -1278,7 +1281,7 @@ export class ODDropdownComponent extends ODComponent {
1278
1281
  ...genericOpts,
1279
1282
  channelTypes: this.data.channelTypes,
1280
1283
  defaultValues: this.data.channels.map((c) => ({ id: c.id, type: discord.SelectMenuDefaultValueType.Channel }))
1281
- });
1284
+ }).setRequired(this.data.required ?? false);
1282
1285
  }
1283
1286
  else if (this.data.type == "mentionable") {
1284
1287
  if (!this.data.mentionables || this.data.mentionables.length < 1)
@@ -1286,7 +1289,7 @@ export class ODDropdownComponent extends ODComponent {
1286
1289
  return new discord.MentionableSelectMenuBuilder({
1287
1290
  ...genericOpts,
1288
1291
  defaultValues: this.data.mentionables.map((m) => (m instanceof discord.User ? { id: m.id, type: discord.SelectMenuDefaultValueType.User } : { id: m.id, type: discord.SelectMenuDefaultValueType.Role }))
1289
- });
1292
+ }).setRequired(this.data.required ?? false);
1290
1293
  }
1291
1294
  else
1292
1295
  throw new ODSystemError("ODDropdownComponent:build('" + this.id.value + "') => Please set the dropdown type to one of the following: string, user, role, channel, mentionable.");
@@ -1321,6 +1324,11 @@ export class ODDropdownComponent extends ODComponent {
1321
1324
  this.data.disabled = disabled;
1322
1325
  return this;
1323
1326
  }
1327
+ /**Mark this dropdown as required in modals. */
1328
+ setRequired(required) {
1329
+ this.data.required = required;
1330
+ return this;
1331
+ }
1324
1332
  /**Set the available channel types of this dropdown. */
1325
1333
  setChannelTypes(channelTypes) {
1326
1334
  this.data.channelTypes = channelTypes;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.4.6",
4
+ "version": "0.4.8",
5
5
  "description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",