@open-discord-bots/framework 0.2.4 → 0.2.5

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 CHANGED
@@ -45,7 +45,7 @@ We do currently <b>NOT</b> provide support for <b>3rd party implementations</b>
45
45
 
46
46
  - **Permissions** - An easy to use system for managing bot permissions for users, roles & channels at the same time.
47
47
 
48
- - **Stats** - Save, modify and keep track of statistics for users, channels, roles or custom entities.
48
+ - **Statistics** - Save, modify and keep track of statistics for users, channels, roles or custom entities.
49
49
 
50
50
  - **Workers** - Many features use a worker-based system to allow extensible/overwritable code by plugins.
51
51
 
@@ -17,7 +17,7 @@ export * from "./modules/action";
17
17
  export * from "./modules/permission";
18
18
  export * from "./modules/helpmenu";
19
19
  export * from "./modules/session";
20
- export * from "./modules/stat";
20
+ export * from "./modules/statistic";
21
21
  export * from "./modules/code";
22
22
  export * from "./modules/cooldown";
23
23
  export * from "./modules/post";
package/dist/api/index.js CHANGED
@@ -35,7 +35,7 @@ __exportStar(require("./modules/action"), exports);
35
35
  __exportStar(require("./modules/permission"), exports);
36
36
  __exportStar(require("./modules/helpmenu"), exports);
37
37
  __exportStar(require("./modules/session"), exports);
38
- __exportStar(require("./modules/stat"), exports);
38
+ __exportStar(require("./modules/statistic"), exports);
39
39
  __exportStar(require("./modules/code"), exports);
40
40
  __exportStar(require("./modules/cooldown"), exports);
41
41
  __exportStar(require("./modules/post"), exports);
@@ -16,7 +16,7 @@ import { ODVerifyBarManager } from "./modules/verifybar";
16
16
  import { ODPermissionManager } from "./modules/permission";
17
17
  import { ODCooldownManager } from "./modules/cooldown";
18
18
  import { ODHelpMenuManager } from "./modules/helpmenu";
19
- import { ODStatsManager } from "./modules/stat";
19
+ import { ODStatisticManager } from "./modules/statistic";
20
20
  import { ODCodeManager } from "./modules/code";
21
21
  import { ODPostManager } from "./modules/post";
22
22
  import { ODClientManager } from "./modules/client";
