@open-discord-bots/framework 0.2.0 → 0.2.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/README.md +21 -19
- package/dist/api/modules/event.d.ts +10 -6
- package/package.json +3 -3
- package/src/api/modules/event.ts +11 -6
- package/src/api/modules/helpmenu.ts +1 -1
- package/src/api/modules/post.ts +1 -1
package/README.md
CHANGED
|
@@ -54,25 +54,6 @@ We do currently <b>NOT</b> provide support for <b>3rd party implementations</b>
|
|
|
54
54
|
- **Large Ecosystem** - The same plugin is able to work in all projects using Open discord (e.g. Open Ticket / Moderation)
|
|
55
55
|
|
|
56
56
|
## 🛠️ Contributors
|
|
57
|
-
### 🖥️ Team & Contributors
|
|
58
|
-
A list of people that contributed or provided support for Open Ticket, Open Moderation & Open Discord.
|
|
59
|
-
<table>
|
|
60
|
-
<tr>
|
|
61
|
-
<td align="center"><img src="https://github.com/DJj123dj.png" alt="Profile Picture" width="80px"></td>
|
|
62
|
-
<td align="center"><img src="https://github.com/guillee3.png" alt="Profile Picture" width="80px"></td>
|
|
63
|
-
<td align="center"><img src="https://github.com/smetsliam.png" alt="Profile Picture" width="80px"></td>
|
|
64
|
-
<td align="center"><img src="https://github.com/FrankVissers.png" alt="Profile Picture" width="80px"></td>
|
|
65
|
-
<td align="center"><img src="https://github.com/Sank34.png" alt="Profile Picture" width="80px"></td>
|
|
66
|
-
</tr>
|
|
67
|
-
<tr>
|
|
68
|
-
<th><a href="https://github.com/DJj123dj">💻🧩💬 DJj123dj</a></th>
|
|
69
|
-
<th><a href="https://github.com/guillee3">🧩💬 Guillee3</a></th>
|
|
70
|
-
<th><a href="https://github.com/smetsliam">💬 smetsliam</a></th>
|
|
71
|
-
<th><a href="https://github.com/FrankVissers">💬 Frank Vissers</a></th>
|
|
72
|
-
<th><a href="https://github.com/Sank34">💬 Sanke</a></th>
|
|
73
|
-
</tr>
|
|
74
|
-
</table>
|
|
75
|
-
|
|
76
57
|
### ❤️ Sponsors
|
|
77
58
|
A big thanks to all our sponsors! Without them, it wouldn't be possible to create this project!
|
|
78
59
|
|
|
@@ -80,10 +61,12 @@ A big thanks to all our sponsors! Without them, it wouldn't be possible to creat
|
|
|
80
61
|
<tr>
|
|
81
62
|
<td><img src="https://github.com/guillee3.png" alt="Profile Picture" width="100px"></td>
|
|
82
63
|
<td><img src="https://github.com/yeeetSK.png" alt="Profile Picture" width="100px"></td>
|
|
64
|
+
<td><img src="https://github.com/jacobhumston.png" alt="Profile Picture" width="100px"></td>
|
|
83
65
|
</tr>
|
|
84
66
|
<tr>
|
|
85
67
|
<td align="center"><a href="https://github.com/guillee3"><b>guillee3</b></a></td>
|
|
86
68
|
<td align="center"><a href="https://github.com/yeeetSK"><b>yeeetSK</b></a></td>
|
|
69
|
+
<td align="center"><a href="https://github.com/jacobhumston"><b>jacobhumston</b></a></td>
|
|
87
70
|
</tr>
|
|
88
71
|
</table>
|
|
89
72
|
|
|
@@ -95,6 +78,25 @@ A big thanks to all our sponsors! Without them, it wouldn't be possible to creat
|
|
|
95
78
|
<img src="https://github.com/BENZORICH.png" alt="BENZORICH" width="40px">
|
|
96
79
|
</a>
|
|
97
80
|
|
|
81
|
+
### 🖥️ Team & Contributors
|
|
82
|
+
A list of people that contributed or provided support for Open Ticket, Open Moderation & Open Discord.
|
|
83
|
+
<table>
|
|
84
|
+
<tr>
|
|
85
|
+
<td align="center"><img src="https://github.com/DJj123dj.png" alt="Profile Picture" width="80px"></td>
|
|
86
|
+
<td align="center"><img src="https://github.com/guillee3.png" alt="Profile Picture" width="80px"></td>
|
|
87
|
+
<td align="center"><img src="https://github.com/smetsliam.png" alt="Profile Picture" width="80px"></td>
|
|
88
|
+
<td align="center"><img src="https://github.com/FrankVissers.png" alt="Profile Picture" width="80px"></td>
|
|
89
|
+
<td align="center"><img src="https://github.com/Sank34.png" alt="Profile Picture" width="80px"></td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<th><a href="https://github.com/DJj123dj">💻🧩💬 DJj123dj</a></th>
|
|
93
|
+
<th><a href="https://github.com/guillee3">🧩💬 Guillee3</a></th>
|
|
94
|
+
<th><a href="https://github.com/smetsliam">💬 smetsliam</a></th>
|
|
95
|
+
<th><a href="https://github.com/FrankVissers">💬 Frank Vissers</a></th>
|
|
96
|
+
<th><a href="https://github.com/Sank34">💬 Sanke</a></th>
|
|
97
|
+
</tr>
|
|
98
|
+
</table>
|
|
99
|
+
|
|
98
100
|
---
|
|
99
101
|
<img src="https://apis.dj-dj.be/cdn/opendiscord/logo.png" alt="Open Ticket Logo" width="170px">
|
|
100
102
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { ODManagerData, ODManager, ODValidId } from "./base";
|
|
1
|
+
import { ODManagerData, ODManager, ODValidId, ODPromiseVoid } from "./base";
|
|
2
2
|
import { ODDebugger } from "./console";
|
|
3
|
+
/**## ODEventCallback `type`
|
|
4
|
+
* The base callback function for events.
|
|
5
|
+
*/
|
|
6
|
+
export type ODEventCallback = (...args: any) => ODPromiseVoid;
|
|
3
7
|
/**## ODEvent `class`
|
|
4
8
|
* This is an Open Discord event.
|
|
5
9
|
*
|
|
6
10
|
* This class is made to work with the `ODEventManager` to handle events.
|
|
7
11
|
* The function of this specific class is to manage all listeners for a specifc event!
|
|
8
12
|
*/
|
|
9
|
-
export declare class ODEvent extends ODManagerData {
|
|
13
|
+
export declare class ODEvent<Callback extends ODEventCallback = ODEventCallback> extends ODManagerData {
|
|
10
14
|
#private;
|
|
11
15
|
/**The list of permanent listeners. */
|
|
12
16
|
listeners: Function[];
|
|
@@ -19,13 +23,13 @@ export declare class ODEvent extends ODManagerData {
|
|
|
19
23
|
/**Edit the listener limit */
|
|
20
24
|
setListenerLimit(limit: number): void;
|
|
21
25
|
/**Add a permanent callback to this event. This will stay as long as the bot is running! */
|
|
22
|
-
listen(callback:
|
|
26
|
+
listen(callback: Callback): void;
|
|
23
27
|
/**Add a one-time-only callback to this event. This will only trigger the callback once! */
|
|
24
|
-
listenOnce(callback:
|
|
28
|
+
listenOnce(callback: Callback): void;
|
|
25
29
|
/**Wait until this event is fired! Be carefull with it, because it could block the entire bot when wrongly used! */
|
|
26
|
-
wait(): Promise<
|
|
30
|
+
wait(): Promise<Parameters<Callback>>;
|
|
27
31
|
/**Emit this event to all listeners. You are required to provide all parameters of the event! */
|
|
28
|
-
emit(params:
|
|
32
|
+
emit(params: Parameters<Callback>): Promise<void>;
|
|
29
33
|
}
|
|
30
34
|
/**## ODEventManagerIdConstraint `type`
|
|
31
35
|
* The constraint/layout for id mappings/interfaces of the `ODEventManager` class.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
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",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"license": "GPL-3.0-only",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@discordjs/rest": "^2.6.
|
|
14
|
+
"@discordjs/rest": "^2.6.1",
|
|
15
15
|
"@types/terminal-kit": "^2.5.7",
|
|
16
16
|
"ansis": "^4.2.0",
|
|
17
|
-
"discord.js": "^14.
|
|
17
|
+
"discord.js": "^14.26.0",
|
|
18
18
|
"formatted-json-stringify": "^1.2.1",
|
|
19
19
|
"terminal-kit": "^3.1.2",
|
|
20
20
|
"typescript": "^5.9.3"
|
package/src/api/modules/event.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//EVENT MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODManagerData, ODManager, ODValidId } from "./base"
|
|
4
|
+
import { ODManagerData, ODManager, ODValidId, ODPromiseVoid } from "./base"
|
|
5
5
|
import { ODConsoleWarningMessage, ODDebugger } from "./console"
|
|
6
6
|
|
|
7
|
+
/**## ODEventCallback `type`
|
|
8
|
+
* The base callback function for events.
|
|
9
|
+
*/
|
|
10
|
+
export type ODEventCallback = (...args:any) => ODPromiseVoid
|
|
11
|
+
|
|
7
12
|
/**## ODEvent `class`
|
|
8
13
|
* This is an Open Discord event.
|
|
9
14
|
*
|
|
10
15
|
* This class is made to work with the `ODEventManager` to handle events.
|
|
11
16
|
* The function of this specific class is to manage all listeners for a specifc event!
|
|
12
17
|
*/
|
|
13
|
-
export class ODEvent extends ODManagerData {
|
|
18
|
+
export class ODEvent<Callback extends ODEventCallback = ODEventCallback> extends ODManagerData {
|
|
14
19
|
/**Alias to Open Discord debugger. */
|
|
15
20
|
#debug?: ODDebugger
|
|
16
21
|
/**The list of permanent listeners. */
|
|
@@ -38,7 +43,7 @@ export class ODEvent extends ODManagerData {
|
|
|
38
43
|
this.listenerLimit = limit
|
|
39
44
|
}
|
|
40
45
|
/**Add a permanent callback to this event. This will stay as long as the bot is running! */
|
|
41
|
-
listen(callback:
|
|
46
|
+
listen(callback:Callback){
|
|
42
47
|
this.listeners.push(callback)
|
|
43
48
|
|
|
44
49
|
if (this.listeners.length > this.listenerLimit){
|
|
@@ -49,17 +54,17 @@ export class ODEvent extends ODManagerData {
|
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
/**Add a one-time-only callback to this event. This will only trigger the callback once! */
|
|
52
|
-
listenOnce(callback:
|
|
57
|
+
listenOnce(callback:Callback){
|
|
53
58
|
this.oncelisteners.push(callback)
|
|
54
59
|
}
|
|
55
60
|
/**Wait until this event is fired! Be carefull with it, because it could block the entire bot when wrongly used! */
|
|
56
|
-
async wait(): Promise<
|
|
61
|
+
async wait(): Promise<Parameters<Callback>> {
|
|
57
62
|
return new Promise((resolve,reject) => {
|
|
58
63
|
this.oncelisteners.push((...args:any) => {resolve(args)})
|
|
59
64
|
})
|
|
60
65
|
}
|
|
61
66
|
/**Emit this event to all listeners. You are required to provide all parameters of the event! */
|
|
62
|
-
async emit(params:
|
|
67
|
+
async emit(params:Parameters<Callback>): Promise<void> {
|
|
63
68
|
for (const listener of this.#getCurrentListeners()){
|
|
64
69
|
try{
|
|
65
70
|
await listener(...params)
|
|
@@ -95,7 +95,7 @@ export class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
|
|
|
95
95
|
/**## ODHelpMenuCategoryIdConstraint `type`
|
|
96
96
|
* The constraint/layout for id mappings/interfaces of the `ODHelpMenuCategory` class.
|
|
97
97
|
*/
|
|
98
|
-
export type ODHelpMenuCategoryIdConstraint = Record<string,ODHelpMenuComponent>
|
|
98
|
+
export type ODHelpMenuCategoryIdConstraint = Record<string,ODHelpMenuComponent|null>
|
|
99
99
|
|
|
100
100
|
/**## ODHelpMenuCategory `class`
|
|
101
101
|
* This is an Open Discord help menu category.
|
package/src/api/modules/post.ts
CHANGED
|
@@ -9,7 +9,7 @@ import * as discord from "discord.js"
|
|
|
9
9
|
/**## ODPostManagerIdConstraint `type`
|
|
10
10
|
* The constraint/layout for id mappings/interfaces of the `ODPostManager` class.
|
|
11
11
|
*/
|
|
12
|
-
export type ODPostManagerIdConstraint = Record<string,ODPost<discord.GuildBasedChannel
|
|
12
|
+
export type ODPostManagerIdConstraint = Record<string,ODPost<discord.GuildBasedChannel>|null>
|
|
13
13
|
|
|
14
14
|
/**## ODPostManager `class`
|
|
15
15
|
* This is an Open Discord post manager.
|