@open-discord-bots/framework 0.3.8 → 0.3.10

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.3.8"));
47
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.10"));
48
48
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
49
49
  this.debugfile = managers.debugfile;
50
50
  this.console = managers.console;
@@ -1,70 +1,40 @@
1
1
  import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
2
- import { ODMessage } from "./builder.js";
3
2
  import { ODDebugger } from "./console.js";
4
3
  import { ODButtonResponderInstance } from "./responder.js";
5
- import * as discord from "discord.js";
6
4
  import { ODWorkerManager } from "./worker.js";
7
5
  /**## ODVerifyBar `class`
8
- * @deprecated Use `ODMessageComponentModifier`'s instead.
9
- * This is an Open Discord verifybar.
6
+ * This is an Open Discord verifybar responder.
10
7
  *
11
- * It is contains 2 sets of workers and a lot of utilities for the (✅ ❌) verifybars in the bot.
8
+ * It contain `ODWorkerManager`'s that will be fired when the continue/stop (✅ ❌) buttons are pressed.
12
9
  *
13
- * It doesn't contain the code which activates or spawns the verifybars!
10
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
14
11
  */
15
- export declare class ODVerifyBar<SuccessWorkerIds extends string = string, FailureWorkerIds extends string = string> extends ODManagerData {
16
- /**All workers that will run when the verifybar is accepted. */
17
- success: ODWorkerManager<ODButtonResponderInstance, "verifybar", {
18
- data: string | null;
19
- verifybarMessage: discord.Message<boolean> | null;
20
- }, SuccessWorkerIds>;
21
- /**All workers that will run when the verifybar is stopped. */
22
- failure: ODWorkerManager<ODButtonResponderInstance, "verifybar", {
23
- data: string | null;
24
- verifybarMessage: discord.Message<boolean> | null;
25
- }, FailureWorkerIds>;
26
- /**The message that will be built wen activating this verifybar. */
27
- message: ODMessage<"verifybar", {
28
- guild: discord.Guild | null;
29
- channel: discord.TextBasedChannel;
30
- user: discord.User;
31
- verifybar: ODVerifyBar;
32
- originalMessage: discord.Message<boolean>;
33
- }>;
34
- /**When disabled, it will skip the verifybar and instantly fire the `success` workers. */
35
- enabled: boolean;
36
- constructor(id: ODValidId, message: ODMessage<"verifybar", {
37
- guild: discord.Guild | null;
38
- channel: discord.TextBasedChannel;
39
- user: discord.User;
40
- verifybar: ODVerifyBar;
41
- originalMessage: discord.Message<boolean>;
42
- }>, enabled?: boolean);
43
- /**Build the message and reply to a button with this verifybar. */
44
- activate(responder: ODButtonResponderInstance): Promise<void>;
12
+ export declare class ODVerifyBar<ButtonIds extends string, WorkerIds extends string = string> extends ODManagerData {
13
+ /**All workers that will run when a button in the verifybar is pressed. */
14
+ workers: ODWorkerManager<ODButtonResponderInstance, "verifybar", {
15
+ verifybar: ODVerifyBar<ButtonIds, WorkerIds>;
16
+ selectedButtonId: ButtonIds;
17
+ }, WorkerIds>;
18
+ constructor(id: ODValidId);
19
+ /**Activate the verifybar response to this button. */
20
+ activate(responder: ODButtonResponderInstance, selectedButtonId: ButtonIds): Promise<void>;
45
21
  }
46
22
  /**## ODVerifyBarManagerIdConstraint `type`
47
- * @deprecated Use `ODMessageComponentModifier`'s instead.
48
23
  * The constraint/layout for id mappings/interfaces of the `ODVerifyBarManager` class.
49
24
  */
50
- export type ODVerifyBarManagerIdConstraint = Record<string, {
51
- successWorkerIds: string;
52
- failureWorkerIds: string;
53
- }>;
25
+ export type ODVerifyBarManagerIdConstraint = Record<string, ODVerifyBar<string>>;
54
26
  /**## ODVerifyBarManager `class`
55
- * @deprecated Use `ODMessageComponentModifier`'s instead.
56
- *
57
- * The Open Discord verifybar manager manages all (✅ ❌) verifybars in the bot.
27
+ * The Open Discord verifybar manager manages all responders for (✅ ❌) verifybars in the bot.
58
28
  * The `ODVerifyBar` classes contain `ODWorkerManager`'s that will be fired when the continue/stop buttons are pressed.
59
29
  *
60
- * It doesn't contain the code which activates the verifybars! This should be implemented by your own.
30
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
61
31
  */
62
- export declare class ODVerifyBarManager<IdList extends ODVerifyBarManagerIdConstraint = ODVerifyBarManagerIdConstraint> extends ODManager<ODVerifyBar> {
32
+ export declare class ODVerifyBarManager<IdList extends ODVerifyBarManagerIdConstraint = ODVerifyBarManagerIdConstraint> extends ODManager<ODVerifyBar<string>> {
63
33
  constructor(debug: ODDebugger);
64
- get<VerifyBarId extends keyof ODNoGeneric<IdList>>(id: VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"], IdList[VerifyBarId]["failureWorkerIds"]>;
65
- get(id: ODValidId): ODVerifyBar | null;
66
- remove<VerifyBarId extends keyof ODNoGeneric<IdList>>(id: VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"], IdList[VerifyBarId]["failureWorkerIds"]>;
67
- remove(id: ODValidId): ODVerifyBar | null;
34
+ get<VerifyBarId extends keyof ODNoGeneric<IdList>>(id: VerifyBarId): IdList[VerifyBarId];
35
+ get(id: ODValidId): ODVerifyBar<string> | null;
36
+ remove<VerifyBarId extends keyof ODNoGeneric<IdList>>(id: VerifyBarId): IdList[VerifyBarId];
37
+ remove(id: ODValidId): ODVerifyBar<string> | null;
68
38
  exists(id: keyof ODNoGeneric<IdList>): boolean;
69
39
  exists(id: ODValidId): boolean;
70
40
  }
@@ -4,50 +4,29 @@
4
4
  import { ODManager, ODManagerData } from "./base.js";
5
5
  import { ODWorkerManager } from "./worker.js";
6
6
  /**## ODVerifyBar `class`
7
- * @deprecated Use `ODMessageComponentModifier`'s instead.
8
- * This is an Open Discord verifybar.
7
+ * This is an Open Discord verifybar responder.
9
8
  *
10
- * It is contains 2 sets of workers and a lot of utilities for the (✅ ❌) verifybars in the bot.
9
+ * It contain `ODWorkerManager`'s that will be fired when the continue/stop (✅ ❌) buttons are pressed.
11
10
  *
12
- * It doesn't contain the code which activates or spawns the verifybars!
11
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
13
12
  */
14
13
  export class ODVerifyBar extends ODManagerData {
15
- /**All workers that will run when the verifybar is accepted. */
16
- success;
17
- /**All workers that will run when the verifybar is stopped. */
18
- failure;
19
- /**The message that will be built wen activating this verifybar. */
20
- message;
21
- /**When disabled, it will skip the verifybar and instantly fire the `success` workers. */
22
- enabled;
23
- constructor(id, message, enabled) {
14
+ /**All workers that will run when a button in the verifybar is pressed. */
15
+ workers;
16
+ constructor(id) {
24
17
  super(id);
25
- this.success = new ODWorkerManager("descending");
26
- this.failure = new ODWorkerManager("descending");
27
- this.message = message;
28
- this.enabled = enabled ?? true;
18
+ this.workers = new ODWorkerManager("descending");
29
19
  }
30
- /**Build the message and reply to a button with this verifybar. */
31
- async activate(responder) {
32
- if (this.enabled) {
33
- //show verifybar
34
- const { guild, channel, user, message } = responder;
35
- await responder.update(await this.message.build("verifybar", { guild, channel, user, verifybar: this, originalMessage: message }));
36
- }
37
- else {
38
- //instant success
39
- if (this.success)
40
- await this.success.executeWorkers(responder, "verifybar", { data: null, verifybarMessage: null });
41
- }
20
+ /**Activate the verifybar response to this button. */
21
+ async activate(responder, selectedButtonId) {
22
+ await this.workers.executeWorkers(responder, "verifybar", { verifybar: this, selectedButtonId });
42
23
  }
43
24
  }
44
25
  /**## ODVerifyBarManager `class`
45
- * @deprecated Use `ODMessageComponentModifier`'s instead.
46
- *
47
- * The Open Discord verifybar manager manages all (✅ ❌) verifybars in the bot.
26
+ * The Open Discord verifybar manager manages all responders for (✅ ❌) verifybars in the bot.
48
27
  * The `ODVerifyBar` classes contain `ODWorkerManager`'s that will be fired when the continue/stop buttons are pressed.
49
28
  *
50
- * It doesn't contain the code which activates the verifybars! This should be implemented by your own.
29
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
51
30
  */
52
31
  export class ODVerifyBarManager extends ODManager {
53
32
  constructor(debug) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.3.8",
4
+ "version": "0.3.10",
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",
package/src/api/main.ts CHANGED
@@ -154,7 +154,7 @@ export abstract class ODMain implements ODMainManagers {
154
154
  constructor(managers:ODMainManagers,project:ODProjectType){
155
155
  this.project = project
156
156
  this.versions = managers.versions
157
- this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.8"))
157
+ this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.10"))
158
158
  this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
159
159
 
160
160
  this.debugfile = managers.debugfile
@@ -2,81 +2,60 @@
2
2
  //VERIFYBAR MODULE
3
3
  ///////////////////////////////////////
4
4
  import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js"
5
- import { ODMessage } from "./builder.js"
6
5
  import { ODDebugger } from "./console.js"
7
6
  import { ODButtonResponderInstance } from "./responder.js"
8
- import * as discord from "discord.js"
9
7
  import { ODWorkerManager } from "./worker.js"
8
+ import * as discord from "discord.js"
10
9
 
11
10
  /**## ODVerifyBar `class`
12
- * @deprecated Use `ODMessageComponentModifier`'s instead.
13
- * This is an Open Discord verifybar.
11
+ * This is an Open Discord verifybar responder.
14
12
  *
15
- * It is contains 2 sets of workers and a lot of utilities for the (✅ ❌) verifybars in the bot.
13
+ * It contain `ODWorkerManager`'s that will be fired when the continue/stop (✅ ❌) buttons are pressed.
16
14
  *
17
- * It doesn't contain the code which activates or spawns the verifybars!
15
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
18
16
  */
19
- export class ODVerifyBar<SuccessWorkerIds extends string = string,FailureWorkerIds extends string = string,> extends ODManagerData {
20
- /**All workers that will run when the verifybar is accepted. */
21
- success: ODWorkerManager<ODButtonResponderInstance,"verifybar",{data:string|null,verifybarMessage:discord.Message<boolean>|null},SuccessWorkerIds>
22
- /**All workers that will run when the verifybar is stopped. */
23
- failure: ODWorkerManager<ODButtonResponderInstance,"verifybar",{data:string|null,verifybarMessage:discord.Message<boolean>|null},FailureWorkerIds>
24
- /**The message that will be built wen activating this verifybar. */
25
- message: ODMessage<"verifybar",{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:ODVerifyBar,originalMessage:discord.Message<boolean>}>
26
- /**When disabled, it will skip the verifybar and instantly fire the `success` workers. */
27
- enabled: boolean
28
-
29
- constructor(id:ODValidId, message:ODMessage<"verifybar",{guild:discord.Guild|null,channel:discord.TextBasedChannel,user:discord.User,verifybar:ODVerifyBar,originalMessage:discord.Message<boolean>}>, enabled?:boolean){
17
+ export class ODVerifyBar<ButtonIds extends string,WorkerIds extends string = string> extends ODManagerData {
18
+ /**All workers that will run when a button in the verifybar is pressed. */
19
+ workers: ODWorkerManager<ODButtonResponderInstance,"verifybar",{verifybar:ODVerifyBar<ButtonIds,WorkerIds>,selectedButtonId:ButtonIds},WorkerIds>
20
+
21
+ constructor(id:ODValidId){
30
22
  super(id)
31
- this.success = new ODWorkerManager("descending")
32
- this.failure = new ODWorkerManager("descending")
33
- this.message = message
34
- this.enabled = enabled ?? true
23
+ this.workers = new ODWorkerManager("descending")
35
24
  }
36
25
 
37
- /**Build the message and reply to a button with this verifybar. */
38
- async activate(responder:ODButtonResponderInstance){
39
- if (this.enabled){
40
- //show verifybar
41
- const {guild,channel,user,message} = responder
42
- await responder.update(await this.message.build("verifybar",{guild,channel,user,verifybar:this,originalMessage:message}))
43
- }else{
44
- //instant success
45
- if (this.success) await this.success.executeWorkers(responder,"verifybar",{data:null,verifybarMessage:null})
46
- }
26
+ /**Activate the verifybar response to this button. */
27
+ async activate(responder:ODButtonResponderInstance,selectedButtonId:ButtonIds){
28
+ await this.workers.executeWorkers(responder,"verifybar",{verifybar:this,selectedButtonId})
47
29
  }
48
30
  }
49
31
 
50
32
  /**## ODVerifyBarManagerIdConstraint `type`
51
- * @deprecated Use `ODMessageComponentModifier`'s instead.
52
33
  * The constraint/layout for id mappings/interfaces of the `ODVerifyBarManager` class.
53
34
  */
54
- export type ODVerifyBarManagerIdConstraint = Record<string,{successWorkerIds:string,failureWorkerIds:string}>
35
+ export type ODVerifyBarManagerIdConstraint = Record<string,ODVerifyBar<string>>
55
36
 
56
37
  /**## ODVerifyBarManager `class`
57
- * @deprecated Use `ODMessageComponentModifier`'s instead.
58
- *
59
- * The Open Discord verifybar manager manages all (✅ ❌) verifybars in the bot.
38
+ * The Open Discord verifybar manager manages all responders for (✅ ❌) verifybars in the bot.
60
39
  * The `ODVerifyBar` classes contain `ODWorkerManager`'s that will be fired when the continue/stop buttons are pressed.
61
40
  *
62
- * It doesn't contain the code which activates the verifybars! This should be implemented by your own.
41
+ * Verifybars don't automatically trigger these workers. The button responders of the verifybars should implement it manually.
63
42
  */
64
- export class ODVerifyBarManager<IdList extends ODVerifyBarManagerIdConstraint = ODVerifyBarManagerIdConstraint> extends ODManager<ODVerifyBar> {
43
+ export class ODVerifyBarManager<IdList extends ODVerifyBarManagerIdConstraint = ODVerifyBarManagerIdConstraint> extends ODManager<ODVerifyBar<string>> {
65
44
  constructor(debug:ODDebugger){
66
45
  super(debug,"verifybar")
67
46
  }
68
47
 
69
- get<VerifyBarId extends keyof ODNoGeneric<IdList>>(id:VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"],IdList[VerifyBarId]["failureWorkerIds"]>
70
- get(id:ODValidId): ODVerifyBar|null
48
+ get<VerifyBarId extends keyof ODNoGeneric<IdList>>(id:VerifyBarId): IdList[VerifyBarId]
49
+ get(id:ODValidId): ODVerifyBar<string>|null
71
50
 
72
- get(id:ODValidId): ODVerifyBar|null {
51
+ get(id:ODValidId): ODVerifyBar<string>|null {
73
52
  return super.get(id)
74
53
  }
75
54
 
76
- remove<VerifyBarId extends keyof ODNoGeneric<IdList>>(id:VerifyBarId): ODVerifyBar<IdList[VerifyBarId]["successWorkerIds"],IdList[VerifyBarId]["failureWorkerIds"]>
77
- remove(id:ODValidId): ODVerifyBar|null
55
+ remove<VerifyBarId extends keyof ODNoGeneric<IdList>>(id:VerifyBarId): IdList[VerifyBarId]
56
+ remove(id:ODValidId): ODVerifyBar<string>|null
78
57
 
79
- remove(id:ODValidId): ODVerifyBar|null {
58
+ remove(id:ODValidId): ODVerifyBar<string>|null {
80
59
  return super.remove(id)
81
60
  }
82
61