@open-discord-bots/framework 0.0.7 → 0.1.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.
@@ -1,4 +1,4 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  import { Terminal } from "terminal-kit";
3
3
  import * as discord from "discord.js";
4
4
  export * from "./editConfig";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- export * as api from "./api/api";
2
- export * as utilities from "./api/utils";
3
- export * as cli from "./cli/cli";
4
1
  export { loadDumpCommand } from "./startup/dump";
5
2
  export { loadAllPlugins } from "./startup/pluginLauncher";
6
3
  export { frameworkStartup } from "./startup/compilation";
package/dist/index.js CHANGED
@@ -1,42 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.frameworkStartup = exports.loadAllPlugins = exports.loadDumpCommand = exports.cli = exports.utilities = exports.api = void 0;
37
- exports.api = __importStar(require("./api/api"));
38
- exports.utilities = __importStar(require("./api/utils"));
39
- exports.cli = __importStar(require("./cli/cli"));
3
+ exports.frameworkStartup = exports.loadAllPlugins = exports.loadDumpCommand = void 0;
40
4
  var dump_1 = require("./startup/dump");
41
5
  Object.defineProperty(exports, "loadDumpCommand", { enumerable: true, get: function () { return dump_1.loadDumpCommand; } });
42
6
  var pluginLauncher_1 = require("./startup/pluginLauncher");
@@ -1,3 +1,3 @@
1
- import type { ODProjectType } from "../api/api";
1
+ import type { ODProjectType } from "../api";
2
2
  export declare function checkFrameworkAllowed(project?: ODProjectType): void;
3
3
  export declare function frameworkStartup(startupFlags: string[], project: ODProjectType, startCallback: () => void): void;
