@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.
Files changed (103) hide show
  1. package/LICENSE.md +713 -0
  2. package/README.md +104 -0
  3. package/dist/api/api.d.ts +26 -0
  4. package/dist/api/api.js +44 -0
  5. package/dist/api/main.d.ts +133 -0
  6. package/dist/api/main.js +87 -0
  7. package/dist/api/modules/action.d.ts +34 -0
  8. package/dist/api/modules/action.js +58 -0
  9. package/dist/api/modules/base.d.ts +329 -0
  10. package/dist/api/modules/base.js +804 -0
  11. package/dist/api/modules/builder.d.ts +647 -0
  12. package/dist/api/modules/builder.js +1441 -0
  13. package/dist/api/modules/checker.d.ts +648 -0
  14. package/dist/api/modules/checker.js +1324 -0
  15. package/dist/api/modules/client.d.ts +768 -0
  16. package/dist/api/modules/client.js +1859 -0
  17. package/dist/api/modules/code.d.ts +33 -0
  18. package/dist/api/modules/code.js +57 -0
  19. package/dist/api/modules/config.d.ts +70 -0
  20. package/dist/api/modules/config.js +206 -0
  21. package/dist/api/modules/console.d.ts +305 -0
  22. package/dist/api/modules/console.js +598 -0
  23. package/dist/api/modules/cooldown.d.ts +138 -0
  24. package/dist/api/modules/cooldown.js +359 -0
  25. package/dist/api/modules/database.d.ts +135 -0
  26. package/dist/api/modules/database.js +271 -0
  27. package/dist/api/modules/event.d.ts +43 -0
  28. package/dist/api/modules/event.js +100 -0
  29. package/dist/api/modules/flag.d.ts +40 -0
  30. package/dist/api/modules/flag.js +72 -0
  31. package/dist/api/modules/fuse.d.ts +218 -0
  32. package/dist/api/modules/fuse.js +123 -0
  33. package/dist/api/modules/helpmenu.d.ts +106 -0
  34. package/dist/api/modules/helpmenu.js +167 -0
  35. package/dist/api/modules/language.d.ts +85 -0
  36. package/dist/api/modules/language.js +195 -0
  37. package/dist/api/modules/permission.d.ts +121 -0
  38. package/dist/api/modules/permission.js +314 -0
  39. package/dist/api/modules/plugin.d.ts +128 -0
  40. package/dist/api/modules/plugin.js +168 -0
  41. package/dist/api/modules/post.d.ts +44 -0
  42. package/dist/api/modules/post.js +92 -0
  43. package/dist/api/modules/progressbar.d.ts +108 -0
  44. package/dist/api/modules/progressbar.js +233 -0
  45. package/dist/api/modules/responder.d.ts +506 -0
  46. package/dist/api/modules/responder.js +1468 -0
  47. package/dist/api/modules/session.d.ts +58 -0
  48. package/dist/api/modules/session.js +171 -0
  49. package/dist/api/modules/startscreen.d.ts +165 -0
  50. package/dist/api/modules/startscreen.js +293 -0
  51. package/dist/api/modules/stat.d.ts +142 -0
  52. package/dist/api/modules/stat.js +293 -0
  53. package/dist/api/modules/verifybar.d.ts +54 -0
  54. package/dist/api/modules/verifybar.js +60 -0
  55. package/dist/api/modules/worker.d.ts +41 -0
  56. package/dist/api/modules/worker.js +93 -0
  57. package/dist/api/utils.d.ts +61 -0
  58. package/dist/api/utils.js +254 -0
  59. package/dist/index.d.ts +4 -1
  60. package/dist/index.js +40 -0
  61. package/dist/startup/dump.d.ts +14 -0
  62. package/dist/startup/dump.js +79 -0
  63. package/dist/startup/errorHandling.d.ts +2 -0
  64. package/dist/startup/errorHandling.js +43 -0
  65. package/dist/startup/pluginLauncher.d.ts +2 -0
  66. package/dist/startup/pluginLauncher.js +202 -0
  67. package/package.json +9 -3
  68. package/src/api/api.ts +29 -0
  69. package/src/api/main.ts +189 -0
  70. package/src/api/modules/action.ts +58 -0
  71. package/src/api/modules/base.ts +811 -0
  72. package/src/api/modules/builder.ts +1554 -0
  73. package/src/api/modules/checker.ts +1549 -0
  74. package/src/api/modules/client.ts +2247 -0
  75. package/src/api/modules/code.ts +58 -0
  76. package/src/api/modules/config.ts +159 -0
  77. package/src/api/modules/console.ts +665 -0
  78. package/src/api/modules/cooldown.ts +348 -0
  79. package/src/api/modules/database.ts +278 -0
  80. package/src/api/modules/event.ts +99 -0
  81. package/src/api/modules/flag.ts +73 -0
  82. package/src/api/modules/fuse.ts +348 -0
  83. package/src/api/modules/helpmenu.ts +216 -0
  84. package/src/api/modules/language.ts +201 -0
  85. package/src/api/modules/permission.ts +340 -0
  86. package/src/api/modules/plugin.ts +242 -0
  87. package/src/api/modules/post.ts +90 -0
  88. package/src/api/modules/progressbar.ts +232 -0
  89. package/src/api/modules/responder.ts +1420 -0
  90. package/src/api/modules/session.ts +155 -0
  91. package/src/api/modules/startscreen.ts +320 -0
  92. package/src/api/modules/stat.ts +313 -0
  93. package/src/api/modules/verifybar.ts +61 -0
  94. package/src/api/modules/worker.ts +93 -0
  95. package/src/api/utils.ts +206 -0
  96. package/src/cli/cli.ts +151 -0
  97. package/src/cli/editConfig.ts +943 -0
  98. package/src/index.ts +6 -1
  99. package/src/startup/compilation.ts +186 -0
  100. package/src/startup/dump.ts +45 -0
  101. package/src/startup/errorHandling.ts +38 -0
  102. package/src/startup/pluginLauncher.ts +261 -0
  103. package/LICENSE +0 -21
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ODStartScreenLogCategoryComponent = exports.ODStartScreenLiveStatusCategoryComponent = exports.ODStartScreenPluginsCategoryComponent = exports.ODStartScreenFlagsCategoryComponent = exports.ODStartScreenPropertiesCategoryComponent = exports.ODStartScreenCategoryComponent = exports.ODStartScreenHeaderComponent = exports.ODStartScreenLogoComponent = exports.ODStartScreenComponent = exports.ODStartScreenManager = void 0;
7
+ ///////////////////////////////////////
8
+ //STARTSCREEN MODULE
9
+ ///////////////////////////////////////
10
+ const base_1 = require("./base");
11
+ const console_1 = require("./console");
12
+ const ansis_1 = __importDefault(require("ansis"));
13
+ /**## ODStartScreenManager `class`
14
+ * This is an Open Discord startscreen manager.
15
+ *
16
+ * This class is responsible for managing & rendering the startscreen of the bot.
17
+ * The startscreen is the part you see when the bot has started up successfully. (e.g. the Open Discord logo, logs, livestatus, flags, ...)
18
+ */
19
+ class ODStartScreenManager extends base_1.ODManager {
20
+ /**Alias to the Open Discord debugger. */
21
+ #debug;
22
+ /**Alias to the livestatus manager. */
23
+ livestatus;
24
+ constructor(debug, livestatus) {
25
+ super(debug, "startscreen component");
26
+ this.#debug = debug;
27
+ this.livestatus = livestatus;
28
+ }
29
+ /**Get all components in sorted order. */
30
+ getSortedComponents(priority) {
31
+ return this.getAll().sort((a, b) => {
32
+ if (priority == "ascending")
33
+ return a.priority - b.priority;
34
+ else
35
+ return b.priority - a.priority;
36
+ });
37
+ }
38
+ /**Render all startscreen components in priority order. */
39
+ async renderAllComponents() {
40
+ const components = this.getSortedComponents("descending");
41
+ let location = 0;
42
+ for (const component of components) {
43
+ try {
44
+ const renderedText = await component.renderAll(location);
45
+ console.log(renderedText);
46
+ this.#debug.console.debugfile.writeText("[STARTSCREEN] Component: \"" + component.id + "\"\n" + ansis_1.default.strip(renderedText));
47
+ }
48
+ catch (e) {
49
+ this.#debug.console.log("Unable to render \"" + component.id + "\" startscreen component!", "error");
50
+ this.#debug.console.debugfile.writeErrorMessage(new console_1.ODError(e, "uncaughtException"));
51
+ }
52
+ location++;
53
+ }
54
+ }
55
+ }
56
+ exports.ODStartScreenManager = ODStartScreenManager;
57
+ /**## ODStartScreenComponent `class`
58
+ * This is an Open Discord startscreen component.
59
+ *
60
+ * This component can be rendered to the start screen of the bot.
61
+ * An optional priority can be specified to choose the location of the component.
62
+ *
63
+ * It's recommended to use pre-built components except if you really need a custom one.
64
+ */
65
+ class ODStartScreenComponent extends base_1.ODManagerData {
66
+ /**The priority of this component. */
67
+ priority;
68
+ /**An optional render function which will be inserted before the default renderer. */
69
+ renderBefore = null;
70
+ /**The render function which will render the contents of this component. */
71
+ render;
72
+ /**An optional render function which will be inserted behind the default renderer. */
73
+ renderAfter = null;
74
+ constructor(id, priority, render) {
75
+ super(id);
76
+ this.priority = priority;
77
+ this.render = render;
78
+ }
79
+ /**Render this component and combine it with the `renderBefore` & `renderAfter` contents. */
80
+ async renderAll(location) {
81
+ const textBefore = (this.renderBefore) ? await this.renderBefore(location) : "";
82
+ const text = await this.render(location);
83
+ const textAfter = (this.renderAfter) ? await this.renderAfter(location) : "";
84
+ return (textBefore ? textBefore + "\n" : "") + text + (textAfter ? "\n" + textAfter : "");
85
+ }
86
+ }
87
+ exports.ODStartScreenComponent = ODStartScreenComponent;
88
+ /**## ODStartScreenLogoComponent `class`
89
+ * This is an Open Discord startscreen logo component.
90
+ *
91
+ * This component will render an ASCII art logo (from an array) to the startscreen. Every property in the array is another row.
92
+ * An optional priority can be specified to choose the location of the component.
93
+ */
94
+ class ODStartScreenLogoComponent extends ODStartScreenComponent {
95
+ /**The ASCII logo contents. */
96
+ logo;
97
+ /**When enabled, the component will add a new line above the logo. */
98
+ topPadding;
99
+ /**When enabled, the component will add a new line below the logo. */
100
+ bottomPadding;
101
+ /**The color of the logo in hex format. */
102
+ logoHexColor;
103
+ constructor(id, priority, logo, topPadding, bottomPadding, logoHexColor) {
104
+ super(id, priority, () => {
105
+ const renderedTop = (this.topPadding ? "\n" : "");
106
+ const renderedLogo = this.logo.join("\n");
107
+ const renderedBottom = (this.bottomPadding ? "\n" : "");
108
+ return ansis_1.default.hex(this.logoHexColor)(renderedTop + renderedLogo + renderedBottom);
109
+ });
110
+ this.logo = logo;
111
+ this.topPadding = topPadding ?? false;
112
+ this.bottomPadding = bottomPadding ?? false;
113
+ this.logoHexColor = logoHexColor ?? "#f8ba00";
114
+ }
115
+ }
116
+ exports.ODStartScreenLogoComponent = ODStartScreenLogoComponent;
117
+ /**## ODStartScreenHeaderComponent `class`
118
+ * This is an Open Discord startscreen header component.
119
+ *
120
+ * This component will render a header to the startscreen. Properties can be aligned left, right or centered.
121
+ * An optional priority can be specified to choose the location of the component.
122
+ */
123
+ class ODStartScreenHeaderComponent extends ODStartScreenComponent {
124
+ /**All properties of this header component. */
125
+ properties;
126
+ /**The spacer used between properties. */
127
+ spacer;
128
+ /**The alignment settings of this header component. */
129
+ align;
130
+ constructor(id, priority, properties, spacer, align) {
131
+ super(id, priority, async () => {
132
+ const renderedProperties = ansis_1.default.bold(this.properties.map((prop) => prop.key + ": " + prop.value).join(this.spacer));
133
+ if (!this.align || this.align.align == "left") {
134
+ return renderedProperties;
135
+ }
136
+ else if (this.align.align == "right") {
137
+ const width = (typeof this.align.width == "number") ? this.align.width : (ansis_1.default.strip(await this.align.width.renderAll(0)).split("\n").map((row) => row.length).reduce((prev, curr) => {
138
+ if (prev < curr)
139
+ return curr;
140
+ else
141
+ return prev;
142
+ }, 0));
143
+ const offset = width - ansis_1.default.strip(renderedProperties).length;
144
+ if (offset < 0)
145
+ return renderedProperties;
146
+ else {
147
+ return (" ".repeat(offset) + renderedProperties);
148
+ }
149
+ }
150
+ else if (this.align.align == "center") {
151
+ const width = (typeof this.align.width == "number") ? this.align.width : (ansis_1.default.strip(await this.align.width.renderAll(0)).split("\n").map((row) => row.length).reduce((prev, curr) => {
152
+ if (prev < curr)
153
+ return curr;
154
+ else
155
+ return prev;
156
+ }));
157
+ const offset = Math.round((width - ansis_1.default.strip(renderedProperties).length) / 2);
158
+ if (offset < 0)
159
+ return renderedProperties;
160
+ else {
161
+ return (" ".repeat(offset) + renderedProperties);
162
+ }
163
+ }
164
+ return renderedProperties;
165
+ });
166
+ this.properties = properties;
167
+ this.spacer = spacer ?? " - ";
168
+ this.align = align ?? null;
169
+ }
170
+ }
171
+ exports.ODStartScreenHeaderComponent = ODStartScreenHeaderComponent;
172
+ /**## ODStartScreenCategoryComponent `class`
173
+ * This is an Open Discord startscreen category component.
174
+ *
175
+ * This component will render a category to the startscreen. This will only render the category name. You'll need to provide your own renderer for the contents.
176
+ * An optional priority can be specified to choose the location of the component.
177
+ */
178
+ class ODStartScreenCategoryComponent extends ODStartScreenComponent {
179
+ /**The name of this category. */
180
+ name;
181
+ /**When enabled, this category will still be rendered when the contents are empty. (enabled by default) */
182
+ renderIfEmpty;
183
+ constructor(id, priority, name, render, renderIfEmpty) {
184
+ super(id, priority, async (location) => {
185
+ const contents = await render(location);
186
+ if (contents != "" || this.renderIfEmpty) {
187
+ return ansis_1.default.bold.underline("\n" + name.toUpperCase() + (contents != "" ? ":\n" : ":")) + contents;
188
+ }
189
+ else
190
+ return "";
191
+ });
192
+ this.name = name;
193
+ this.renderIfEmpty = renderIfEmpty ?? true;
194
+ }
195
+ }
196
+ exports.ODStartScreenCategoryComponent = ODStartScreenCategoryComponent;
197
+ /**## ODStartScreenPropertiesCategoryComponent `class`
198
+ * This is an Open Discord startscreen properties category component.
199
+ *
200
+ * This component will render a properties category to the startscreen. This will list the properties in the category.
201
+ * An optional priority can be specified to choose the location of the component.
202
+ */
203
+ class ODStartScreenPropertiesCategoryComponent extends ODStartScreenCategoryComponent {
204
+ /**The properties of this category component. */
205
+ properties;
206
+ /**The hex color for the key/name of all the properties. */
207
+ propertyHexColor;
208
+ constructor(id, priority, name, properties, propertyHexColor, renderIfEmpty) {
209
+ super(id, priority, name, () => {
210
+ return this.properties.map((prop) => ansis_1.default.hex(this.propertyHexColor)(prop.key + ": ") + prop.value).join("\n");
211
+ }, renderIfEmpty);
212
+ this.properties = properties;
213
+ this.propertyHexColor = propertyHexColor ?? "#f8ba00";
214
+ }
215
+ }
216
+ exports.ODStartScreenPropertiesCategoryComponent = ODStartScreenPropertiesCategoryComponent;
217
+ /**## ODStartScreenFlagsCategoryComponent `class`
218
+ * This is an Open Discord startscreen flags category component.
219
+ *
220
+ * This component will render a flags category to the startscreen. This will list the enabled flags in the category.
221
+ * An optional priority can be specified to choose the location of the component.
222
+ */
223
+ class ODStartScreenFlagsCategoryComponent extends ODStartScreenCategoryComponent {
224
+ /**A list of all flags to render. */
225
+ flags;
226
+ constructor(id, priority, flags) {
227
+ super(id, priority, "flags", () => {
228
+ return this.flags.filter((flag) => (flag.value == true)).map((flag) => ansis_1.default.blue("[" + flag.name + "] " + flag.description)).join("\n");
229
+ }, false);
230
+ this.flags = flags;
231
+ }
232
+ }
233
+ exports.ODStartScreenFlagsCategoryComponent = ODStartScreenFlagsCategoryComponent;
234
+ /**## ODStartScreenPluginsCategoryComponent `class`
235
+ * This is an Open Discord startscreen plugins category component.
236
+ *
237
+ * This component will render a plugins category to the startscreen. This will list the enabled, disabled & crashed plugins in the category.
238
+ * An optional priority can be specified to choose the location of the component.
239
+ */
240
+ class ODStartScreenPluginsCategoryComponent extends ODStartScreenCategoryComponent {
241
+ /**A list of all plugins to render. */
242
+ plugins;
243
+ /**A list of all crashed plugins to render. */
244
+ unknownCrashedPlugins;
245
+ constructor(id, priority, plugins, unknownCrashedPlugins) {
246
+ super(id, priority, "plugins", () => {
247
+ const disabledPlugins = this.plugins.filter((plugin) => !plugin.enabled);
248
+ const renderedActivePlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.executed).sort((a, b) => b.priority - a.priority).map((plugin) => ansis_1.default.green("✅ [" + plugin.name + "] " + plugin.details.shortDescription));
249
+ const renderedCrashedPlugins = this.plugins.filter((plugin) => plugin.enabled && plugin.crashed).sort((a, b) => b.priority - a.priority).map((plugin) => ansis_1.default.red("❌ [" + plugin.name + "] " + plugin.details.shortDescription));
250
+ const renderedDisabledPlugins = (disabledPlugins.length > 4) ? [ansis_1.default.gray("💤 (+" + disabledPlugins.length + " disabled plugins)")] : disabledPlugins.sort((a, b) => b.priority - a.priority).map((plugin) => ansis_1.default.gray("💤 [" + plugin.name + "] " + plugin.details.shortDescription));
251
+ const renderedUnknownPlugins = unknownCrashedPlugins.map((plugin) => ansis_1.default.red("❌ [" + plugin.name + "] " + plugin.description));
252
+ return [
253
+ ...renderedActivePlugins,
254
+ ...renderedDisabledPlugins,
255
+ ...renderedCrashedPlugins,
256
+ ...renderedUnknownPlugins
257
+ ].join("\n");
258
+ }, false);
259
+ this.plugins = plugins;
260
+ this.unknownCrashedPlugins = unknownCrashedPlugins;
261
+ }
262
+ }
263
+ exports.ODStartScreenPluginsCategoryComponent = ODStartScreenPluginsCategoryComponent;
264
+ /**## ODStartScreenLiveStatusCategoryComponent `class`
265
+ * This is an Open Discord startscreen livestatus category component.
266
+ *
267
+ * This component will render a livestatus category to the startscreen. This will list the livestatus messages in the category.
268
+ * An optional priority can be specified to choose the location of the component.
269
+ */
270
+ class ODStartScreenLiveStatusCategoryComponent extends ODStartScreenCategoryComponent {
271
+ /**A reference to the Open Discord livestatus manager. */
272
+ livestatus;
273
+ constructor(id, priority, livestatus) {
274
+ super(id, priority, "livestatus", async () => {
275
+ const messages = await this.livestatus.getAllMessages();
276
+ return this.livestatus.renderer.render(messages);
277
+ }, false);
278
+ this.livestatus = livestatus;
279
+ }
280
+ }
281
+ exports.ODStartScreenLiveStatusCategoryComponent = ODStartScreenLiveStatusCategoryComponent;
282
+ /**## ODStartScreenLogsCategoryComponent `class`
283
+ * This is an Open Discord startscreen logs category component.
284
+ *
285
+ * This component will render a logs category to the startscreen. This will only render the logs category name.
286
+ * An optional priority can be specified to choose the location of the component.
287
+ */
288
+ class ODStartScreenLogCategoryComponent extends ODStartScreenCategoryComponent {
289
+ constructor(id, priority) {
290
+ super(id, priority, "logs", () => "", true);
291
+ }
292
+ }
293
+ exports.ODStartScreenLogCategoryComponent = ODStartScreenLogCategoryComponent;
@@ -0,0 +1,142 @@
1
+ import { ODId, ODManager, ODManagerData, ODValidId } from "./base";
2
+ import { ODDebugger } from "./console";
3
+ import { ODDatabase, ODJsonDatabaseStructure } from "./database";
4
+ import * as discord from "discord.js";
5
+ /**## ODValidStatValue `type`
6
+ * These are the only allowed types for a stat value to improve compatibility with different database systems.
7
+ */
8
+ export type ODValidStatValue = string | number | boolean;
9
+ /**## ODStatsManagerInitCallback `type`
10
+ * This callback can be used to execute something when the stats have been initiated.
11
+ *
12
+ * By default this is used to clear stats from users that left the server or tickets which don't exist anymore.
13
+ */
14
+ export type ODStatsManagerInitCallback = (database: ODJsonDatabaseStructure, deletables: ODJsonDatabaseStructure) => void | Promise<void>;
15
+ /**## ODStatScopeSetMode `type`
16
+ * This type contains all valid methods for changing the value of a stat.
17
+ */
18
+ export type ODStatScopeSetMode = "set" | "increase" | "decrease";
19
+ /**## ODStatsManager `class`
20
+ * This is an Open Discord stats manager.
21
+ *
22
+ * This class is responsible for managing all stats of the bot.
23
+ * Stats are categorized in "scopes" which can be accessed in this manager.
24
+ *
25
+ * Stats can be accessed in the individual scopes.
26
+ */
27
+ export declare class ODStatsManager extends ODManager<ODStatScope> {
28
+ #private;
29
+ /**Alias to Open Discord stats database. */
30
+ database: ODDatabase | null;
31
+ constructor(debug: ODDebugger);
32
+ /**Select the database to use to read/write all stats from/to. */
33
+ useDatabase(database: ODDatabase): void;
34
+ add(data: ODStatScope, overwrite?: boolean): boolean;
35
+ /**Init all stats and run `onInit()` listeners. */
36
+ init(): Promise<void>;
37
+ /**Reset all stats. (clears the entire database) */
38
+ reset(): Promise<void>;
39
+ /**Run a function when the stats are initialized. This can be used to clear stats from users that left the server or tickets which don't exist anymore. */
40
+ onInit(callback: ODStatsManagerInitCallback): void;
41
+ }
42
+ /**## ODStatScope `class`
43
+ * This is an Open Discord stat scope.
44
+ *
45
+ * A scope can contain multiple stats. Every scope is seperated from other scopes.
46
+ * Here, you can read & write the values of all stats.
47
+ *
48
+ * The built-in Open Discord scopes are: `global`, `user`, `ticket`
49
+ */
50
+ export declare class ODStatScope extends ODManager<ODStat> {
51
+ /**The id of this statistics scope. */
52
+ id: ODId;
53
+ /**Is this stat scope already initialized? */
54
+ ready: boolean;
55
+ /**Alias to Open Discord stats database. */
56
+ database: ODDatabase | null;
57
+ /**The name of this scope (used in embed title) */
58
+ name: string;
59
+ constructor(id: ODValidId, name: string);
60
+ /**Select the database to use to read/write all stats from/to. (Automatically assigned when used in `ODStatsManager`) */
61
+ useDatabase(database: ODDatabase): void;
62
+ /**Get the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
63
+ getStat(id: ODValidId, scopeId: string): Promise<ODValidStatValue | null>;
64
+ /**Get the value of a statistic for all `scopeId`'s. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
65
+ getAllStats(id: ODValidId): Promise<{
66
+ id: string;
67
+ value: ODValidStatValue;
68
+ }[]>;
69
+ /**Set, increase or decrease the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
70
+ setStat(id: ODValidId, scopeId: string, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
71
+ /**Reset the value of a statistic to the initial value. The `scopeId` is the unique id of the user, channel, role, etc that the stats are related to. */
72
+ resetStat(id: ODValidId, scopeId: string): Promise<ODValidStatValue | null>;
73
+ /**Initialize this stat scope & return a list of all statistic ids in the following format: `<scopeid>_<statid>` */
74
+ init(): string[];
75
+ /**Render all stats in this scope for usage in a discord message/embed. */
76
+ render(scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
77
+ }
78
+ /**## ODStatGlobalScope `class`
79
+ * This is an Open Discord stat global scope.
80
+ *
81
+ * A scope can contain multiple stats. Every scope is seperated from other scopes.
82
+ * Here, you can read & write the values of all stats.
83
+ *
84
+ * This scope is made specifically for the global stats of Open Discord.
85
+ */
86
+ export declare class ODStatGlobalScope extends ODStatScope {
87
+ getStat(id: ODValidId): Promise<ODValidStatValue | null>;
88
+ getAllStats(id: ODValidId): Promise<{
89
+ id: string;
90
+ value: ODValidStatValue;
91
+ }[]>;
92
+ setStat(id: ODValidId, value: ODValidStatValue, mode: ODStatScopeSetMode): Promise<boolean>;
93
+ resetStat(id: ODValidId): Promise<ODValidStatValue | null>;
94
+ render(scopeId: "GLOBAL", guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
95
+ }
96
+ /**## ODStatRenderer `type`
97
+ * This callback will render a single statistic for a discord embed/message.
98
+ */
99
+ export type ODStatRenderer = (value: ODValidStatValue, scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User) => string | Promise<string>;
100
+ /**## ODStat `class`
101
+ * This is an Open Discord statistic.
102
+ *
103
+ * This single statistic doesn't do anything except defining the rules of this statistic.
104
+ * Use it in a stats scope to register a new statistic. A statistic can also include a priority to choose the render priority.
105
+ *
106
+ * It's recommended to use the `ODBasicStat` & `ODDynamicStat` classes instead of this one!
107
+ */
108
+ export declare class ODStat extends ODManagerData {
109
+ /**The priority of this statistic. */
110
+ priority: number;
111
+ /**The render function of this statistic. */
112
+ render: ODStatRenderer;
113
+ /**The value of this statistic. */
114
+ value: ODValidStatValue | null;
115
+ constructor(id: ODValidId, priority: number, render: ODStatRenderer, value?: ODValidStatValue);
116
+ }
117
+ /**## ODBasicStat `class`
118
+ * This is an Open Discord basic statistic.
119
+ *
120
+ * This single statistic will store a number, boolean or string in the database.
121
+ * Use it to create a simple statistic for any stats scope.
122
+ */
123
+ export declare class ODBasicStat extends ODStat {
124
+ /**The name of this stat. Rendered in discord embeds/messages. */
125
+ name: string;
126
+ constructor(id: ODValidId, priority: number, name: string, value: ODValidStatValue);
127
+ }
128
+ /**## ODDynamicStatRenderer `type`
129
+ * This callback will render a single dynamic statistic for a discord embed/message.
130
+ */
131
+ export type ODDynamicStatRenderer = (scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User) => string | Promise<string>;
132
+ /**## ODDynamicStat `class`
133
+ * This is an Open Discord dynamic statistic.
134
+ *
135
+ * A dynamic statistic does not store anything in the database! Instead, it will execute a function to return a custom result.
136
+ * This can be used to show statistics which are not stored in the database.
137
+ *
138
+ * This is used in Open Discord for the live ticket status, participants & system status.
139
+ */
140
+ export declare class ODDynamicStat extends ODStat {
141
+ constructor(id: ODValidId, priority: number, render: ODDynamicStatRenderer);
142
+ }