@@ -71,7 +71,7 @@ export interface ODMainManagers {
71
71
  /**The manager that manages & renders the Open Discord help menu. (not the embed, but the text) */
72
72
  helpmenu: ODHelpMenuManager;
73
73
  /**The manager that manages, saves & renders the Open Discord statistics. (not the embed, but the text & database) */
74
- stats: ODStatsManager;
74
+ statistics: ODStatisticManager;
75
75
  /**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) */
76
76
  code: ODCodeManager;
77
77
  /**The manager that manages all posts (static discord channels) in the bot. (e.g. transcripts, logs, etc) */
@@ -117,7 +117,7 @@ export declare class ODMain implements ODMainManagers {
117
117
  readonly permissions: ODPermissionManager;
118
118
  readonly cooldowns: ODCooldownManager;
119
119
  readonly helpmenu: ODHelpMenuManager;
120
- readonly stats: ODStatsManager;
120
+ readonly statistics: ODStatisticManager;
121
121
  readonly code: ODCodeManager;
122
122
  readonly posts: ODPostManager;
123
123
  readonly client: ODClientManager;
package/dist/api/main.js CHANGED
@@ -34,7 +34,7 @@ class ODMain {
34
34
  permissions;
35
35
  cooldowns;
36
36
  helpmenu;
37
- stats;
37
+ statistics;
38
38
  code;
39
39
  posts;
40
40
  client;
@@ -67,7 +67,7 @@ class ODMain {
67
67
  this.permissions = managers.permissions;
68
68
  this.cooldowns = managers.cooldowns;
69
69
  this.helpmenu = managers.helpmenu;
70
- this.stats = managers.stats;
70
+ this.statistics = managers.statistics;
71
71
  this.code = managers.code;
72
72
  this.posts = managers.posts;
73
73
  this.sharedFuses = managers.sharedFuses;
@@ -7,7 +7,7 @@ import { ODDebugger } from "./console";
7
7
  * You can also specify a priority to change the execution order.
8
8
  * In Open Discord, this is used for the following processes:
9
9
  * - Autoclose/delete
10
- * - Database syncronisation (with tickets, stats & used options)
10
+ * - Database syncronisation (with tickets, statistics & used options)
11
11
  * - Panel auto-update
12
12
  * - Database Garbage Collection (removing tickets that don't exist anymore)
13
13
  * - And more!
@@ -12,7 +12,7 @@ const base_1 = require("./base");
12
12
  * You can also specify a priority to change the execution order.
13
13
  * In Open Discord, this is used for the following processes:
14
14
  * - Autoclose/delete
15
- * - Database syncronisation (with tickets, stats & used options)
15
+ * - Database syncronisation (with tickets, statistics & used options)
16
16
  * - Panel auto-update
17
17
  * - Database Garbage Collection (removing tickets that don't exist anymore)
18
18
  * - And more!
@@ -334,7 +334,7 @@ class ODDebugFileManager {
334
334
  fs_1.default.writeFileSync(this.path, newtext);
335
335
  }
336
336
  }
337
- /**Generate the stats/header of the debug file (containing the version) */
337
+ /**Generate the statistics/header of the debug file (containing the version) */
338
338
  #createStatsText() {
339
339
  const date = new Date();
340
340
  const dstring = `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
@@ -346,7 +346,7 @@ class ODDebugFileManager {
346
346
  "=========================\n\n"
347
347
  ].join("\n");
348
348
  }
349
- /**Write the stats/header to the debug file on startup */
349
+ /**Write the statistics/header to the debug file on startup */
350
350
  #writeStartupStats() {
351
351
  const currenttext = this.#readDebugFile();
352
352
  if (currenttext) {
@@ -182,12 +182,12 @@ export interface ODSharedFuseList {
182
182
  helpMenuCategoryLoading: boolean;
183
183
  /**Load the default Open Discord help menu components. */
184
184
  helpMenuComponentLoading: boolean;
185
- /**Load the default Open Discord stat scopes. */
186
- statScopesLoading: boolean;
187
- /**Load the default Open Discord stats. */
188
- statLoading: boolean;
189
- /**Initiate the default Open Discord stats. */
190
- statInitiating: boolean;
185
+ /**Load the default Open Discord statistic scopes. */
186
+ statisticScopesLoading: boolean;
187
+ /**Load the default Open Discord statistics. */
188
+ statisticLoading: boolean;
189
+ /**Initiate the default Open Discord statistics. */
190
+ statisticInitiating: boolean;
191
191
  /**Load the default Open Discord code/functions. */
192
192
  codeLoading: boolean;
193
193
  /**Execute the default Open Discord code/functions. */
@@ -106,9 +106,9 @@ class ODSharedFuseManager extends ODFuseManager {
106
106
  cooldownsInitiating: true,
107
107
  helpMenuCategoryLoading: true,
108
108
  helpMenuComponentLoading: true,
109
- statScopesLoading: true,
110
- statLoading: true,
111
- statInitiating: true,
109
+ statisticScopesLoading: true,
110
+ statisticLoading: true,
111
+ statisticInitiating: true,
112
112
  codeLoading: true,
113
113
  codeExecution: true,
114
114
  liveStatusLoading: true,
@@ -0,0 +1,176 @@
1
+ import { ODId, ODManager, ODManagerData, ODValidId } from "./base";
2
+ import { ODDebugger } from "./console";
3
+ import { ODDatabase, ODDatabaseIdConstraint, ODJsonDatabaseStructure } from "./database";
4
+ import * as discord from "discord.js";
5
+ /**## ODValidStatisticValue `type`
6
+ * These are the only allowed types for a statistic value to improve compatibility with different database systems.
7
+ */
8
+ export type ODValidStatisticValue = string | number | boolean;
9
+ /**## ODStatisticManagerInitCallback `type`
10
+ * This callback can be used to execute something when the statistics have been initiated.
11
+ *
12
+ * By default this is used to clear statistics from users that left the server or tickets which don't exist anymore.
13
+ */
14
+ export type ODStatisticManagerInitCallback = (database: ODJsonDatabaseStructure, deletables: ODJsonDatabaseStructure) => void | Promise<void>;
15
+ /**## ODStatisticScopeSetMode `type`
16
+ * This type contains all valid methods for changing the value of a statistic.
17
+ */
18
+ export type ODStatisticScopeSetMode = "set" | "increase" | "decrease";
19
+ /**## ODStatisticManagerIdConstraint `type`
20
+ * The constraint/layout for id mappings/interfaces of the `ODStatisticManager` class.
21
+ */
22
+ export type ODStatisticManagerIdConstraint = Record<string, ODStatisticScope>;
23
+ /**## ODStatisticManager `class`
24
+ * This is an Open Discord statistics manager.
25
+ *
26
+ * This class is responsible for managing all statistics of the bot.
27
+ * Statistic are categorized in "scopes" which can be accessed in this manager.
28
+ *
29
+ * Statistic can be accessed in the individual scopes.
30
+ */
31
+ export declare class ODStatisticManager<IdList extends ODStatisticManagerIdConstraint = ODStatisticManagerIdConstraint> extends ODManager<ODStatisticScope> {
32
+ #private;
33
+ /**Alias to Open Discord statistics database. */
34
+ database: ODDatabase<ODDatabaseIdConstraint> | null;
35
+ constructor(debug: ODDebugger);
36
+ /**Select the database to use to read/write all statistics from/to. */
37
+ useDatabase(database: ODDatabase<ODDatabaseIdConstraint>): void;
38
+ add(data: ODStatisticScope, overwrite?: boolean): boolean;
39
+ /**Init all statistics and run `onInit()` listeners. */
40
+ init(): Promise<void>;
41
+ /**Reset all statistics. (clears the entire database) */
42
+ reset(): Promise<void>;
43
+ /**Run a function when the statistics are initialized. This can be used to clear statistics from users that left the server or tickets which don't exist anymore. */
44
+ onInit(callback: ODStatisticManagerInitCallback): void;
45
+ get<ScopeId extends keyof IdList>(id: ScopeId): IdList[ScopeId];
46
+ get(id: ODValidId): ODStatisticScope | null;
47
+ remove<ScopeId extends keyof IdList>(id: ScopeId): IdList[ScopeId];
48
+ remove(id: ODValidId): ODStatisticScope | null;
49
+ exists(id: keyof IdList): boolean;
50
+ exists(id: ODValidId): boolean;
51
+ }
52
+ /**## ODStatisticScopeIdConstraint `type`
53
+ * The constraint/layout for id mappings/interfaces of the `ODStatisticScope` class.
54
+ */
55
+ export type ODStatisticScopeIdConstraint = Record<string, ODStatistic>;
56
+ /**## ODStatisticScope `class`
57
+ * This is an Open Discord statistic scope.
58
+ *
59
+ * A scope can contain multiple statistics. Every scope is seperated from other scopes.
60
+ * Here, you can read & write the values of all statistics.
61
+ *
62
+ * The built-in Open Discord scopes are: `global`, `user`, `ticket`
63
+ */
64
+ export declare class ODStatisticScope<IdList extends ODStatisticScopeIdConstraint = ODStatisticScopeIdConstraint> extends ODManager<ODStatistic> {
65
+ /**The id of this statistics scope. */
66
+ id: ODId;
67
+ /**Is this scope already initialized? */
68
+ ready: boolean;
69
+ /**Alias to Open Discord statistics database. */
70
+ database: ODDatabase<ODDatabaseIdConstraint> | null;
71
+ /**The name of this scope (used in embed title) */
72
+ name: string;
73
+ constructor(id: ODValidId, name: string);
74
+ /**Select the database to use to read/write all statistics from/to. (Automatically assigned when used in `ODStatisticManager`) */
75
+ useDatabase(database: ODDatabase<ODDatabaseIdConstraint>): void;
76
+ /**Get the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the statistics are related to. */
77
+ getStat<StatisticId extends keyof IdList>(id: StatisticId, scopeId: string): Promise<ODValidStatisticValue | null>;
78
+ getStat(id: ODValidId, scopeId: string): Promise<ODValidStatisticValue | null>;
79
+ /**Get the value of a statistic for all `scopeId`'s. The `scopeId` is the unique id of the user, channel, role, etc that the statistics are related to. */
80
+ getAllStats<StatisticId extends keyof IdList>(id: StatisticId): Promise<{
81
+ id: string;
82
+ value: ODValidStatisticValue;
83
+ }[]>;
84
+ getAllStats(id: ODValidId): Promise<{
85
+ id: string;
86
+ value: ODValidStatisticValue;
87
+ }[]>;
88
+ /**Set, increase or decrease the value of a statistic. The `scopeId` is the unique id of the user, channel, role, etc that the statistics are related to. */
89
+ setStat<StatisticId extends keyof IdList>(id: StatisticId, scopeId: string, value: ODValidStatisticValue, mode: ODStatisticScopeSetMode): Promise<boolean>;
90
+ setStat(id: ODValidId, scopeId: string, value: ODValidStatisticValue, mode: ODStatisticScopeSetMode): Promise<boolean>;
91
+ /**Reset the value of a statistic to the initial value. The `scopeId` is the unique id of the user, channel, role, etc that the statistics are related to. */
92
+ resetStat<StatisticId extends keyof IdList>(id: ODValidId, scopeId: string): Promise<ODValidStatisticValue | null>;
93
+ resetStat(id: ODValidId, scopeId: string): Promise<ODValidStatisticValue | null>;
94
+ /**Initialize this statistic scope & return a list of all statistic ids in the following format: `<scopeid>_<statid>` */
95
+ init(): string[];
96
+ /**Render all statistics in this scope for usage in a discord message/embed. */
97
+ render(scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
98
+ get<StatisticId extends keyof IdList>(id: StatisticId): IdList[StatisticId];
99
+ get(id: ODValidId): ODStatistic | null;
100
+ remove<StatisticId extends keyof IdList>(id: StatisticId): IdList[StatisticId];
101
+ remove(id: ODValidId): ODStatistic | null;
102
+ exists(id: keyof IdList): boolean;
103
+ exists(id: ODValidId): boolean;
104
+ }
105
+ /**## ODStatisticGlobalScope `class`
106
+ * This is an Open Discord statistic global scope.
107
+ *
108
+ * A scope can contain multiple statistics. Every scope is seperated from other scopes.
109
+ * Here, you can read & write the values of all statistics.
110
+ *
111
+ * This scope is made specifically for the global statistics of Open Discord.
112
+ */
113
+ export declare class ODStatisticGlobalScope<IdList extends ODStatisticScopeIdConstraint = ODStatisticScopeIdConstraint> extends ODStatisticScope<IdList> {
114
+ getStat<StatisticId extends keyof IdList>(id: StatisticId): Promise<ODValidStatisticValue | null>;
115
+ getStat(id: ODValidId): Promise<ODValidStatisticValue | null>;
116
+ getAllStats<StatisticId extends keyof IdList>(id: StatisticId): Promise<{
117
+ id: string;
118
+ value: ODValidStatisticValue;
119
+ }[]>;
120
+ getAllStats(id: ODValidId): Promise<{
121
+ id: string;
122
+ value: ODValidStatisticValue;
123
+ }[]>;
124
+ setStat<StatisticId extends keyof IdList>(id: StatisticId, value: ODValidStatisticValue, mode: ODStatisticScopeSetMode): Promise<boolean>;
125
+ setStat(id: ODValidId, value: ODValidStatisticValue, mode: ODStatisticScopeSetMode): Promise<boolean>;
126
+ resetStat<StatisticId extends keyof IdList>(id: ODValidId): Promise<ODValidStatisticValue | null>;
127
+ resetStat(id: ODValidId): Promise<ODValidStatisticValue | null>;
128
+ render(scopeId: "GLOBAL", guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User): Promise<string>;
129
+ }
130
+ /**## ODStatisticRenderer `type`
131
+ * This callback will render a single statistic for a discord embed/message.
132
+ */
133
+ export type ODStatisticRenderer = (value: ODValidStatisticValue, scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User) => string | Promise<string>;
134
+ /**## ODStatistic `class`
135
+ * This is an Open Discord statistic.
136
+ *
137
+ * This single statistic doesn't do anything except defining the rules of this statistic.
138
+ * Use it in a statistics scope to register a new statistic. A statistic can also include a priority to choose the render priority.
139
+ *
140
+ * It's recommended to use the `ODBaseStatistic` & `ODDynamicStatistic` classes instead of this one!
141
+ */
142
+ export declare class ODStatistic extends ODManagerData {
143
+ /**The priority of this statistic. */
144
+ priority: number;
145
+ /**The render function of this statistic. */
146
+ render: ODStatisticRenderer;
147
+ /**The value of this statistic. */
148
+ value: ODValidStatisticValue | null;
149
+ constructor(id: ODValidId, priority: number, render: ODStatisticRenderer, value?: ODValidStatisticValue);
150
+ }
151
+ /**## ODBaseStatistic `class`
152
+ * This is an Open Discord basic statistic.
153
+ *
154
+ * This single statistic will store a number, boolean or string in the database.
155
+ * Use it to create a simple statistic for any statistics scope.
156
+ */
157
+ export declare class ODBaseStatistic extends ODStatistic {
158
+ /**The name of this statistic. Rendered in discord embeds/messages. */
159
+ name: string;
160
+ constructor(id: ODValidId, priority: number, name: string, value: ODValidStatisticValue);
161
+ }
162
+ /**## ODDynamicStatisticRenderer `type`
163
+ * This callback will render a single dynamic statistic for a discord embed/message.
164
+ */
165
+ export type ODDynamicStatisticRenderer = (scopeId: string, guild: discord.Guild, channel: discord.TextBasedChannel, user: discord.User) => string | Promise<string>;
166
+ /**## ODDynamicStatistic `class`
167
+ * This is an Open Discord dynamic statistic.
168
+ *
169
+ * A dynamic statistic does not store anything in the database! Instead, it will execute a function to return a custom result.
170
+ * This can be used to show statistics which are not stored in the database.
171
+ *
172
+ * This is used in Open Discord for the live ticket status, participants & system status.
173
+ */
174
+ export declare class ODDynamicStatistic extends ODStatistic {
175
+ constructor(id: ODValidId, priority: number, render: ODDynamicStatisticRenderer);
176
+ }
@@ -1,30 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ODDynamicStat = exports.ODBasicStat = exports.ODStat = exports.ODStatGlobalScope = exports.ODStatScope = exports.ODStatsManager = void 0;
3
+ exports.ODDynamicStatistic = exports.ODBaseStatistic = exports.ODStatistic = exports.ODStatisticGlobalScope = exports.ODStatisticScope = exports.ODStatisticManager = void 0;
4
4
  ///////////////////////////////////////
5
- //STAT MODULE
5
+ //STATISTIC MODULE
6
6
  ///////////////////////////////////////
7
7
  const base_1 = require("./base");
8
- /**## ODStatsManager `class`
9
- * This is an Open Discord stats manager.
8
+ /**## ODStatisticManager `class`
9
+ * This is an Open Discord statistics manager.
10
10
  *
11
- * This class is responsible for managing all stats of the bot.
12
- * Stats are categorized in "scopes" which can be accessed in this manager.
11
+ * This class is responsible for managing all statistics of the bot.
12
+ * Statistic are categorized in "scopes" which can be accessed in this manager.
13
13
  *
14
- * Stats can be accessed in the individual scopes.
14
+ * Statistic can be accessed in the individual scopes.
15
15
  */
16
- class ODStatsManager extends base_1.ODManager {
16
+ class ODStatisticManager extends base_1.ODManager {
17
17
  /**Alias to Open Discord debugger. */
18
18
  #debug;
19
- /**Alias to Open Discord stats database. */
19
+ /**Alias to Open Discord statistics database. */
20
20
  database = null;
21
21
  /**All the listeners for the init event. */
22
22
  #initListeners = [];
23
23
  constructor(debug) {
24
- super(debug, "stat scope");
24
+ super(debug, "statistic scope");
25
25
  this.#debug = debug;
26
26
  }
27
- /**Select the database to use to read/write all stats from/to. */
27
+ /**Select the database to use to read/write all statistics from/to. */
28
28
  useDatabase(database) {
29
29
  this.database = database;
30
30
  }
@@ -34,16 +34,16 @@ class ODStatsManager extends base_1.ODManager {
34
34
  data.useDatabase(this.database);
35
35
  return super.add(data, overwrite);
36
36
  }
37
- /**Init all stats and run `onInit()` listeners. */
37
+ /**Init all statistics and run `onInit()` listeners. */
38
38
  async init() {
39
39
  if (!this.database)
40
- throw new base_1.ODSystemError("Unable to initialize stats scopes due to missing database!");
40
+ throw new base_1.ODSystemError("Unable to initialize statistics scopes due to missing database!");
41
41
  //get all valid categories
42
42
  const validCategories = [];
43
43
  for (const scope of this.getAll()) {
44
44
  validCategories.push(...scope.init());
45
45
  }
46
- //filter out the deletable stats
46
+ //filter out the deletable statistics
47
47
  const deletableStats = [];
48
48
  const data = await this.database.getAll();
49
49
  data.forEach((data) => {
@@ -54,14 +54,14 @@ class ODStatsManager extends base_1.ODManager {
54
54
  for (const cb of this.#initListeners) {
55
55
  await cb(data, deletableStats);
56
56
  }
57
- //delete all deletable stats
57
+ //delete all deletable statistics
58
58
  for (const data of deletableStats) {
59
59
  if (!this.database)
60
60
  return;
61
61
  await this.database.delete(data.category, data.key);
62
62
  }
63
63
  }
64
- /**Reset all stats. (clears the entire database) */
64
+ /**Reset all statistics. (clears the entire database) */
65
65
  async reset() {
66
66
  if (!this.database)
67
67
  return;
@@ -72,7 +72,7 @@ class ODStatsManager extends base_1.ODManager {
72
72
  await this.database.delete(d.category, d.key);
73
73
  }
74
74
  }
75
- /**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. */
75
+ /**Run a function when the statistics are initialized. This can be used to clear statistics from users that left the server or tickets which don't exist anymore. */
76
76
  onInit(callback) {
77
77
  this.#initListeners.push(callback);
78
78
  }
@@ -86,21 +86,21 @@ class ODStatsManager extends base_1.ODManager {
86
86
  return super.exists(id);
87
87
  }
88
88
  }
89
- exports.ODStatsManager = ODStatsManager;
90
- /**## ODStatScope `class`
91
- * This is an Open Discord stat scope.
89
+ exports.ODStatisticManager = ODStatisticManager;
90
+ /**## ODStatisticScope `class`
91
+ * This is an Open Discord statistic scope.
92
92
  *
93
- * A scope can contain multiple stats. Every scope is seperated from other scopes.
94
- * Here, you can read & write the values of all stats.
93
+ * A scope can contain multiple statistics. Every scope is seperated from other scopes.
94
+ * Here, you can read & write the values of all statistics.
95
95
  *
96
96
  * The built-in Open Discord scopes are: `global`, `user`, `ticket`
97
97
  */
98
- class ODStatScope extends base_1.ODManager {
98
+ class ODStatisticScope extends base_1.ODManager {
99
99
  /**The id of this statistics scope. */
100
100
  id;
101
- /**Is this stat scope already initialized? */
101
+ /**Is this scope already initialized? */
102
102
  ready = false;
103
- /**Alias to Open Discord stats database. */
103
+ /**Alias to Open Discord statistics database. */
104
104
  database = null;
105
105
  /**The name of this scope (used in embed title) */
106
106
  name;
@@ -109,7 +109,7 @@ class ODStatScope extends base_1.ODManager {
109
109
  this.id = new base_1.ODId(id);
110
110
  this.name = name;
111
111
  }
112
- /**Select the database to use to read/write all stats from/to. (Automatically assigned when used in `ODStatsManager`) */
112
+ /**Select the database to use to read/write all statistics from/to. (Automatically assigned when used in `ODStatisticManager`) */
113
113
  useDatabase(database) {
114
114
  this.database = database;
115
115
  }
@@ -119,7 +119,7 @@ class ODStatScope extends base_1.ODManager {
119
119
  const newId = new base_1.ODId(id);
120
120
  const data = await this.database.get(this.id.value + "_" + newId.value, scopeId);
121
121
  if (typeof data == "undefined") {
122
- //set stats to default value & return
122
+ //set statistics to default value & return
123
123
  return this.resetStat(id, scopeId);
124
124
  }
125
125
  else if (typeof data == "string" || typeof data == "boolean" || typeof data == "number") {
@@ -179,13 +179,13 @@ class ODStatScope extends base_1.ODManager {
179
179
  await this.database.set(this.id.value + "_" + stat.id.value, scopeId, stat.value);
180
180
  return stat.value;
181
181
  }
182
- /**Initialize this stat scope & return a list of all statistic ids in the following format: `<scopeid>_<statid>` */
182
+ /**Initialize this statistic scope & return a list of all statistic ids in the following format: `<scopeid>_<statid>` */
183
183
  init() {
184
- //get all valid stats categories
184
+ //get all valid statistics categories
185
185
  this.ready = true;
186
186
  return this.getAll().map((stat) => this.id.value + "_" + stat.id.value);
187
187
  }
188
- /**Render all stats in this scope for usage in a discord message/embed. */
188
+ /**Render all statistics in this scope for usage in a discord message/embed. */
189
189
  async render(scopeId, guild, channel, user) {
190
190
  //sort from high priority to low
191
191
  const derefArray = [...this.getAll()];
@@ -195,7 +195,7 @@ class ODStatScope extends base_1.ODManager {
195
195
  const result = [];
196
196
  for (const stat of derefArray) {
197
197
  try {
198
- if (stat instanceof ODDynamicStat) {
198
+ if (stat instanceof ODDynamicStatistic) {
199
199
  //dynamic render (without value)
200
200
  result.push(await stat.render("", scopeId, guild, channel, user));
201
201
  }
@@ -222,16 +222,16 @@ class ODStatScope extends base_1.ODManager {
222
222
  return super.exists(id);
223
223
  }
224
224
  }
225
- exports.ODStatScope = ODStatScope;
226
- /**## ODStatGlobalScope `class`
227
- * This is an Open Discord stat global scope.
225
+ exports.ODStatisticScope = ODStatisticScope;
226
+ /**## ODStatisticGlobalScope `class`
227
+ * This is an Open Discord statistic global scope.
228
228
  *
229
- * A scope can contain multiple stats. Every scope is seperated from other scopes.
230
- * Here, you can read & write the values of all stats.
229
+ * A scope can contain multiple statistics. Every scope is seperated from other scopes.
230
+ * Here, you can read & write the values of all statistics.
231
231
  *
232
- * This scope is made specifically for the global stats of Open Discord.
232
+ * This scope is made specifically for the global statistics of Open Discord.
233
233
  */
234
- class ODStatGlobalScope extends ODStatScope {
234
+ class ODStatisticGlobalScope extends ODStatisticScope {
235
235
  getStat(id) {
236
236
  return super.getStat(id, "GLOBAL");
237
237
  }
@@ -248,16 +248,16 @@ class ODStatGlobalScope extends ODStatScope {
248
248
  return super.render("GLOBAL", guild, channel, user);
249
249
  }
250
250
  }
251
- exports.ODStatGlobalScope = ODStatGlobalScope;
252
- /**## ODStat `class`
251
+ exports.ODStatisticGlobalScope = ODStatisticGlobalScope;
252
+ /**## ODStatistic `class`
253
253
  * This is an Open Discord statistic.
254
254
  *
255
255
  * This single statistic doesn't do anything except defining the rules of this statistic.
256
- * Use it in a stats scope to register a new statistic. A statistic can also include a priority to choose the render priority.
256
+ * Use it in a statistics scope to register a new statistic. A statistic can also include a priority to choose the render priority.
257
257
  *
258
- * It's recommended to use the `ODBasicStat` & `ODDynamicStat` classes instead of this one!
258
+ * It's recommended to use the `ODBaseStatistic` & `ODDynamicStatistic` classes instead of this one!
259
259
  */
260
- class ODStat extends base_1.ODManagerData {
260
+ class ODStatistic extends base_1.ODManagerData {
261
261
  /**The priority of this statistic. */
262
262
  priority;
263
263
  /**The render function of this statistic. */
@@ -271,15 +271,15 @@ class ODStat extends base_1.ODManagerData {
271
271
  this.value = value ?? null;
272
272
  }
273
273
  }
274
- exports.ODStat = ODStat;
275
- /**## ODBasicStat `class`
274
+ exports.ODStatistic = ODStatistic;
275
+ /**## ODBaseStatistic `class`
276
276
  * This is an Open Discord basic statistic.
277
277
  *
278
278
  * This single statistic will store a number, boolean or string in the database.
279
- * Use it to create a simple statistic for any stats scope.
279
+ * Use it to create a simple statistic for any statistics scope.
280
280
  */
281
- class ODBasicStat extends ODStat {
282
- /**The name of this stat. Rendered in discord embeds/messages. */
281
+ class ODBaseStatistic extends ODStatistic {
282
+ /**The name of this statistic. Rendered in discord embeds/messages. */
283
283
  name;
284
284
  constructor(id, priority, name, value) {
285
285
  super(id, priority, (value) => {
@@ -288,8 +288,8 @@ class ODBasicStat extends ODStat {
288
288
  this.name = name;
289
289
  }
290
290
  }
291
- exports.ODBasicStat = ODBasicStat;
292
- /**## ODDynamicStat `class`
291
+ exports.ODBaseStatistic = ODBaseStatistic;
292
+ /**## ODDynamicStatistic `class`
293
293
  * This is an Open Discord dynamic statistic.
294
294
  *
295
295
  * A dynamic statistic does not store anything in the database! Instead, it will execute a function to return a custom result.
@@ -297,11 +297,11 @@ exports.ODBasicStat = ODBasicStat;
297
297
  *
298
298
  * This is used in Open Discord for the live ticket status, participants & system status.
299
299
  */
300
- class ODDynamicStat extends ODStat {
300
+ class ODDynamicStatistic extends ODStatistic {
301
301
  constructor(id, priority, render) {
302
302
  super(id, priority, (value, scopeId, guild, channel, user) => {
303
303
  return render(scopeId, guild, channel, user);
304
304
  });
305
305
  }
306
306
  }
307
- exports.ODDynamicStat = ODDynamicStat;
307
+ exports.ODDynamicStatistic = ODDynamicStatistic;
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",
4
+ "version": "0.2.5",
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",
package/src/api/index.ts CHANGED
@@ -20,7 +20,7 @@ export * from "./modules/action"
20
20
  export * from "./modules/permission"
21
21
  export * from "./modules/helpmenu"
22
22
  export * from "./modules/session"
23
- export * from "./modules/stat"
23
+ export * from "./modules/statistic"
24
24
  export * from "./modules/code"
25
25
  export * from "./modules/cooldown"
26
26
  export * from "./modules/post"