@@ -1,4 +1,4 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  /** ### What is this?
3
3
  * This is the `!OPENTICKET:dump` command.
4
4
  * It's a utility command which can only be used by the creator of Open Discord/Ticket/Moderation or the owner of the bot.
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.loadDumpCommand = void 0;
37
- const index_1 = require("../index");
37
+ const api = __importStar(require("../api/index"));
38
38
  const discord = __importStar(require("discord.js"));
39
39
  const fs = __importStar(require("fs"));
40
40
  /** ### What is this?
@@ -52,7 +52,7 @@ const fs = __importStar(require("fs"));
52
52
  const loadDumpCommand = (opendiscord) => {
53
53
  if (!opendiscord.sharedFuses.getFuse("allowDumpCommand"))
54
54
  return;
55
- opendiscord.client.textCommands.add(new index_1.api.ODTextCommand("opendiscord:dump", {
55
+ opendiscord.client.textCommands.add(new api.ODTextCommand("opendiscord:dump", {
56
56
  allowBots: false,
57
57
  guildPermission: true,
58
58
  dmPermission: true,
@@ -1,2 +1,2 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  export declare function loadErrorHandling(opendiscord: api.ODMain, project: api.ODProjectType): void;
@@ -1,7 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.loadErrorHandling = loadErrorHandling;
4
- const index_1 = require("../index");
37
+ const api = __importStar(require("../api/index"));
5
38
  function loadErrorHandling(opendiscord, project) {
6
39
  process.on("uncaughtException", async (error, origin) => {
7
40
  try {
@@ -26,7 +59,7 @@ function loadErrorHandling(opendiscord, project) {
26
59
  }
27
60
  else {
28
61
  //unknown error
29
- const errmsg = new index_1.api.ODError(error, origin);
62
+ const errmsg = new api.ODError(error, origin);
30
63
  opendiscord.log(errmsg);
31
64
  if (opendiscord.sharedFuses.getFuse("crashOnError"))
32
65
  process.exit(1);
@@ -1,2 +1,2 @@
1
- import { api } from "../index";
1
+ import * as api from "../api/index";
2
2
  export declare const loadAllPlugins: (opendiscord: api.ODMain) => Promise<void>;
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  exports.loadAllPlugins = void 0;
7
- const index_1 = require("../index");
40
+ const api = __importStar(require("../api/index"));
8
41
  const fs_1 = __importDefault(require("fs"));
9
42
  const loadAllPlugins = async (opendiscord) => {
10
43
  //start launching plugins
@@ -36,64 +69,64 @@ const loadAllPlugins = async (opendiscord) => {
36
69
  try {
37
70
  const rawplugindata = JSON.parse(fs_1.default.readFileSync("./plugins/" + p + "/plugin.json").toString());
38
71
  if (typeof rawplugindata != "object")
39
- throw new index_1.api.ODPluginError("Failed to load plugin.json");
72
+ throw new api.ODPluginError("Failed to load plugin.json");
40
73
  if (typeof rawplugindata.id != "string")
41
- throw new index_1.api.ODPluginError("Failed to load plugin.json/id");
74
+ throw new api.ODPluginError("Failed to load plugin.json/id");
42
75
  if (typeof rawplugindata.name != "string")
43
- throw new index_1.api.ODPluginError("Failed to load plugin.json/name");
76
+ throw new api.ODPluginError("Failed to load plugin.json/name");
44
77
  if (typeof rawplugindata.version != "string")
45
- throw new index_1.api.ODPluginError("Failed to load plugin.json/version");
78
+ throw new api.ODPluginError("Failed to load plugin.json/version");
46
79
  if (typeof rawplugindata.startFile != "string")
47
- throw new index_1.api.ODPluginError("Failed to load plugin.json/startFile");
80
+ throw new api.ODPluginError("Failed to load plugin.json/startFile");
48
81
  //only check "supportedVersions" if it exists (should be array)
49
82
  if (rawplugindata.supportedVersions) {
50
83
  if (!Array.isArray(rawplugindata.supportedVersions))
51
- throw new index_1.api.ODPluginError("Failed to load plugin.json/supportedVersions (must be array)");
84
+ throw new api.ODPluginError("Failed to load plugin.json/supportedVersions (must be array)");
52
85
  for (const version of rawplugindata.supportedVersions) {
53
86
  if (typeof version !== "string") {
54
- throw new index_1.api.ODPluginError("Failed to load plugin.json/supportedVersions (all items must be strings)");
87
+ throw new api.ODPluginError("Failed to load plugin.json/supportedVersions (all items must be strings)");
55
88
  }
56
89
  //only OT (Open Ticket) & OM (Open Moderation) are supported at the moment
57
90
  if (!pluginVersionRegex.test(version)) {
58
- throw new index_1.api.ODPluginError(`Failed to load plugin.json/supportedVersions (invalid format: "${version}", expected format like "OTv4.0.x" or "OMv1.0.0")`);
91
+ throw new api.ODPluginError(`Failed to load plugin.json/supportedVersions (invalid format: "${version}", expected format like "OTv4.0.x" or "OMv1.0.0")`);
59
92
  }
60
93
  }
61
94
  }
62
95
  if (typeof rawplugindata.enabled != "boolean")
63
- throw new index_1.api.ODPluginError("Failed to load plugin.json/enabled");
96
+ throw new api.ODPluginError("Failed to load plugin.json/enabled");
64
97
  if (typeof rawplugindata.priority != "number")
65
- throw new index_1.api.ODPluginError("Failed to load plugin.json/priority");
98
+ throw new api.ODPluginError("Failed to load plugin.json/priority");
66
99
  if (!Array.isArray(rawplugindata.events))
67
- throw new index_1.api.ODPluginError("Failed to load plugin.json/events");
100
+ throw new api.ODPluginError("Failed to load plugin.json/events");
68
101
  if (!Array.isArray(rawplugindata.npmDependencies))
69
- throw new index_1.api.ODPluginError("Failed to load plugin.json/npmDependencies");
102
+ throw new api.ODPluginError("Failed to load plugin.json/npmDependencies");
70
103
  if (!Array.isArray(rawplugindata.requiredPlugins))
71
- throw new index_1.api.ODPluginError("Failed to load plugin.json/requiredPlugins");
104
+ throw new api.ODPluginError("Failed to load plugin.json/requiredPlugins");
72
105
  if (!Array.isArray(rawplugindata.incompatiblePlugins))
73
- throw new index_1.api.ODPluginError("Failed to load plugin.json/incompatiblePlugins");
106
+ throw new api.ODPluginError("Failed to load plugin.json/incompatiblePlugins");
74
107
  if (typeof rawplugindata.details != "object")
75
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details");
108
+ throw new api.ODPluginError("Failed to load plugin.json/details");
76
109
  if (typeof rawplugindata.details.author != "string")
77
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/author");
110
+ throw new api.ODPluginError("Failed to load plugin.json/details/author");
78
111
  //only check "contributors" if it exists (should be array)
79
112
  if (rawplugindata.details.contributors && !Array.isArray(rawplugindata.details.contributors))
80
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/contributors (must be array)");
113
+ throw new api.ODPluginError("Failed to load plugin.json/details/contributors (must be array)");
81
114
  if (typeof rawplugindata.details.shortDescription != "string")
82
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/shortDescription");
115
+ throw new api.ODPluginError("Failed to load plugin.json/details/shortDescription");
83
116
  if (typeof rawplugindata.details.longDescription != "string")
84
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/longDescription");
117
+ throw new api.ODPluginError("Failed to load plugin.json/details/longDescription");
85
118
  if (typeof rawplugindata.details.imageUrl != "string")
86
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/imageUrl");
119
+ throw new api.ODPluginError("Failed to load plugin.json/details/imageUrl");
87
120
  if (typeof rawplugindata.details.projectUrl != "string")
88
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/projectUrl");
121
+ throw new api.ODPluginError("Failed to load plugin.json/details/projectUrl");
89
122
  if (!Array.isArray(rawplugindata.details.tags))
90
- throw new index_1.api.ODPluginError("Failed to load plugin.json/details/tags");
123
+ throw new api.ODPluginError("Failed to load plugin.json/details/tags");
91
124
  if (rawplugindata.id != p)
92
- throw new index_1.api.ODPluginError("Failed to load plugin, directory name is required to match the id");
125
+ throw new api.ODPluginError("Failed to load plugin, directory name is required to match the id");
93
126
  if (opendiscord.plugins.exists(rawplugindata.id))
94
- throw new index_1.api.ODPluginError("Failed to load plugin, this id already exists in another plugin");
127
+ throw new api.ODPluginError("Failed to load plugin, this id already exists in another plugin");
95
128
  //plugin.json is valid => load plugin
96
- const plugin = new index_1.api.ODPlugin(p, rawplugindata);
129
+ const plugin = new api.ODPlugin(p, rawplugindata);
97
130
  opendiscord.plugins.add(plugin);
98
131
  }
99
132
  catch (e) {
@@ -134,7 +167,7 @@ const loadAllPlugins = async (opendiscord) => {
134
167
  if (plugin.data.supportedVersions && plugin.data.supportedVersions.length > 0) {
135
168
  const currentVersion = opendiscord.versions.get("opendiscord:version");
136
169
  if (!currentVersion)
137
- throw new index_1.api.ODSystemError("Unable to get project version: opendiscord.versions.get('opendiscord:version')!");
170
+ throw new api.ODSystemError("Unable to get project version: opendiscord.versions.get('opendiscord:version')!");
138
171
  let isCompatible = false;
139
172
  for (const versionStr of plugin.data.supportedVersions) {
140
173
  const match = versionStr.match(pluginVersionRegex);
@@ -231,7 +264,7 @@ const loadAllPlugins = async (opendiscord) => {
231
264
  //preload all events required for every plugin
232
265
  for (const plugin of sortedPlugins) {
233
266
  if (plugin.enabled)
234
- plugin.data.events.forEach((event) => opendiscord.events.add(new index_1.api.ODEvent(event)));
267
+ plugin.data.events.forEach((event) => opendiscord.events.add(new api.ODEvent(event)));
235
268
  }
236
269
  //execute all working plugins
237
270
  for (const plugin of sortedPlugins) {
@@ -1,4 +1,4 @@
1
- import * as api from "./api";
1
+ import * as api from "../api/index";
2
2
  /**## sharedFuses `utility variable`
3
3
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
4
4
  */
