@open-discord-bots/framework 1.0.0 → 2.0.1
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
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", "
|
|
47
|
+
this.versions.add(ODVersion.fromString("opendiscord:api", "v2.0.1"));
|
|
48
48
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
|
|
49
49
|
this.debugfile = managers.debugfile;
|
|
50
50
|
this.console = managers.console;
|
|
@@ -77,12 +77,27 @@ export declare class ODComponentModifierManager<IdList extends ODComponentModifi
|
|
|
77
77
|
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
78
78
|
exists(id: ODValidId): boolean;
|
|
79
79
|
}
|
|
80
|
+
/**## ODSharedComponentManagerIdConstraint `type`
|
|
81
|
+
* The constraint/layout for id mappings/interfaces of the `ODComponentManager` class.
|
|
82
|
+
*/
|
|
83
|
+
export type ODSharedComponentManagerIdConstraint = Record<string, {
|
|
84
|
+
component: ODComponent<object, any>;
|
|
85
|
+
origin: string;
|
|
86
|
+
params: object;
|
|
87
|
+
workers: string;
|
|
88
|
+
}>;
|
|
80
89
|
/**## ODSharedComponentManager `class
|
|
81
90
|
* A special class with types for shared message/modal `ODComponent`'s.
|
|
82
91
|
* Create button, dropdown or any other layout component template to use them in messages & modals.
|
|
83
92
|
*/
|
|
84
|
-
export declare class ODSharedComponentManager<IdList extends
|
|
93
|
+
export declare class ODSharedComponentManager<IdList extends ODSharedComponentManagerIdConstraint = ODSharedComponentManagerIdConstraint> extends ODBaseComponentManager<IdList, ODComponent<object, any>> {
|
|
85
94
|
constructor(debug: ODDebugger);
|
|
95
|
+
get<FactoryId extends keyof ODNoGeneric<IdList>>(id: FactoryId): ODComponentFactory<IdList[FactoryId]["component"], IdList[FactoryId]["origin"], IdList[FactoryId]["params"], IdList[FactoryId]["workers"]>;
|
|
96
|
+
get(id: ODValidId): ODComponentFactory<ODComponent<object, any>, string, {}, string> | null;
|
|
97
|
+
remove<FactoryId extends keyof ODNoGeneric<IdList>>(id: FactoryId): ODComponentFactory<IdList[FactoryId]["component"], IdList[FactoryId]["origin"], IdList[FactoryId]["params"], IdList[FactoryId]["workers"]>;
|
|
98
|
+
remove(id: ODValidId): ODComponentFactory<ODComponent<object, any>, string, {}, string> | null;
|
|
99
|
+
exists(id: keyof ODNoGeneric<IdList>): boolean;
|
|
100
|
+
exists(id: ODValidId): boolean;
|
|
86
101
|
}
|
|
87
102
|
/**## ODMessageComponentManager `class
|
|
88
103
|
* A special class with types for `ODMessageComponent`'s.
|
|
@@ -112,7 +127,7 @@ export declare class ODModalComponentManager<IdList extends ODComponentManagerId
|
|
|
112
127
|
* - Get to know the origin of the request (e.g. button, dropdown, modal, ...)
|
|
113
128
|
* - And so much more!
|
|
114
129
|
*/
|
|
115
|
-
export declare class ODComponentManager<SharedIdList extends
|
|
130
|
+
export declare class ODComponentManager<SharedIdList extends ODSharedComponentManagerIdConstraint = ODSharedComponentManagerIdConstraint, MessageIdList extends ODComponentManagerIdConstraint = ODComponentManagerIdConstraint, ModalIdList extends ODComponentManagerIdConstraint = ODComponentManagerIdConstraint, ModifierIdList extends ODComponentModifierManagerIdConstraint = ODComponentModifierManagerIdConstraint> {
|
|
116
131
|
/**The manager for all shared components. */
|
|
117
132
|
shared: ODSharedComponentManager<SharedIdList>;
|
|
118
133
|
/**The manager for all messages components. */
|
|
@@ -105,6 +105,15 @@ export class ODSharedComponentManager extends ODBaseComponentManager {
|
|
|
105
105
|
constructor(debug) {
|
|
106
106
|
super(debug, "shared component");
|
|
107
107
|
}
|
|
108
|
+
get(id) {
|
|
109
|
+
return super.get(id);
|
|
110
|
+
}
|
|
111
|
+
remove(id) {
|
|
112
|
+
return super.remove(id);
|
|
113
|
+
}
|
|
114
|
+
exists(id) {
|
|
115
|
+
return super.exists(id);
|
|
116
|
+
}
|
|
108
117
|
}
|
|
109
118
|
/**## ODMessageComponentManager `class
|
|
110
119
|
* A special class with types for `ODMessageComponent`'s.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
///////////////////////////////////////
|
|
2
2
|
//EVENT MODULE
|
|
3
3
|
///////////////////////////////////////
|
|
4
|
-
import { ODManagerData, ODManager
|
|
4
|
+
import { ODManagerData, ODManager } from "./base.js";
|
|
5
5
|
import { ODWarningConsoleMessage } from "./console.js";
|
|
6
6
|
/**## ODEvent `class`
|
|
7
7
|
* This is an Open Discord event.
|
|
@@ -62,7 +62,7 @@ export class ODEvent extends ODManagerData {
|
|
|
62
62
|
await listener(...params);
|
|
63
63
|
}
|
|
64
64
|
catch (err) {
|
|
65
|
-
process.emit("uncaughtException",
|
|
65
|
+
process.emit("uncaughtException", err);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -89,7 +89,8 @@ export class ODPlugin extends ODManagerData {
|
|
|
89
89
|
try {
|
|
90
90
|
//import relative plugin directory path (works on windows & unix based systems)
|
|
91
91
|
const pluginPath = nodepath.join(process.cwd(), "./dist/plugins/", this.getStartFile()).replaceAll("\\", "/");
|
|
92
|
-
|
|
92
|
+
const finalPathForWindows = (process.platform == "win32") ? "file://" + pluginPath : pluginPath;
|
|
93
|
+
await import(finalPathForWindows);
|
|
93
94
|
debug.console.log("Plugin \"" + this.id.value + "\" loaded successfully!", "plugin");
|
|
94
95
|
this.executed = true;
|
|
95
96
|
return true;
|
|
@@ -1310,9 +1310,16 @@ export class ODModalResponderInstance extends ODBaseResponderInstance {
|
|
|
1310
1310
|
async reply(build) {
|
|
1311
1311
|
try {
|
|
1312
1312
|
const finalMessage = this.getMessageFromBuildResult(build, "interaction");
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1313
|
+
if (this.interaction.replied || this.interaction.deferred) {
|
|
1314
|
+
const sent = await this.interaction.editReply(finalMessage);
|
|
1315
|
+
this.ignoreResponderTimeout = true;
|
|
1316
|
+
return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
const sent = await this.interaction.reply(finalMessage);
|
|
1320
|
+
this.ignoreResponderTimeout = true;
|
|
1321
|
+
return { success: true, message: await sent.fetch(), ephemeral: build.ephemeral };
|
|
1322
|
+
}
|
|
1316
1323
|
}
|
|
1317
1324
|
catch (err) {
|
|
1318
1325
|
process.emit("uncaughtException", err);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
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",
|