@open-discord-bots/framework 0.3.6 → 0.3.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 +1 -1
- package/dist/api/modules/builder.d.ts +2 -0
- package/dist/api/modules/builder.js +8 -0
- package/dist/api/modules/component.d.ts +90 -7
- package/dist/api/modules/component.js +143 -27
- package/dist/api/modules/fuse.d.ts +2 -0
- package/dist/api/modules/fuse.js +1 -0
- package/dist/api/modules/state.d.ts +6 -6
- package/dist/api/modules/verifybar.d.ts +4 -2
- package/dist/api/modules/verifybar.js +3 -2
- package/dist/api/modules/worker.d.ts +2 -0
- package/dist/api/modules/worker.js +4 -0
- package/package.json +1 -1
- package/src/api/main.ts +1 -1
- package/src/api/modules/builder.ts +8 -0
- package/src/api/modules/component.ts +202 -31
- package/src/api/modules/fuse.ts +3 -0
- package/src/api/modules/state.ts +8 -8
- package/src/api/modules/verifybar.ts +4 -2
- package/src/api/modules/worker.ts +5 -0
package/src/api/modules/state.ts
CHANGED
|
@@ -73,7 +73,7 @@ export interface ODStateSettings {
|
|
|
73
73
|
*
|
|
74
74
|
* Features automatic garbage collection to clear expired states.
|
|
75
75
|
*/
|
|
76
|
-
export class ODState<StateData extends any,WithGuildKey extends boolean
|
|
76
|
+
export class ODState<StateData extends any,WithGuildKey extends boolean,WithUserKey extends boolean> extends ODManagerData {
|
|
77
77
|
/**Alias to Open Discord message states database. */
|
|
78
78
|
protected database: ODDatabase<ODDatabaseIdConstraint>
|
|
79
79
|
/**Alias to Open Discord client manager. */
|
|
@@ -251,14 +251,14 @@ export class ODState<StateData extends any,WithGuildKey extends boolean = true,W
|
|
|
251
251
|
/**## ODStateManagerIdConstraint `type`
|
|
252
252
|
* The constraint/layout for id mappings/interfaces of the `ODStateManager` class.
|
|
253
253
|
*/
|
|
254
|
-
export type ODStateManagerIdConstraint = Record<string,ODState<any>>
|
|
254
|
+
export type ODStateManagerIdConstraint = Record<string,ODState<any,boolean,boolean>>
|
|
255
255
|
|
|
256
256
|
/**## ODStateManager `class`
|
|
257
257
|
* The Open Discord state manager is a system for tracking messages or linking metadata, states or progress to Discord messages (ID-based).
|
|
258
258
|
*
|
|
259
259
|
* Features automatic garbage collection to clear expired states.
|
|
260
260
|
*/
|
|
261
|
-
export class ODStateManager<IdList extends ODStateManagerIdConstraint = ODStateManagerIdConstraint> extends ODManager<ODState<any>> {
|
|
261
|
+
export class ODStateManager<IdList extends ODStateManagerIdConstraint = ODStateManagerIdConstraint> extends ODManager<ODState<any,boolean,boolean>> {
|
|
262
262
|
constructor(debug:ODDebugger){
|
|
263
263
|
super(debug,"state")
|
|
264
264
|
}
|
|
@@ -270,22 +270,22 @@ export class ODStateManager<IdList extends ODStateManagerIdConstraint = ODStateM
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
add(data:ODState<any>, overwrite?:boolean): boolean {
|
|
273
|
+
add(data:ODState<any,boolean,boolean>, overwrite?:boolean): boolean {
|
|
274
274
|
data.useDebug(this.debug)
|
|
275
275
|
return super.add(data,overwrite)
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
get<StateId extends keyof ODNoGeneric<IdList>>(id:StateId): IdList[StateId]
|
|
279
|
-
get(id:ODValidId): ODState<any>|null
|
|
279
|
+
get(id:ODValidId): ODState<any,boolean,boolean>|null
|
|
280
280
|
|
|
281
|
-
get(id:ODValidId): ODState<any>|null {
|
|
281
|
+
get(id:ODValidId): ODState<any,boolean,boolean>|null {
|
|
282
282
|
return super.get(id)
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
remove<StateId extends keyof ODNoGeneric<IdList>>(id:StateId): IdList[StateId]
|
|
286
|
-
remove(id:ODValidId): ODState<any>|null
|
|
286
|
+
remove(id:ODValidId): ODState<any,boolean,boolean>|null
|
|
287
287
|
|
|
288
|
-
remove(id:ODValidId): ODState<any>|null {
|
|
288
|
+
remove(id:ODValidId): ODState<any,boolean,boolean>|null {
|
|
289
289
|
return super.remove(id)
|
|
290
290
|
}
|
|
291
291
|
|
|
@@ -9,6 +9,7 @@ import * as discord from "discord.js"
|
|
|
9
9
|
import { ODWorkerManager } from "./worker.js"
|
|
10
10
|
|
|
11
11
|
/**## ODVerifyBar `class`
|
|
12
|
+
* @deprecated Use `ODMessageComponentModifier`'s instead.
|
|
12
13
|
* This is an Open Discord verifybar.
|
|
13
14
|
*
|
|
14
15
|
* It is contains 2 sets of workers and a lot of utilities for the (✅ ❌) verifybars in the bot.
|
|
@@ -47,14 +48,15 @@ export class ODVerifyBar<SuccessWorkerIds extends string = string,FailureWorkerI
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
/**## ODVerifyBarManagerIdConstraint `type`
|
|
51
|
+
* @deprecated Use `ODMessageComponentModifier`'s instead.
|
|
50
52
|
* The constraint/layout for id mappings/interfaces of the `ODVerifyBarManager` class.
|
|
51
53
|
*/
|
|
52
54
|
export type ODVerifyBarManagerIdConstraint = Record<string,{successWorkerIds:string,failureWorkerIds:string}>
|
|
53
55
|
|
|
54
56
|
/**## ODVerifyBarManager `class`
|
|
55
|
-
*
|
|
57
|
+
* @deprecated Use `ODMessageComponentModifier`'s instead.
|
|
56
58
|
*
|
|
57
|
-
*
|
|
59
|
+
* The Open Discord verifybar manager manages all (✅ ❌) verifybars in the bot.
|
|
58
60
|
* The `ODVerifyBar` classes contain `ODWorkerManager`'s that will be fired when the continue/stop buttons are pressed.
|
|
59
61
|
*
|
|
60
62
|
* It doesn't contain the code which activates the verifybars! This should be implemented by your own.
|
|
@@ -29,6 +29,11 @@ export class ODWorker<Instance, Origin extends string, Params> extends ODManager
|
|
|
29
29
|
this.priority = priority
|
|
30
30
|
this.callback = callback
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
/**Duplicate this worker. Warning: If the callback accesses external variables (outside parameters), the clone will still use those variables. This might result in unexpected behaviour! */
|
|
34
|
+
duplicate(newId?:ODValidId): ODWorker<Instance,Origin,Params> {
|
|
35
|
+
return new ODWorker<Instance,Origin,Params>(newId ?? this.id.value,this.priority,this.callback)
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
/**## ODWorker `class`
|