@open-discord-bots/framework 0.2.17 → 0.3.0
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/index.d.ts +16 -15
- package/dist/api/index.js +16 -15
- package/dist/api/main.d.ts +31 -23
- package/dist/api/main.js +3 -1
- package/dist/api/modules/action.d.ts +2 -2
- package/dist/api/modules/action.js +1 -5
- package/dist/api/modules/base.d.ts +2 -2
- package/dist/api/modules/builder.d.ts +2 -2
- package/dist/api/modules/builder.js +0 -4
- package/dist/api/modules/checker.d.ts +2 -2
- package/dist/api/modules/checker.js +2 -6
- package/dist/api/modules/component.d.ts +922 -0
- package/dist/api/modules/component.js +1344 -0
- package/dist/api/modules/config.d.ts +30 -1
- package/dist/api/modules/config.js +81 -0
- package/dist/api/modules/cooldown.d.ts +5 -5
- package/dist/api/modules/cooldown.js +1 -17
- package/dist/api/modules/database.d.ts +21 -13
- package/dist/api/modules/database.js +0 -23
- package/dist/api/modules/helpmenu.d.ts +9 -7
- package/dist/api/modules/helpmenu.js +22 -17
- package/dist/api/modules/language.d.ts +2 -2
- package/dist/api/modules/language.js +3 -7
- package/dist/api/modules/progressbar.d.ts +2 -1
- package/dist/api/modules/progressbar.js +1 -1
- package/dist/api/modules/responder.d.ts +2 -2
- package/dist/api/modules/responder.js +0 -4
- package/dist/api/modules/session.d.ts +1 -1
- package/dist/api/modules/session.js +1 -1
- package/dist/api/modules/startscreen.d.ts +2 -2
- package/dist/api/modules/startscreen.js +5 -3
- package/package.json +3 -2
- package/src/api/index.ts +16 -15
- package/src/api/main.ts +33 -24
- package/src/api/modules/action.ts +2 -4
- package/src/api/modules/base.ts +2 -2
- package/src/api/modules/builder.ts +2 -4
- package/src/api/modules/checker.ts +5 -6
- package/src/api/modules/component.ts +1822 -0
- package/src/api/modules/config.ts +78 -1
- package/src/api/modules/cooldown.ts +8 -13
- package/src/api/modules/database.ts +24 -32
- package/src/api/modules/helpmenu.ts +29 -22
- package/src/api/modules/language.ts +5 -7
- package/src/api/modules/progressbar.ts +2 -3
- package/src/api/modules/responder.ts +2 -4
- package/src/api/modules/session.ts +1 -1
- package/src/api/modules/startscreen.ts +6 -4
- package/src/api/modules/component.txt +0 -350
package/src/api/main.ts
CHANGED
|
@@ -23,12 +23,13 @@ import { ODPostManager } from "./modules/post.js"
|
|
|
23
23
|
import { ODClientManager } from "./modules/client.js"
|
|
24
24
|
import { ODSharedFuseManager } from "./modules/fuse.js"
|
|
25
25
|
import { ODStartScreenManager } from "./modules/startscreen.js"
|
|
26
|
+
import { ODComponentManager } from "./modules/component.js"
|
|
26
27
|
|
|
27
28
|
/**## ODMainManagers `interface`
|
|
28
29
|
* The global properties for the main class of the bot.
|
|
29
30
|
*/
|
|
30
31
|
export interface ODMainManagers {
|
|
31
|
-
/**
|
|
32
|
+
/**A collection of versions of the bot, systems, frameworks & services. */
|
|
32
33
|
versions: ODVersionManager
|
|
33
34
|
|
|
34
35
|
/**The timestamp that the (node.js) process of the bot started. */
|
|
@@ -49,49 +50,55 @@ export interface ODMainManagers {
|
|
|
49
50
|
plugins: ODPluginManager
|
|
50
51
|
/**The manager that manages & checks all the console flags of the bot. (like `--debug`) */
|
|
51
52
|
flags: ODFlagManager
|
|
52
|
-
/**The manager responsible for progress bars in the console. */
|
|
53
|
+
/**The manager responsible for displaying progress bars in the console. */
|
|
53
54
|
progressbars: ODProgressBarManager
|
|
54
|
-
/**
|
|
55
|
+
/**A collection of all the config files of the bot and plugins. (like `config/general.json`) */
|
|
55
56
|
configs: ODConfigManager
|
|
56
|
-
/**
|
|
57
|
+
/**A collection of all the databases of the bot and plugins. (like `database/global.json`) */
|
|
57
58
|
databases: ODDatabaseManager
|
|
58
|
-
/**
|
|
59
|
+
/**A collection of all the sessions of the bot. (Sessions are temporary objects stored in memory) */
|
|
59
60
|
sessions: ODSessionManager
|
|
60
|
-
/**The manager
|
|
61
|
+
/**The global translation manager which manges all language files, translations & switches between them. (Does not manage translations for plugins) */
|
|
61
62
|
languages: ODLanguageManager
|
|
62
63
|
|
|
63
|
-
/**The manager
|
|
64
|
+
/**The manager responsible for checking the bot & plugin configs. (it checks for mistakes in your config) */
|
|
64
65
|
checkers: ODCheckerManager
|
|
65
|
-
/**
|
|
66
|
+
/**A collection of button, dropdown, embed, ... templates which can be used to construct messages and modals.
|
|
67
|
+
* ### (🚨 Better alternative: `opendiscord.components (ODComponentManager)`)
|
|
68
|
+
*/
|
|
66
69
|
builders: ODBuilderManager
|
|
67
|
-
/**
|
|
70
|
+
/**A collection of building blocks and templates for messages & modals with native support for Discord Components v2. (e.g. buttons, dropdowns, checkboxes, radio groups, file uploads, ...)
|
|
71
|
+
* ### (✅ New replacement for: `opendiscord.builders (ODBuilderManager)`)
|
|
72
|
+
*/
|
|
73
|
+
components: ODComponentManager
|
|
74
|
+
/**The manager that handles responses to all interactions of the bot. (e.g. slash/text commands, buttons, dropdowns, modals) */
|
|
68
75
|
responders: ODResponderManager
|
|
69
|
-
/**
|
|
76
|
+
/**A collection of procedures. A procedure is a complex task which can be executed from multiple responders or events. (e.g. ticket-creation, ticket-deletion, ticket-claiming, ...) */
|
|
70
77
|
actions: ODActionManager
|
|
71
|
-
/**
|
|
78
|
+
/**A collection of verify bars from the bot. (the ✅ ❌ buttons in messages) */
|
|
72
79
|
verifybars: ODVerifyBarManager
|
|
73
|
-
/**
|
|
80
|
+
/**A manager which will help with calculating permissions for commands & actions. */
|
|
74
81
|
permissions: ODPermissionManager
|
|
75
|
-
/**The manager
|
|
82
|
+
/**The manager which will manage cooldowns in the bot. (e.g. ticket-create cooldowns) */
|
|
76
83
|
cooldowns: ODCooldownManager
|
|
77
|
-
/**The manager that
|
|
84
|
+
/**The manager that collects & renders the Open Discord help menu contents. (not the final embed) */
|
|
78
85
|
helpmenu: ODHelpMenuManager
|
|
79
|
-
/**The manager that
|
|
86
|
+
/**The manager that registers, saves & updates statistics in the database. */
|
|
80
87
|
statistics: ODStatisticManager
|
|
81
|
-
/**
|
|
88
|
+
/**A place where you can put general-purpose code which will start on startup of the bot. (Perfect for background tasks) */
|
|
82
89
|
code: ODCodeManager
|
|
83
|
-
/**
|
|
90
|
+
/**A collection of static Discord post channels. It allows the bot to find back log, transcript or configured channels based on a linked ID. */
|
|
84
91
|
posts: ODPostManager
|
|
85
92
|
|
|
86
|
-
/**
|
|
93
|
+
/**A wrapper around the `discord.Client` class. It handles client login, activity and registering text/slash commands. */
|
|
87
94
|
client: ODClientManager
|
|
88
|
-
/**Shared fuses between Open Discord bots.
|
|
95
|
+
/**Shared fuses between Open Discord bots. Turn off "default behaviours" from the bot which is useful for replacing default behaviour with a custom implementation. */
|
|
89
96
|
sharedFuses: ODSharedFuseManager
|
|
90
|
-
/**
|
|
97
|
+
/**A manager which collects variables from the Process ENV and `.env` file. */
|
|
91
98
|
env: ODEnvHelper
|
|
92
|
-
/**
|
|
99
|
+
/**LiveStatus is a protocol which displays live updates from DJdj Development in the startscreen of the bot. (e.g. new version available) */
|
|
93
100
|
livestatus: ODLiveStatusManager
|
|
94
|
-
/**The manager responsible for the
|
|
101
|
+
/**The manager responsible for rendering the startscreen of the bot. */
|
|
95
102
|
startscreen: ODStartScreenManager
|
|
96
103
|
}
|
|
97
104
|
|
|
@@ -101,7 +108,7 @@ export interface ODMainManagers {
|
|
|
101
108
|
*
|
|
102
109
|
* This class can't be overwritten or extended & is available as the global variable `opendiscord`!
|
|
103
110
|
*/
|
|
104
|
-
export class ODMain implements ODMainManagers {
|
|
111
|
+
export abstract class ODMain implements ODMainManagers {
|
|
105
112
|
readonly project: ODProjectType
|
|
106
113
|
|
|
107
114
|
readonly versions: ODVersionManager
|
|
@@ -123,6 +130,7 @@ export class ODMain implements ODMainManagers {
|
|
|
123
130
|
|
|
124
131
|
readonly checkers: ODCheckerManager
|
|
125
132
|
readonly builders: ODBuilderManager
|
|
133
|
+
readonly components: ODComponentManager
|
|
126
134
|
readonly responders: ODResponderManager
|
|
127
135
|
readonly actions: ODActionManager
|
|
128
136
|
readonly verifybars: ODVerifyBarManager
|
|
@@ -142,7 +150,7 @@ export class ODMain implements ODMainManagers {
|
|
|
142
150
|
constructor(managers:ODMainManagers,project:ODProjectType){
|
|
143
151
|
this.project = project
|
|
144
152
|
this.versions = managers.versions
|
|
145
|
-
this.versions.add(ODVersion.fromString("opendiscord:api","v0.
|
|
153
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v0.3.0"))
|
|
146
154
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
147
155
|
|
|
148
156
|
this.debugfile = managers.debugfile
|
|
@@ -160,6 +168,7 @@ export class ODMain implements ODMainManagers {
|
|
|
160
168
|
|
|
161
169
|
this.checkers = managers.checkers
|
|
162
170
|
this.builders = managers.builders
|
|
171
|
+
this.components = managers.components
|
|
163
172
|
this.client = managers.client
|
|
164
173
|
this.responders = managers.responders
|
|
165
174
|
this.actions = managers.actions
|
|
@@ -12,7 +12,7 @@ import { ODDebugger } from "./console.js"
|
|
|
12
12
|
*
|
|
13
13
|
* This class can't be used stand-alone & needs to be extended from!
|
|
14
14
|
*/
|
|
15
|
-
export class ODActionImplementation<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
|
|
15
|
+
export abstract class ODActionImplementation<Origin extends string,Params extends object,Result extends object,WorkerIds extends string = string> extends ODManagerData {
|
|
16
16
|
/**The manager that has all workers of this implementation */
|
|
17
17
|
workers: ODWorkerManager<Partial<Result>,Origin,Params,WorkerIds>
|
|
18
18
|
|
|
@@ -22,9 +22,7 @@ export class ODActionImplementation<Origin extends string,Params extends object,
|
|
|
22
22
|
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
23
23
|
}
|
|
24
24
|
/**Execute all workers & return the result. */
|
|
25
|
-
|
|
26
|
-
throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation")
|
|
27
|
-
}
|
|
25
|
+
abstract run(origin:Origin, params:Params): Promise<Partial<Result>>
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
/**## ODActionManagerIdConstraint `type`
|
package/src/api/modules/base.ts
CHANGED
|
@@ -140,7 +140,7 @@ export class ODId {
|
|
|
140
140
|
* It is used to let the "onChange" event in the `ODManager` class work.
|
|
141
141
|
* You can use this class when extending your own `ODManager`
|
|
142
142
|
*/
|
|
143
|
-
export class ODManagerChangeHelper {
|
|
143
|
+
export abstract class ODManagerChangeHelper {
|
|
144
144
|
#change: (() => void)|null = null
|
|
145
145
|
|
|
146
146
|
/**Trigger an `onChange()` event in the parent `ODManager` of this class. */
|
|
@@ -167,7 +167,7 @@ export class ODManagerChangeHelper {
|
|
|
167
167
|
*
|
|
168
168
|
* There is an `id:ODId` property & also some events used in the manager.
|
|
169
169
|
*/
|
|
170
|
-
export class ODManagerData extends ODManagerChangeHelper {
|
|
170
|
+
export abstract class ODManagerData extends ODManagerChangeHelper {
|
|
171
171
|
/**The id of this data. */
|
|
172
172
|
id: ODId
|
|
173
173
|
|
|
@@ -13,7 +13,7 @@ import { ODDebugger } from "./console.js"
|
|
|
13
13
|
*
|
|
14
14
|
* This class can't be used stand-alone & needs to be extended from!
|
|
15
15
|
*/
|
|
16
|
-
export class ODBuilderImplementation<Instance,Origin extends string,Params,BuildType extends {id:ODId},WorkerIds extends string = string> extends ODManagerData {
|
|
16
|
+
export abstract class ODBuilderImplementation<Instance,Origin extends string,Params,BuildType extends {id:ODId},WorkerIds extends string = string> extends ODManagerData {
|
|
17
17
|
/**The manager that has all workers of this implementation */
|
|
18
18
|
workers: ODWorkerManager<Instance,Origin,Params,WorkerIds>
|
|
19
19
|
/**Cache a build or create it every time from scratch when this.build() gets executed. */
|
|
@@ -42,9 +42,7 @@ export class ODBuilderImplementation<Instance,Origin extends string,Params,Build
|
|
|
42
42
|
return this
|
|
43
43
|
}
|
|
44
44
|
/**Execute all workers & return the result. */
|
|
45
|
-
|
|
46
|
-
throw new ODSystemError("Tried to build an unimplemented ODBuilderImplementation")
|
|
47
|
-
}
|
|
45
|
+
abstract build(origin:Origin, params:Params): Promise<BuildType>
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
/**## ODBuilderManager `class`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//CONFIG CHECKER MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
4
|
import { ODDiscordIdType, ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId, ODValidJsonType } from "./base.js"
|
|
5
|
-
import { ODConfig } from "./config.js"
|
|
5
|
+
import { ODConfig, ODMemoryConfig } from "./config.js"
|
|
6
6
|
import { ODLanguageManager } from "./language.js"
|
|
7
7
|
import { ODDebugger } from "./console.js"
|
|
8
8
|
import ansis from "ansis"
|
|
@@ -96,7 +96,7 @@ export class ODCheckerManager<
|
|
|
96
96
|
}
|
|
97
97
|
/**Create temporary and unlisted `ODConfig`, `ODChecker` & `ODCheckerStorage` classes. This will help you use a `ODCheckerStructure` validator without officially registering it in `opendiscord.checkers`. */
|
|
98
98
|
createTemporaryCheckerEnvironment(){
|
|
99
|
-
return new ODChecker("opendiscord:temporary-environment",new ODCheckerStorage(),0,new
|
|
99
|
+
return new ODChecker("opendiscord:temporary-environment",new ODCheckerStorage(),0,new ODMemoryConfig("opendiscord:temporary-environment",{}),new ODCheckerStructure("opendiscord:temporary-environment",{}))
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
get<CheckerId extends keyof ODNoGeneric<IdList>>(id:CheckerId): IdList[CheckerId]
|
|
@@ -181,11 +181,10 @@ export class ODCheckerStorage {
|
|
|
181
181
|
*
|
|
182
182
|
* Use this class to change the config checker looks!
|
|
183
183
|
*/
|
|
184
|
-
export class ODCheckerRenderer {
|
|
184
|
+
export abstract class ODCheckerRenderer {
|
|
185
185
|
/**Get all config checker render components. These can be combined and rendered to the console. */
|
|
186
|
-
getComponents(compact:boolean, renderEmpty:boolean, translation:ODCheckerTranslationRegister<string,string>, data:ODCheckerResult): string[]
|
|
187
|
-
|
|
188
|
-
}
|
|
186
|
+
abstract getComponents(compact:boolean, renderEmpty:boolean, translation:ODCheckerTranslationRegister<string,string>, data:ODCheckerResult): string[]
|
|
187
|
+
|
|
189
188
|
/**Render all config checker render components to the console. */
|
|
190
189
|
render(components:string[]){
|
|
191
190
|
if (components.length < 1) return
|