@@ -51,7 +51,7 @@ exports.ordinalNumber = ordinalNumber;
51
51
  exports.trimEmojis = trimEmojis;
52
52
  const fs = __importStar(require("fs"));
53
53
  const ansis_1 = __importDefault(require("ansis"));
54
- const api = __importStar(require("./api"));
54
+ const api = __importStar(require("../api/index"));
55
55
  /**## sharedFuses `utility variable`
56
56
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
57
57
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.0.7",
4
+ "version": "0.1.0",
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",
@@ -25,5 +25,10 @@
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"
28
+ },
29
+ "exports": {
30
+ ".": "./dist/index.js",
31
+ "./api": "./dist/api/index.js",
32
+ "./utilities": "./dist/utilities/index.js"
28
33
  }
29
34
  }
@@ -592,16 +592,16 @@ export class ODLiveStatusManager extends ODManager<ODLiveStatusSource> {
592
592
  /**The class responsible for rendering the livestatus messages. */
593
593
  renderer: ODLiveStatusRenderer
594
594
  /**A reference to the ODMain or "opendiscord" global variable */
595
- #main: ODMain
595
+ #main: ODMain|null = null
596
596
 
597
- constructor(debug:ODDebugger, main:ODMain){
597
+ constructor(debug:ODDebugger,console:ODConsoleManager){
598
598
  super(debug,"livestatus source")
599
- this.renderer = new ODLiveStatusRenderer(main.console)
600
- this.#main = main
599
+ this.renderer = new ODLiveStatusRenderer(console)
601
600
  }
602
601
 
603
602
  /**Get the messages from all sources combined! */
604
603
  async getAllMessages(): Promise<ODLiveStatusSourceData[]> {
604
+ if (!this.#main) throw new ODSystemError("ODLiveStatusManager:getAllMessages() --> Unable to get messages, 'opendiscord/ODMain' has not been connected!")
605
605
  const messages: ODLiveStatusSourceData[] = []
606
606
  for (const source of this.getAll()){
607
607
  try {
@@ -610,6 +610,10 @@ export class ODLiveStatusManager extends ODManager<ODLiveStatusSource> {
610
610
  }
611
611
  return messages
612
612
  }
613
+ /**Set the opendiscord `ODMain` class to use for fetching message filters. */
614
+ useMain(main:ODMain){
615
+ this.#main = main
616
+ }
613
617
  }
614
618
 
615
619
  /**## ODLiveStatusRenderer `class`
@@ -1,7 +1,8 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import {Terminal, terminal} from "terminal-kit"
3
4
  import ansis from "ansis"
4
- import {ODCliHeaderOpts, renderHeader} from "./cli"
5
+ import {ODCliHeaderOpts, renderHeader} from "."
5
6
 
6
7
  export class ODCliEditConfigInstance {
7
8
  private readonly opts: ODCliHeaderOpts
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import {Terminal, terminal} from "terminal-kit"
3
4
  import * as discord from "discord.js"
4
5
  import ansis from "ansis"
package/src/index.ts CHANGED
@@ -1,7 +1,3 @@
1
-
2
- export * as api from "./api/api"
3
- export * as utilities from "./api/utils"
4
- export * as cli from "./cli/cli"
5
1
  export { loadDumpCommand } from "./startup/dump"
6
2
  export { loadAllPlugins } from "./startup/pluginLauncher"
7
3
  export { frameworkStartup } from "./startup/compilation"
@@ -3,7 +3,7 @@ import ts from "typescript"
3
3
  import { createHash, Hash } from "crypto"
4
4
  import nodepath from "path"
5
5
  import ansis from "ansis"
6
- import type { ODProjectType } from "../api/api"
6
+ import type { ODProjectType } from "../api"
7
7
 
8
8
  /** ## What is this?
9
9
  * This is a function which compares `./src/` with a hash stored in `./dist/hash.txt`.
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import * as discord from "discord.js"
3
4
  import * as fs from "fs"
4
5
 
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
 
3
4
  export function loadErrorHandling(opendiscord:api.ODMain,project:api.ODProjectType){
4
5
  process.on("uncaughtException",async (error,origin) => {
@@ -1,4 +1,5 @@
1
- import {api, utilities} from "../index"
1
+ import * as api from "../api/index"
2
+ import * as utilities from "../utilities/index"
2
3
  import fs from "fs"
3
4
 
4
5
  export const loadAllPlugins = async (opendiscord:api.ODMain) => {
@@ -1,6 +1,6 @@
1
1
  import * as fs from "fs"
2
2
  import ansis from "ansis"
3
- import * as api from "./api"
3
+ import * as api from "../api/index"
4
4
 
5
5
  /**## sharedFuses `utility variable`
6
6
  * All shared fuses from Open Discord. Please use `opendiscord.sharedFuses` instead!
File without changes
File without changes
File without changes
File without changes