@open-discord-bots/framework 0.3.10 → 0.3.12
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 +1 -1
- package/dist/api/modules/component.d.ts +11 -11
- package/dist/api/modules/component.js +10 -6
- package/package.json +1 -1
- package/src/api/main.ts +1 -1
- package/src/api/modules/component.ts +17 -14
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.
|
|
47
|
+
this.versions.add(ODVersion.fromString("opendiscord:api", "v0.3.12"));
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { ODId, ODValidId, ODManagerData, ODNoGeneric, ODManager, ODValidButtonColor, ODInterfaceWithPartialProperty } from "./base.js";
|
|
2
2
|
import * as discord from "discord.js";
|
|
3
|
-
import { ODWorkerManager, ODWorkerCallback
|
|
3
|
+
import { ODWorkerManager, ODWorkerCallback } from "./worker.js";
|
|
4
4
|
import { ODDebugger } from "./console.js";
|
|
5
5
|
import { ODMessage, ODMessageInstance } from "./builder.js";
|
|
6
6
|
/**## ODComponentFactoryInstance `class`
|
|
@@ -60,7 +60,7 @@ export declare class ODBaseComponentManager<IdList extends ODComponentManagerIdC
|
|
|
60
60
|
/**## ODComponentModifierManagerIdConstraint `type`
|
|
61
61
|
* The constraint/layout for id mappings/interfaces of the `ODComponentModifierManager` class.
|
|
62
62
|
*/
|
|
63
|
-
export type ODComponentModifierManagerIdConstraint = Record<string, ODMessageComponentModifier<string, {}>>;
|
|
63
|
+
export type ODComponentModifierManagerIdConstraint = Record<string, ODMessageComponentModifier<string, {}, string>>;
|
|
64
64
|
/**## ODComponentModifierManager `class`
|
|
65
65
|
* An Open Discord component modifier manager.
|
|
66
66
|
*
|
|
@@ -68,12 +68,12 @@ export type ODComponentModifierManagerIdConstraint = Record<string, ODMessageCom
|
|
|
68
68
|
* - Patch, modify, expand or update existing messages
|
|
69
69
|
* - It Does not affect the original message (cloned)
|
|
70
70
|
*/
|
|
71
|
-
export declare class ODComponentModifierManager<IdList extends ODComponentModifierManagerIdConstraint = ODComponentModifierManagerIdConstraint> extends ODManager<ODMessageComponentModifier<string, {}>> {
|
|
71
|
+
export declare class ODComponentModifierManager<IdList extends ODComponentModifierManagerIdConstraint = ODComponentModifierManagerIdConstraint> extends ODManager<ODMessageComponentModifier<string, {}, string>> {
|
|
72
72
|
constructor(debug: ODDebugger);
|
|
73
73
|
get<ModifierId extends keyof ODNoGeneric<IdList>>(id: ModifierId): IdList[ModifierId];
|
|
74
|
-
get(id: ODValidId): ODMessageComponentModifier<string, {}> | null;
|
|
74
|
+
get(id: ODValidId): ODMessageComponentModifier<string, {}, string> | null;
|
|
75
75
|
remove<ModifierId extends keyof ODNoGeneric<IdList>>(id: ModifierId): IdList[ModifierId];
|
|
76
|
-
remove(id: ODValidId): ODMessageComponentModifier<string, {}> | null;
|
|
76
|
+
remove(id: ODValidId): ODMessageComponentModifier<string, {}, string> | null;
|
|
77
77
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
78
78
|
exists(id: ODValidId): boolean;
|
|
79
79
|
}
|
|
@@ -245,12 +245,12 @@ export declare abstract class ODParentComponent<Data extends object, ChildCompon
|
|
|
245
245
|
*
|
|
246
246
|
* Warning: If workers access external variables (outside parameters), the clone will still use those variables. This might result in unexpected behaviour!
|
|
247
247
|
*/
|
|
248
|
-
export declare class ODMessageComponentModifier<Origin extends string, Params> extends ODManagerData {
|
|
249
|
-
/**The
|
|
250
|
-
|
|
251
|
-
constructor(id: ODValidId,
|
|
252
|
-
/**Modify an `ODMessage` or `ODComponentFactory` with
|
|
253
|
-
modify<Message extends ODMessage<
|
|
248
|
+
export declare class ODMessageComponentModifier<Origin extends string, Params, WorkerIds extends string> extends ODManagerData {
|
|
249
|
+
/**The workers which will modify the message. */
|
|
250
|
+
workers: ODWorkerManager<ODMessageInstance | ODComponentFactoryInstance<ODMessageComponent>, Origin, Params, WorkerIds>;
|
|
251
|
+
constructor(id: ODValidId, callback?: ODWorkerCallback<ODMessageInstance | ODComponentFactoryInstance<ODMessageComponent>, Origin, Params>, priority?: number, callbackId?: ODValidId);
|
|
252
|
+
/**Modify an `ODMessage` or `ODComponentFactory` with these workers. A copy will be returned and the original is preserved. */
|
|
253
|
+
modify<Message extends ODMessage<Origin, Params, any> | ODComponentFactory<ODMessageComponent, Origin, Params, any>>(message: Message): Message;
|
|
254
254
|
}
|
|
255
255
|
/**## ODMessageComponentData `type`
|
|
256
256
|
* The configurable settings/options for the `ODMessageComponent`.
|
|
@@ -323,16 +323,20 @@ export class ODParentComponent extends ODComponent {
|
|
|
323
323
|
* Warning: If workers access external variables (outside parameters), the clone will still use those variables. This might result in unexpected behaviour!
|
|
324
324
|
*/
|
|
325
325
|
export class ODMessageComponentModifier extends ODManagerData {
|
|
326
|
-
/**The
|
|
327
|
-
|
|
328
|
-
constructor(id,
|
|
326
|
+
/**The workers which will modify the message. */
|
|
327
|
+
workers;
|
|
328
|
+
constructor(id, callback, priority, callbackId) {
|
|
329
329
|
super(id);
|
|
330
|
-
this.
|
|
330
|
+
this.workers = new ODWorkerManager("ascending");
|
|
331
|
+
if (callback)
|
|
332
|
+
this.workers.add(new ODWorker(callbackId ? callbackId : id, priority ?? 0, callback));
|
|
331
333
|
}
|
|
332
|
-
/**Modify an `ODMessage` or `ODComponentFactory` with
|
|
334
|
+
/**Modify an `ODMessage` or `ODComponentFactory` with these workers. A copy will be returned and the original is preserved. */
|
|
333
335
|
modify(message) {
|
|
334
336
|
const newMsg = message.duplicate(message.id.value + "-VERIFYBAR");
|
|
335
|
-
|
|
337
|
+
for (const worker of this.workers.getAll()) {
|
|
338
|
+
newMsg.workers.add(worker.duplicate());
|
|
339
|
+
}
|
|
336
340
|
return newMsg;
|
|
337
341
|
}
|
|
338
342
|
}
|
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.
|
|
4
|
+
"version": "0.3.12",
|
|
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.
|
|
157
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.12"))
|
|
158
158
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
159
159
|
|
|
160
160
|
this.debugfile = managers.debugfile
|
|
@@ -101,7 +101,7 @@ export class ODBaseComponentManager<IdList extends ODComponentManagerIdConstrain
|
|
|
101
101
|
/**## ODComponentModifierManagerIdConstraint `type`
|
|
102
102
|
* The constraint/layout for id mappings/interfaces of the `ODComponentModifierManager` class.
|
|
103
103
|
*/
|
|
104
|
-
export type ODComponentModifierManagerIdConstraint = Record<string,ODMessageComponentModifier<string,{}>>
|
|
104
|
+
export type ODComponentModifierManagerIdConstraint = Record<string,ODMessageComponentModifier<string,{},string>>
|
|
105
105
|
|
|
106
106
|
/**## ODComponentModifierManager `class`
|
|
107
107
|
* An Open Discord component modifier manager.
|
|
@@ -110,22 +110,22 @@ export type ODComponentModifierManagerIdConstraint = Record<string,ODMessageComp
|
|
|
110
110
|
* - Patch, modify, expand or update existing messages
|
|
111
111
|
* - It Does not affect the original message (cloned)
|
|
112
112
|
*/
|
|
113
|
-
export class ODComponentModifierManager<IdList extends ODComponentModifierManagerIdConstraint = ODComponentModifierManagerIdConstraint> extends ODManager<ODMessageComponentModifier<string,{}>> {
|
|
113
|
+
export class ODComponentModifierManager<IdList extends ODComponentModifierManagerIdConstraint = ODComponentModifierManagerIdConstraint> extends ODManager<ODMessageComponentModifier<string,{},string>> {
|
|
114
114
|
constructor(debug:ODDebugger){
|
|
115
115
|
super(debug,"component modifier")
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
get<ModifierId extends keyof ODNoGeneric<IdList>>(id:ModifierId): IdList[ModifierId]
|
|
119
|
-
get(id:ODValidId): ODMessageComponentModifier<string,{}>|null
|
|
119
|
+
get(id:ODValidId): ODMessageComponentModifier<string,{},string>|null
|
|
120
120
|
|
|
121
|
-
get(id:ODValidId): ODMessageComponentModifier<string,{}>|null {
|
|
121
|
+
get(id:ODValidId): ODMessageComponentModifier<string,{},string>|null {
|
|
122
122
|
return super.get(id)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
remove<ModifierId extends keyof ODNoGeneric<IdList>>(id:ModifierId): IdList[ModifierId]
|
|
126
|
-
remove(id:ODValidId): ODMessageComponentModifier<string,{}>|null
|
|
126
|
+
remove(id:ODValidId): ODMessageComponentModifier<string,{},string>|null
|
|
127
127
|
|
|
128
|
-
remove(id:ODValidId): ODMessageComponentModifier<string,{}>|null {
|
|
128
|
+
remove(id:ODValidId): ODMessageComponentModifier<string,{},string>|null {
|
|
129
129
|
return super.remove(id)
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -433,19 +433,22 @@ export abstract class ODParentComponent<Data extends object,ChildComponent exten
|
|
|
433
433
|
*
|
|
434
434
|
* Warning: If workers access external variables (outside parameters), the clone will still use those variables. This might result in unexpected behaviour!
|
|
435
435
|
*/
|
|
436
|
-
export class ODMessageComponentModifier<Origin extends string,Params> extends ODManagerData {
|
|
437
|
-
/**The
|
|
438
|
-
|
|
436
|
+
export class ODMessageComponentModifier<Origin extends string,Params,WorkerIds extends string> extends ODManagerData {
|
|
437
|
+
/**The workers which will modify the message. */
|
|
438
|
+
workers: ODWorkerManager<ODMessageInstance|ODComponentFactoryInstance<ODMessageComponent>,Origin,Params,WorkerIds>
|
|
439
439
|
|
|
440
|
-
constructor(id:ODValidId,
|
|
440
|
+
constructor(id:ODValidId,callback?:ODWorkerCallback<ODMessageInstance|ODComponentFactoryInstance<ODMessageComponent>,Origin,Params>, priority?:number, callbackId?:ODValidId){
|
|
441
441
|
super(id)
|
|
442
|
-
this.
|
|
442
|
+
this.workers = new ODWorkerManager("ascending")
|
|
443
|
+
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
443
444
|
}
|
|
444
445
|
|
|
445
|
-
/**Modify an `ODMessage` or `ODComponentFactory` with
|
|
446
|
-
modify<Message extends ODMessage<
|
|
446
|
+
/**Modify an `ODMessage` or `ODComponentFactory` with these workers. A copy will be returned and the original is preserved. */
|
|
447
|
+
modify<Message extends ODMessage<Origin,Params,any>|ODComponentFactory<ODMessageComponent,Origin,Params,any>>(message:Message): Message {
|
|
447
448
|
const newMsg = message.duplicate(message.id.value+"-VERIFYBAR") as Message
|
|
448
|
-
|
|
449
|
+
for (const worker of this.workers.getAll()){
|
|
450
|
+
newMsg.workers.add(worker.duplicate())
|
|
451
|
+
}
|
|
449
452
|
return newMsg
|
|
450
453
|
}
|
|
451
454
|
}
|