@open-discord-bots/framework 0.0.1 → 0.0.2
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/LICENSE.md +713 -0
- package/README.md +104 -0
- package/dist/api/api.d.ts +26 -0
- package/dist/api/api.js +44 -0
- package/dist/api/main.d.ts +133 -0
- package/dist/api/main.js +87 -0
- package/dist/api/modules/action.d.ts +34 -0
- package/dist/api/modules/action.js +58 -0
- package/dist/api/modules/base.d.ts +329 -0
- package/dist/api/modules/base.js +804 -0
- package/dist/api/modules/builder.d.ts +647 -0
- package/dist/api/modules/builder.js +1441 -0
- package/dist/api/modules/checker.d.ts +648 -0
- package/dist/api/modules/checker.js +1324 -0
- package/dist/api/modules/client.d.ts +768 -0
- package/dist/api/modules/client.js +1859 -0
- package/dist/api/modules/code.d.ts +33 -0
- package/dist/api/modules/code.js +57 -0
- package/dist/api/modules/config.d.ts +70 -0
- package/dist/api/modules/config.js +206 -0
- package/dist/api/modules/console.d.ts +305 -0
- package/dist/api/modules/console.js +598 -0
- package/dist/api/modules/cooldown.d.ts +138 -0
- package/dist/api/modules/cooldown.js +359 -0
- package/dist/api/modules/database.d.ts +135 -0
- package/dist/api/modules/database.js +271 -0
- package/dist/api/modules/event.d.ts +43 -0
- package/dist/api/modules/event.js +100 -0
- package/dist/api/modules/flag.d.ts +40 -0
- package/dist/api/modules/flag.js +72 -0
- package/dist/api/modules/fuse.d.ts +218 -0
- package/dist/api/modules/fuse.js +123 -0
- package/dist/api/modules/helpmenu.d.ts +106 -0
- package/dist/api/modules/helpmenu.js +167 -0
- package/dist/api/modules/language.d.ts +85 -0
- package/dist/api/modules/language.js +195 -0
- package/dist/api/modules/permission.d.ts +121 -0
- package/dist/api/modules/permission.js +314 -0
- package/dist/api/modules/plugin.d.ts +128 -0
- package/dist/api/modules/plugin.js +168 -0
- package/dist/api/modules/post.d.ts +44 -0
- package/dist/api/modules/post.js +92 -0
- package/dist/api/modules/progressbar.d.ts +108 -0
- package/dist/api/modules/progressbar.js +233 -0
- package/dist/api/modules/responder.d.ts +506 -0
- package/dist/api/modules/responder.js +1468 -0
- package/dist/api/modules/session.d.ts +58 -0
- package/dist/api/modules/session.js +171 -0
- package/dist/api/modules/startscreen.d.ts +165 -0
- package/dist/api/modules/startscreen.js +293 -0
- package/dist/api/modules/stat.d.ts +142 -0
- package/dist/api/modules/stat.js +293 -0
- package/dist/api/modules/verifybar.d.ts +54 -0
- package/dist/api/modules/verifybar.js +60 -0
- package/dist/api/modules/worker.d.ts +41 -0
- package/dist/api/modules/worker.js +93 -0
- package/dist/api/utils.d.ts +61 -0
- package/dist/api/utils.js +254 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +40 -0
- package/dist/startup/dump.d.ts +14 -0
- package/dist/startup/dump.js +79 -0
- package/dist/startup/errorHandling.d.ts +2 -0
- package/dist/startup/errorHandling.js +43 -0
- package/dist/startup/pluginLauncher.d.ts +2 -0
- package/dist/startup/pluginLauncher.js +202 -0
- package/package.json +9 -3
- package/src/api/api.ts +29 -0
- package/src/api/main.ts +189 -0
- package/src/api/modules/action.ts +58 -0
- package/src/api/modules/base.ts +811 -0
- package/src/api/modules/builder.ts +1554 -0
- package/src/api/modules/checker.ts +1549 -0
- package/src/api/modules/client.ts +2247 -0
- package/src/api/modules/code.ts +58 -0
- package/src/api/modules/config.ts +159 -0
- package/src/api/modules/console.ts +665 -0
- package/src/api/modules/cooldown.ts +348 -0
- package/src/api/modules/database.ts +278 -0
- package/src/api/modules/event.ts +99 -0
- package/src/api/modules/flag.ts +73 -0
- package/src/api/modules/fuse.ts +348 -0
- package/src/api/modules/helpmenu.ts +216 -0
- package/src/api/modules/language.ts +201 -0
- package/src/api/modules/permission.ts +340 -0
- package/src/api/modules/plugin.ts +242 -0
- package/src/api/modules/post.ts +90 -0
- package/src/api/modules/progressbar.ts +232 -0
- package/src/api/modules/responder.ts +1420 -0
- package/src/api/modules/session.ts +155 -0
- package/src/api/modules/startscreen.ts +320 -0
- package/src/api/modules/stat.ts +313 -0
- package/src/api/modules/verifybar.ts +61 -0
- package/src/api/modules/worker.ts +93 -0
- package/src/api/utils.ts +206 -0
- package/src/cli/cli.ts +151 -0
- package/src/cli/editConfig.ts +943 -0
- package/src/index.ts +6 -1
- package/src/startup/compilation.ts +186 -0
- package/src/startup/dump.ts +45 -0
- package/src/startup/errorHandling.ts +38 -0
- package/src/startup/pluginLauncher.ts +261 -0
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "The core framework of Open Ticket & Open Moderation.",
|
|
4
|
+
"version": "0.0.2",
|
|
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",
|
|
8
8
|
"scripts": {
|
|
@@ -11,7 +11,13 @@
|
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"
|
|
14
|
+
"@discordjs/rest": "^2.6.0",
|
|
15
|
+
"@types/terminal-kit": "^2.5.7",
|
|
16
|
+
"ansis": "^4.2.0",
|
|
17
|
+
"discord.js": "^14.25.1",
|
|
18
|
+
"formatted-json-stringify": "^1.2.1",
|
|
19
|
+
"terminal-kit": "^3.1.2",
|
|
20
|
+
"typescript": "^5.9.3"
|
|
15
21
|
},
|
|
16
22
|
"repository": {
|
|
17
23
|
"type": "git",
|
package/src/api/api.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//MAIN MODULE
|
|
2
|
+
export * from "./main"
|
|
3
|
+
|
|
4
|
+
//BASE MODULES
|
|
5
|
+
export * from "./modules/base"
|
|
6
|
+
export * from "./modules/event"
|
|
7
|
+
export * from "./modules/config"
|
|
8
|
+
export * from "./modules/database"
|
|
9
|
+
export * from "./modules/language"
|
|
10
|
+
export * from "./modules/flag"
|
|
11
|
+
export * from "./modules/console"
|
|
12
|
+
export * from "./modules/fuse"
|
|
13
|
+
export * from "./modules/plugin"
|
|
14
|
+
export * from "./modules/checker"
|
|
15
|
+
export * from "./modules/client"
|
|
16
|
+
export * from "./modules/worker"
|
|
17
|
+
export * from "./modules/builder"
|
|
18
|
+
export * from "./modules/responder"
|
|
19
|
+
export * from "./modules/action"
|
|
20
|
+
export * from "./modules/permission"
|
|
21
|
+
export * from "./modules/helpmenu"
|
|
22
|
+
export * from "./modules/session"
|
|
23
|
+
export * from "./modules/stat"
|
|
24
|
+
export * from "./modules/code"
|
|
25
|
+
export * from "./modules/cooldown"
|
|
26
|
+
export * from "./modules/post"
|
|
27
|
+
export * from "./modules/verifybar"
|
|
28
|
+
export * from "./modules/progressbar"
|
|
29
|
+
export * from "./modules/startscreen"
|
package/src/api/main.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
//BASE MODULES
|
|
2
|
+
import { ODEnvHelper, ODProjectType, ODVersion, ODVersionManager } from "./modules/base"
|
|
3
|
+
import { ODConsoleManager, ODConsoleMessage, ODConsoleMessageParam, ODConsoleMessageTypes, ODDebugFileManager, ODDebugger, ODError, ODLiveStatusManager } from "./modules/console"
|
|
4
|
+
import { ODCheckerManager } from "./modules/checker"
|
|
5
|
+
import { ODEventManager } from "./modules/event"
|
|
6
|
+
import { ODPluginManager } from "./modules/plugin"
|
|
7
|
+
import { ODFlagManager } from "./modules/flag"
|
|
8
|
+
import { ODProgressBarManager } from "./modules/progressbar"
|
|
9
|
+
import { ODConfigManager } from "./modules/config"
|
|
10
|
+
import { ODDatabaseManager } from "./modules/database"
|
|
11
|
+
import { ODSessionManager } from "./modules/session"
|
|
12
|
+
import { ODLanguageManager } from "./modules/language"
|
|
13
|
+
import { ODBuilderManager } from "./modules/builder"
|
|
14
|
+
import { ODResponderManager } from "./modules/responder"
|
|
15
|
+
import { ODActionManager } from "./modules/action"
|
|
16
|
+
import { ODVerifyBarManager } from "./modules/verifybar"
|
|
17
|
+
import { ODPermissionManager } from "./modules/permission"
|
|
18
|
+
import { ODCooldownManager } from "./modules/cooldown"
|
|
19
|
+
import { ODHelpMenuManager } from "./modules/helpmenu"
|
|
20
|
+
import { ODStatsManager } from "./modules/stat"
|
|
21
|
+
import { ODCodeManager } from "./modules/code"
|
|
22
|
+
import { ODPostManager } from "./modules/post"
|
|
23
|
+
import { ODClientManager } from "./modules/client"
|
|
24
|
+
import { ODSharedFuseManager } from "./modules/fuse"
|
|
25
|
+
import { ODStartScreenManager } from "./modules/startscreen"
|
|
26
|
+
|
|
27
|
+
/**## ODMainManagers `interface`
|
|
28
|
+
* The global properties for the main class of the bot.
|
|
29
|
+
*/
|
|
30
|
+
export interface ODMainManagers {
|
|
31
|
+
/**The manager that handles all versions in the bot. */
|
|
32
|
+
versions: ODVersionManager
|
|
33
|
+
|
|
34
|
+
/**The timestamp that the (node.js) process of the bot started. */
|
|
35
|
+
processStartupDate: Date
|
|
36
|
+
/**The timestamp that the bot finished loading and is ready for usage. */
|
|
37
|
+
readyStartupDate: Date|null
|
|
38
|
+
|
|
39
|
+
/**The manager responsible for the debug file. (`...debug.txt`) */
|
|
40
|
+
debugfile: ODDebugFileManager
|
|
41
|
+
/**The manager responsible for the console system. (logs, errors, etc) */
|
|
42
|
+
console: ODConsoleManager
|
|
43
|
+
/**The manager responsible for sending debug logs to the debug file. (`...debug.txt`) */
|
|
44
|
+
debug: ODDebugger
|
|
45
|
+
/**The manager containing all Open Discord events. */
|
|
46
|
+
events: ODEventManager
|
|
47
|
+
|
|
48
|
+
/**The manager that handles & executes all plugins in the bot. */
|
|
49
|
+
plugins: ODPluginManager
|
|
50
|
+
/**The manager that manages & checks all the console flags of the bot. (like `--debug`) */
|
|
51
|
+
flags: ODFlagManager
|
|
52
|
+
/**The manager responsible for progress bars in the console. */
|
|
53
|
+
progressbars: ODProgressBarManager
|
|
54
|
+
/**The manager that manages & contains all the config files of the bot. (like `config/general.json`) */
|
|
55
|
+
configs: ODConfigManager
|
|
56
|
+
/**The manager that manages & contains all the databases of the bot. (like `database/global.json`) */
|
|
57
|
+
databases: ODDatabaseManager
|
|
58
|
+
/**The manager that manages all the data sessions of the bot. (it's a temporary database) */
|
|
59
|
+
sessions: ODSessionManager
|
|
60
|
+
/**The manager that manages all languages & translations of the bot. (but not for plugins) */
|
|
61
|
+
languages: ODLanguageManager
|
|
62
|
+
|
|
63
|
+
/**The manager that handles & executes all config checkers in the bot. (the code that checks if you have something wrong in your config) */
|
|
64
|
+
checkers: ODCheckerManager
|
|
65
|
+
/**The manager that manages all builders in the bot. (e.g. buttons, dropdowns, messages, modals, etc) */
|
|
66
|
+
builders: ODBuilderManager
|
|
67
|
+
/**The manager that manages all responders in the bot. (e.g. commands, buttons, dropdowns, modals) */
|
|
68
|
+
responders: ODResponderManager
|
|
69
|
+
/**The manager that manages all actions or procedures in the bot. (e.g. ticket-creation, ticket-deletion, ticket-claiming, etc) */
|
|
70
|
+
actions: ODActionManager
|
|
71
|
+
/**The manager that manages all verify bars in the bot. (the ✅ ❌ buttons) */
|
|
72
|
+
verifybars: ODVerifyBarManager
|
|
73
|
+
/**The manager that contains all permissions for commands & actions in the bot. (use it to check if someone has admin perms or not) */
|
|
74
|
+
permissions: ODPermissionManager
|
|
75
|
+
/**The manager that contains all cooldowns of the bot. (e.g. ticket-cooldowns) */
|
|
76
|
+
cooldowns: ODCooldownManager
|
|
77
|
+
/**The manager that manages & renders the Open Discord help menu. (not the embed, but the text) */
|
|
78
|
+
helpmenu: ODHelpMenuManager
|
|
79
|
+
/**The manager that manages, saves & renders the Open Discord statistics. (not the embed, but the text & database) */
|
|
80
|
+
stats: ODStatsManager
|
|
81
|
+
/**This manager is a place where you can put code that executes when the bot almost finishes the setup. (can be used for less important stuff that doesn't require an exact time-order) */
|
|
82
|
+
code: ODCodeManager
|
|
83
|
+
/**The manager that manages all posts (static discord channels) in the bot. (e.g. transcripts, logs, etc) */
|
|
84
|
+
posts: ODPostManager
|
|
85
|
+
|
|
86
|
+
/**The manager responsible for everything related to the client. (e.g. status, login, slash & text commands, etc) */
|
|
87
|
+
client: ODClientManager
|
|
88
|
+
/**Shared fuses between Open Discord bots. With these fuses/switches, you can turn off "default behaviours" from the bot. Useful for replacing default behaviour with a custom implementation. */
|
|
89
|
+
sharedFuses: ODSharedFuseManager
|
|
90
|
+
/**This manager manages all the variables in the ENV. It reads from both the `.env` file & the `process.env`. (these 2 will be combined) */
|
|
91
|
+
env: ODEnvHelper
|
|
92
|
+
/**The manager responsible for the livestatus system. (remote console logs) */
|
|
93
|
+
livestatus: ODLiveStatusManager
|
|
94
|
+
/**The manager responsible for the livestatus system. (remote console logs) */
|
|
95
|
+
startscreen: ODStartScreenManager
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**## ODMain `class`
|
|
99
|
+
* This is the main Open Discord class.
|
|
100
|
+
* It contains all managers from the entire bot & has shortcuts to the event & logging system.
|
|
101
|
+
*
|
|
102
|
+
* This class can't be overwritten or extended & is available as the global variable `opendiscord`!
|
|
103
|
+
*/
|
|
104
|
+
export class ODMain implements ODMainManagers {
|
|
105
|
+
readonly project: ODProjectType
|
|
106
|
+
|
|
107
|
+
readonly versions: ODVersionManager
|
|
108
|
+
readonly processStartupDate: Date = new Date()
|
|
109
|
+
readyStartupDate: Date|null = null
|
|
110
|
+
|
|
111
|
+
readonly debugfile: ODDebugFileManager
|
|
112
|
+
readonly console: ODConsoleManager
|
|
113
|
+
readonly debug: ODDebugger
|
|
114
|
+
readonly events: ODEventManager
|
|
115
|
+
|
|
116
|
+
readonly plugins: ODPluginManager
|
|
117
|
+
readonly flags: ODFlagManager
|
|
118
|
+
readonly progressbars: ODProgressBarManager
|
|
119
|
+
readonly configs: ODConfigManager
|
|
120
|
+
readonly databases: ODDatabaseManager
|
|
121
|
+
readonly sessions: ODSessionManager
|
|
122
|
+
readonly languages: ODLanguageManager
|
|
123
|
+
|
|
124
|
+
readonly checkers: ODCheckerManager
|
|
125
|
+
readonly builders: ODBuilderManager
|
|
126
|
+
readonly responders: ODResponderManager
|
|
127
|
+
readonly actions: ODActionManager
|
|
128
|
+
readonly verifybars: ODVerifyBarManager
|
|
129
|
+
readonly permissions: ODPermissionManager
|
|
130
|
+
readonly cooldowns: ODCooldownManager
|
|
131
|
+
readonly helpmenu: ODHelpMenuManager
|
|
132
|
+
readonly stats: ODStatsManager
|
|
133
|
+
readonly code: ODCodeManager
|
|
134
|
+
readonly posts: ODPostManager
|
|
135
|
+
|
|
136
|
+
readonly client: ODClientManager
|
|
137
|
+
readonly sharedFuses: ODSharedFuseManager
|
|
138
|
+
readonly env: ODEnvHelper
|
|
139
|
+
readonly livestatus: ODLiveStatusManager
|
|
140
|
+
readonly startscreen: ODStartScreenManager
|
|
141
|
+
|
|
142
|
+
constructor(managers:ODMainManagers,project:ODProjectType){
|
|
143
|
+
this.project = project
|
|
144
|
+
this.versions = managers.versions
|
|
145
|
+
this.versions.add(ODVersion.fromString("opendiscord:api","v1.0.0"))
|
|
146
|
+
this.versions.add(ODVersion.fromString("opendiscord:livestatus","v2.0.0"))
|
|
147
|
+
|
|
148
|
+
this.debugfile = managers.debugfile
|
|
149
|
+
this.console = managers.console
|
|
150
|
+
this.debug = managers.debug
|
|
151
|
+
this.events = managers.events
|
|
152
|
+
|
|
153
|
+
this.plugins = managers.plugins
|
|
154
|
+
this.flags = managers.flags
|
|
155
|
+
this.progressbars = managers.progressbars
|
|
156
|
+
this.configs = managers.configs
|
|
157
|
+
this.databases = managers.databases
|
|
158
|
+
this.sessions = managers.sessions
|
|
159
|
+
this.languages = managers.languages
|
|
160
|
+
|
|
161
|
+
this.checkers = managers.checkers
|
|
162
|
+
this.builders = managers.builders
|
|
163
|
+
this.client = managers.client
|
|
164
|
+
this.responders = managers.responders
|
|
165
|
+
this.actions = managers.actions
|
|
166
|
+
this.verifybars = managers.verifybars
|
|
167
|
+
this.permissions = managers.permissions
|
|
168
|
+
this.cooldowns = managers.cooldowns
|
|
169
|
+
this.helpmenu = managers.helpmenu
|
|
170
|
+
this.stats = managers.stats
|
|
171
|
+
this.code = managers.code
|
|
172
|
+
this.posts = managers.posts
|
|
173
|
+
|
|
174
|
+
this.sharedFuses = managers.sharedFuses
|
|
175
|
+
this.env = managers.env
|
|
176
|
+
this.livestatus = managers.livestatus
|
|
177
|
+
this.startscreen = managers.startscreen
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**Log a message to the console. But in the Open Discord style :) */
|
|
181
|
+
log(message:ODConsoleMessage): void
|
|
182
|
+
log(message:ODError): void
|
|
183
|
+
log(message:string, type?:ODConsoleMessageTypes, params?:ODConsoleMessageParam[]): void
|
|
184
|
+
log(message:ODConsoleMessage|ODError|string, type?:ODConsoleMessageTypes, params?:ODConsoleMessageParam[]){
|
|
185
|
+
if (message instanceof ODConsoleMessage) this.console.log(message)
|
|
186
|
+
else if (message instanceof ODError) this.console.log(message)
|
|
187
|
+
else if (["string","number","boolean","object"].includes(typeof message)) this.console.log(message,type,params)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///////////////////////////////////////
|
|
2
|
+
//ACTION MODULE
|
|
3
|
+
///////////////////////////////////////
|
|
4
|
+
import { ODId, ODManager, ODValidId, ODSystemError, ODManagerData } from "./base"
|
|
5
|
+
import { ODWorkerManager, ODWorkerCallback, ODWorker } from "./worker"
|
|
6
|
+
import { ODDebugger } from "./console"
|
|
7
|
+
|
|
8
|
+
/**## ODActionImplementation `class`
|
|
9
|
+
* This is an Open Discord action implementation.
|
|
10
|
+
*
|
|
11
|
+
* It is a basic implementation of the `ODWorkerManager` used by all `ODAction` classes.
|
|
12
|
+
*
|
|
13
|
+
* This class can't be used stand-alone & needs to be extended from!
|
|
14
|
+
*/
|
|
15
|
+
export class ODActionImplementation<Source extends string,Params extends object,Result extends object> extends ODManagerData {
|
|
16
|
+
/**The manager that has all workers of this implementation */
|
|
17
|
+
workers: ODWorkerManager<object,Source,Params>
|
|
18
|
+
|
|
19
|
+
constructor(id:ODValidId, callback?:ODWorkerCallback<object,Source,Params>, priority?:number, callbackId?:ODValidId){
|
|
20
|
+
super(id)
|
|
21
|
+
this.workers = new ODWorkerManager("descending")
|
|
22
|
+
if (callback) this.workers.add(new ODWorker(callbackId ? callbackId : id,priority ?? 0,callback))
|
|
23
|
+
}
|
|
24
|
+
/**Execute all workers & return the result. */
|
|
25
|
+
async run(source:Source, params:Params): Promise<Partial<Result>> {
|
|
26
|
+
throw new ODSystemError("Tried to build an unimplemented ODResponderImplementation")
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**## ODActionManager `class`
|
|
31
|
+
* This is an Open Discord action manager.
|
|
32
|
+
*
|
|
33
|
+
* It contains all Open Discord actions. You can compare actions with some sort of "procedure".
|
|
34
|
+
* It's a complicated task that is divided into multiple functions.
|
|
35
|
+
*
|
|
36
|
+
* Some examples are `ticket-creation`, `ticket-closing`, `ticket-claiming`, ...
|
|
37
|
+
*
|
|
38
|
+
* It's recommended to use this system in combination with Open Discord responders!
|
|
39
|
+
*/
|
|
40
|
+
export class ODActionManager extends ODManager<ODAction<string,{},{}>> {
|
|
41
|
+
constructor(debug:ODDebugger){
|
|
42
|
+
super(debug,"action")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class ODAction<Source extends string,Params extends object,Result extends object> extends ODActionImplementation<Source,Params,Result> {
|
|
47
|
+
/**Run this action */
|
|
48
|
+
async run(source:Source, params:Params): Promise<Partial<Result>> {
|
|
49
|
+
//create instance
|
|
50
|
+
const instance = {}
|
|
51
|
+
|
|
52
|
+
//wait for workers to finish
|
|
53
|
+
await this.workers.executeWorkers(instance,source,params)
|
|
54
|
+
|
|
55
|
+
//return data generated by workers
|
|
56
|
+
return instance
|
|
57
|
+
}
|
|
58
|
+
}
|