@open-discord-bots/framework 0.2.17 → 0.3.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.
Files changed (76) hide show
  1. package/dist/api/index.d.ts +16 -15
  2. package/dist/api/index.js +16 -15
  3. package/dist/api/main.d.ts +31 -23
  4. package/dist/api/main.js +3 -1
  5. package/dist/api/modules/action.d.ts +2 -2
  6. package/dist/api/modules/action.js +1 -5
  7. package/dist/api/modules/base.d.ts +29 -11
  8. package/dist/api/modules/base.js +78 -80
  9. package/dist/api/modules/builder.d.ts +2 -11
  10. package/dist/api/modules/builder.js +0 -4
  11. package/dist/api/modules/checker.d.ts +28 -7
  12. package/dist/api/modules/checker.js +33 -37
  13. package/dist/api/modules/client.d.ts +66 -14
  14. package/dist/api/modules/client.js +146 -132
  15. package/dist/api/modules/component.d.ts +928 -0
  16. package/dist/api/modules/component.js +1346 -0
  17. package/dist/api/modules/config.d.ts +30 -2
  18. package/dist/api/modules/config.js +90 -7
  19. package/dist/api/modules/console.d.ts +16 -4
  20. package/dist/api/modules/console.js +25 -25
  21. package/dist/api/modules/cooldown.d.ts +5 -5
  22. package/dist/api/modules/cooldown.js +1 -17
  23. package/dist/api/modules/database.d.ts +21 -13
  24. package/dist/api/modules/database.js +0 -23
  25. package/dist/api/modules/event.d.ts +4 -2
  26. package/dist/api/modules/event.js +8 -10
  27. package/dist/api/modules/fuse.d.ts +1 -1
  28. package/dist/api/modules/helpmenu.d.ts +11 -9
  29. package/dist/api/modules/helpmenu.js +24 -22
  30. package/dist/api/modules/language.d.ts +4 -3
  31. package/dist/api/modules/language.js +9 -16
  32. package/dist/api/modules/permission.d.ts +10 -1
  33. package/dist/api/modules/permission.js +17 -20
  34. package/dist/api/modules/plugin.d.ts +2 -1
  35. package/dist/api/modules/plugin.js +2 -2
  36. package/dist/api/modules/post.d.ts +12 -4
  37. package/dist/api/modules/post.js +36 -10
  38. package/dist/api/modules/progressbar.d.ts +18 -6
  39. package/dist/api/modules/progressbar.js +35 -35
  40. package/dist/api/modules/responder.d.ts +97 -28
  41. package/dist/api/modules/responder.js +213 -176
  42. package/dist/api/modules/session.d.ts +11 -2
  43. package/dist/api/modules/session.js +16 -16
  44. package/dist/api/modules/startscreen.d.ts +2 -3
  45. package/dist/api/modules/startscreen.js +8 -9
  46. package/dist/api/modules/statistic.d.ts +2 -1
  47. package/dist/api/modules/statistic.js +4 -7
  48. package/dist/api/modules/worker.d.ts +2 -1
  49. package/dist/api/modules/worker.js +3 -3
  50. package/package.json +3 -2
  51. package/src/api/index.ts +16 -15
  52. package/src/api/main.ts +33 -24
  53. package/src/api/modules/action.ts +2 -4
  54. package/src/api/modules/base.ts +77 -79
  55. package/src/api/modules/builder.ts +2 -14
  56. package/src/api/modules/checker.ts +36 -37
  57. package/src/api/modules/client.ts +144 -136
  58. package/src/api/modules/component.ts +1826 -0
  59. package/src/api/modules/config.ts +86 -7
  60. package/src/api/modules/console.ts +25 -25
  61. package/src/api/modules/cooldown.ts +8 -13
  62. package/src/api/modules/database.ts +24 -32
  63. package/src/api/modules/event.ts +6 -10
  64. package/src/api/modules/fuse.ts +1 -1
  65. package/src/api/modules/helpmenu.ts +31 -27
  66. package/src/api/modules/language.ts +11 -16
  67. package/src/api/modules/permission.ts +17 -20
  68. package/src/api/modules/plugin.ts +2 -2
  69. package/src/api/modules/post.ts +31 -10
  70. package/src/api/modules/progressbar.ts +36 -37
  71. package/src/api/modules/responder.ts +234 -185
  72. package/src/api/modules/session.ts +15 -15
  73. package/src/api/modules/startscreen.ts +9 -10
  74. package/src/api/modules/statistic.ts +4 -7
  75. package/src/api/modules/worker.ts +3 -3
  76. package/src/api/modules/component.txt +0 -350
@@ -1,20 +1,16 @@
1
1
  import { ODId, ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
2
2
  import { ODDebugger } from "./console.js";
3
- /**## ODHelpMenuComponentRenderer `type`
4
- * This is the callback of the help menu component renderer. It also contains information about how & where it is rendered.
5
- */
6
- export type ODHelpMenuComponentRenderer = (page: number, category: number, location: number, mode: "slash" | "text") => string | Promise<string>;
7
3
  /**## ODHelpMenuComponent `class`
8
4
  * This is an Open Discord help menu component.
9
5
  *
10
6
  * It can render something on the Open Discord help menu.
11
7
  */
12
- export declare class ODHelpMenuComponent extends ODManagerData {
8
+ export declare abstract class ODHelpMenuComponent extends ODManagerData {
13
9
  /**The priority of this component. The higher, the earlier it will appear in the help menu. */
14
10
  priority: number;
11
+ constructor(id: ODValidId, priority: number);
15
12
  /**The render function for this component. */
16
- render: ODHelpMenuComponentRenderer;
17
- constructor(id: ODValidId, priority: number, render: ODHelpMenuComponentRenderer);
13
+ abstract render(page: number, category: number, location: number, mode: "slash" | "text"): string | Promise<string>;
18
14
  }
19
15
  /**## ODHelpMenuTextComponent `class`
20
16
  * This is an Open Discord help menu text component.
@@ -22,7 +18,10 @@ export declare class ODHelpMenuComponent extends ODManagerData {
22
18
  * It can render a static piece of text on the Open Discord help menu.
23
19
  */
24
20
  export declare class ODHelpMenuTextComponent extends ODHelpMenuComponent {
21
+ /**The text of this help menu component. */
22
+ text: string;
25
23
  constructor(id: ODValidId, priority: number, text: string);
24
+ render(page: number, category: number, location: number, mode: "slash" | "text"): string;
26
25
  }
27
26
  /**## ODHelpMenuCommandComponentOption `interface`
28
27
  * This interface contains a command option for the `ODHelpMenuCommandComponent`.
@@ -56,8 +55,12 @@ export interface ODHelpMenuCommandComponentSettings {
56
55
  * It contains a useful helper to render a command in the Open Discord help menu.
57
56
  */
58
57
  export declare class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
59
- #private;
58
+ /**The settings for this help menu component. */
59
+ settings: ODHelpMenuCommandComponentSettings;
60
60
  constructor(id: ODValidId, priority: number, settings: ODHelpMenuCommandComponentSettings);
61
+ render(page: number, category: number, location: number, mode: "slash" | "text"): string;
62
+ /**Utility function to render all command options. */
63
+ protected renderOptions(options: ODHelpMenuCommandComponentOption[]): string;
61
64
  }
62
65
  /**## ODHelpMenuCategoryIdConstraint `type`
63
66
  * The constraint/layout for id mappings/interfaces of the `ODHelpMenuCategory` class.
@@ -110,7 +113,6 @@ export type ODHelpMenuManagerIdConstraint = Record<string, ODHelpMenuCategory>;
110
113
  * Fewer Categories == More Clean Menu
111
114
  */
112
115
  export declare class ODHelpMenuManager<IdList extends ODHelpMenuManagerIdConstraint = ODHelpMenuManagerIdConstraint> extends ODManager<ODHelpMenuCategory> {
113
- #private;
114
116
  /**The amount of categories per-page. */
115
117
  categoriesPerPage: number;
116
118
  constructor(debug: ODDebugger);
@@ -10,12 +10,9 @@ import { ODId, ODManager, ODManagerData, ODSystemError } from "./base.js";
10
10
  export class ODHelpMenuComponent extends ODManagerData {
11
11
  /**The priority of this component. The higher, the earlier it will appear in the help menu. */
12
12
  priority;
13
- /**The render function for this component. */
14
- render;
15
- constructor(id, priority, render) {
13
+ constructor(id, priority) {
16
14
  super(id);
17
15
  this.priority = priority;
18
- this.render = render;
19
16
  }
20
17
  }
21
18
  /**## ODHelpMenuTextComponent `class`
@@ -24,10 +21,14 @@ export class ODHelpMenuComponent extends ODManagerData {
24
21
  * It can render a static piece of text on the Open Discord help menu.
25
22
  */
26
23
  export class ODHelpMenuTextComponent extends ODHelpMenuComponent {
24
+ /**The text of this help menu component. */
25
+ text;
27
26
  constructor(id, priority, text) {
28
- super(id, priority, () => {
29
- return text;
30
- });
27
+ super(id, priority);
28
+ this.text = text;
29
+ }
30
+ render(page, category, location, mode) {
31
+ return this.text;
31
32
  }
32
33
  }
33
34
  /**## ODHelpMenuCommandComponent `class`
@@ -36,20 +37,24 @@ export class ODHelpMenuTextComponent extends ODHelpMenuComponent {
36
37
  * It contains a useful helper to render a command in the Open Discord help menu.
37
38
  */
38
39
  export class ODHelpMenuCommandComponent extends ODHelpMenuComponent {
40
+ /**The settings for this help menu component. */
41
+ settings;
39
42
  constructor(id, priority, settings) {
40
- super(id, priority, (page, category, location, mode) => {
41
- if (mode == "slash" && settings.slashName) {
42
- return `\`${settings.slashName}${(settings.slashOptions) ? this.#renderOptions(settings.slashOptions) : ""}\` ➜ ${settings.slashDescription ?? ""}`;
43
- }
44
- else if (mode == "text" && settings.textName) {
45
- return `\`${settings.textName}${(settings.textOptions) ? this.#renderOptions(settings.textOptions) : ""}\` ➜ ${settings.textDescription ?? ""}`;
46
- }
47
- else
48
- return "";
49
- });
43
+ super(id, priority);
44
+ this.settings = settings;
45
+ }
46
+ render(page, category, location, mode) {
47
+ if (mode == "slash" && this.settings.slashName) {
48
+ return `\`${this.settings.slashName}${(this.settings.slashOptions) ? this.renderOptions(this.settings.slashOptions) : ""}\` ➜ ${this.settings.slashDescription ?? ""}`;
49
+ }
50
+ else if (mode == "text" && this.settings.textName) {
51
+ return `\`${this.settings.textName}${(this.settings.textOptions) ? this.renderOptions(this.settings.textOptions) : ""}\` ➜ ${this.settings.textDescription ?? ""}`;
52
+ }
53
+ else
54
+ return "";
50
55
  }
51
56
  /**Utility function to render all command options. */
52
- #renderOptions(options) {
57
+ renderOptions(options) {
53
58
  return " " + options.map((opt) => (opt.optional) ? `[${opt.name}]` : `<${opt.name}>`).join(" ");
54
59
  }
55
60
  }
@@ -115,16 +120,13 @@ export class ODHelpMenuCategory extends ODManager {
115
120
  * Fewer Categories == More Clean Menu
116
121
  */
117
122
  export class ODHelpMenuManager extends ODManager {
118
- /**Alias to Open Discord debugger. */
119
- #debug;
120
123
  /**The amount of categories per-page. */
121
124
  categoriesPerPage = 3;
122
125
  constructor(debug) {
123
126
  super(debug, "help menu category");
124
- this.#debug = debug;
125
127
  }
126
128
  add(data, overwrite) {
127
- data.useDebug(this.#debug, "help menu component");
129
+ data.useDebug(this.debug, "help menu component");
128
130
  return super.add(data, overwrite);
129
131
  }
130
132
  /**Render this entire help menu & return a `ODHelpMenuRenderResult`. */
@@ -28,7 +28,6 @@ export type ODLanguageManagerIdConstraint = Record<string, ODLanguage>;
28
28
  * Add new languages using the `ODlanguage` class in your plugin!
29
29
  */
30
30
  export declare class ODLanguageManager<IdList extends ODLanguageManagerIdConstraint = ODLanguageManagerIdConstraint, TranslationIds extends string = string> extends ODManager<ODLanguage> {
31
- #private;
32
31
  /**The currently selected language. */
33
32
  current: ODLanguage | null;
34
33
  /**The currently selected backup language. (used when translation missing in current language) */
@@ -51,6 +50,8 @@ export declare class ODLanguageManager<IdList extends ODLanguageManagerIdConstra
51
50
  /**Get a translation string by JSON location. (e.g. `"checker.system.typeError"`) */
52
51
  getTranslation(id: TranslationIds): string;
53
52
  getTranslation(id: string): string | null;
53
+ /**Get a backup translation string by JSON location. (system only) */
54
+ protected getBackupTranslation(id: string): string | null;
54
55
  /**Get a backup translation string by JSON location and replace `{0}`,`{1}`,`{2}`,... with the provided parameters. */
55
56
  getTranslationWithParams(id: TranslationIds, params: string[]): string;
56
57
  getTranslationWithParams(id: string, params: string[]): string | null;
@@ -71,7 +72,7 @@ export declare class ODLanguageManager<IdList extends ODLanguageManagerIdConstra
71
72
  *
72
73
  * JSON languages should be created using the `ODJsonLanguage` class instead!
73
74
  */
74
- export declare class ODLanguage extends ODManagerData {
75
+ export declare abstract class ODLanguage extends ODManagerData {
75
76
  /**The name of the file with extension. */
76
77
  file: string;
77
78
  /**The path to the file relative to the main directory. */
@@ -82,7 +83,7 @@ export declare class ODLanguage extends ODManagerData {
82
83
  metadata: ODLanguageMetadata | null;
83
84
  constructor(id: ODValidId, data: any);
84
85
  /**Init the language. */
85
- init(): ODPromiseVoid;
86
+ abstract init(): ODPromiseVoid;
86
87
  }
87
88
  /**## ODJsonLanguage `class`
88
89
  * This is an Open Discord JSON language file.
@@ -17,21 +17,18 @@ export class ODLanguageManager extends ODManager {
17
17
  current = null;
18
18
  /**The currently selected backup language. (used when translation missing in current language) */
19
19
  backup = null;
20
- /**An alias to Open Discord debugger. */
21
- #debug;
22
20
  constructor(debug, presets) {
23
21
  super(debug, "language");
24
22
  if (presets)
25
- this.add(new ODLanguage("english", "english.json"));
26
- this.current = presets ? new ODLanguage("english", "english.json") : null;
27
- this.backup = presets ? new ODLanguage("english", "english.json") : null;
28
- this.#debug = debug;
23
+ this.add(new ODJsonLanguage("english", "english.json"));
24
+ this.current = presets ? new ODJsonLanguage("english", "english.json") : null;
25
+ this.backup = presets ? new ODJsonLanguage("english", "english.json") : null;
29
26
  }
30
27
  setCurrentLanguage(id) {
31
28
  this.current = this.get(id);
32
29
  const languageId = this.current?.id.value ?? "<unknown-id>";
33
30
  const languageAutomated = this.current?.metadata?.automated.toString() ?? "<unknown-metadata>";
34
- this.#debug.debug("Selected current language", [
31
+ this.debug?.debug("Selected current language", [
35
32
  { key: "id", value: languageId },
36
33
  { key: "automated", value: languageAutomated },
37
34
  ]);
@@ -44,7 +41,7 @@ export class ODLanguageManager extends ODManager {
44
41
  this.backup = this.get(id);
45
42
  const languageId = this.backup?.id.value ?? "<unknown-id>";
46
43
  const languageAutomated = this.backup?.metadata?.automated.toString() ?? "<unknown-metadata>";
47
- this.#debug.debug("Selected backup language", [
44
+ this.debug?.debug("Selected backup language", [
48
45
  { key: "id", value: languageId },
49
46
  { key: "automated", value: languageAutomated },
50
47
  ]);
@@ -65,7 +62,7 @@ export class ODLanguageManager extends ODManager {
65
62
  }
66
63
  getTranslation(id) {
67
64
  if (!this.current)
68
- return this.#getBackupTranslation(id);
65
+ return this.getBackupTranslation(id);
69
66
  const splitted = id.split(".");
70
67
  let currentObject = this.current.data;
71
68
  let result = false;
@@ -80,10 +77,10 @@ export class ODLanguageManager extends ODManager {
80
77
  if (typeof result == "string")
81
78
  return result;
82
79
  else
83
- return this.#getBackupTranslation(id);
80
+ return this.getBackupTranslation(id);
84
81
  }
85
- /**Get a backup translation string by JSON location. (system only) */
86
- #getBackupTranslation(id) {
82
+ /**Get a backup translation string by JSON location. (system only) */
83
+ getBackupTranslation(id) {
87
84
  if (!this.backup)
88
85
  return null;
89
86
  const splitted = id.split(".");
@@ -155,10 +152,6 @@ export class ODLanguage extends ODManagerData {
155
152
  super(id);
156
153
  this.data = data;
157
154
  }
158
- /**Init the language. */
159
- init() {
160
- //nothing
161
- }
162
155
  }
163
156
  /**## ODJsonLanguage `class`
164
157
  * This is an Open Discord JSON language file.
@@ -108,7 +108,10 @@ export type ODPermissionManagerIdConstraint = Record<string, ODPermission>;
108
108
  * Add new permissions using the `ODPermission` class in your plugin!
109
109
  */
110
110
  export declare class ODPermissionManager<IdList extends ODPermissionManagerIdConstraint = ODPermissionManagerIdConstraint> extends ODManager<ODPermission> {
111
- #private;
111
+ /**The function for calculating permissions in this manager. */
112
+ private calculation;
113
+ /**An alias to the Open Discord client manager. */
114
+ private client;
112
115
  /**The result which is returned when no other permissions match. (`member` by default) */
113
116
  defaultResult: ODPermissionResult;
114
117
  constructor(debug: ODDebugger, client: ODClientManager, useDefaultCalculation?: boolean);
@@ -120,6 +123,12 @@ export declare class ODPermissionManager<IdList extends ODPermissionManagerIdCon
120
123
  getPermissions(user: discord.User, channel?: discord.Channel | null, guild?: discord.Guild | null, settings?: ODPermissionSettings | null): Promise<ODPermissionResult>;
121
124
  /**Simplifies the `ODPermissionResult` returned from `getPermissions()` and returns a boolean to check if the user matches the required permissions. */
122
125
  hasPermissions(minimum: ODPermissionType, data: ODPermissionResult): boolean;
126
+ /**Check for permissions. (default calculation) */
127
+ private defaultCalculation;
128
+ /**Check for global permissions. Result will be compared with the channel perms in `#defaultCalculation()`. */
129
+ private defaultGlobalCalculation;
130
+ /**Check for channel permissions. Result will be compared with the global perms in `#defaultCalculation()`. */
131
+ private defaultChannelCalculation;
123
132
  /**Check the permissions for a certain command of the bot. */
124
133
  checkCommandPerms(permissionMode: string, requiredLevel: ODPermissionType, user: discord.User, member?: discord.GuildMember | null, channel?: discord.Channel | null, guild?: discord.Guild | null, settings?: ODPermissionSettings): Promise<ODPermissionCommandResult>;
125
134
  get<PermissionId extends keyof ODNoGeneric<IdList>>(id: PermissionId): IdList[PermissionId];
@@ -56,12 +56,10 @@ export class ODPermission extends ODManagerData {
56
56
  * Add new permissions using the `ODPermission` class in your plugin!
57
57
  */
58
58
  export class ODPermissionManager extends ODManager {
59
- /**Alias for Open Discord debugger. */
60
- #debug;
61
59
  /**The function for calculating permissions in this manager. */
62
- #calculation;
60
+ calculation;
63
61
  /**An alias to the Open Discord client manager. */
64
- #client;
62
+ client;
65
63
  /**The result which is returned when no other permissions match. (`member` by default) */
66
64
  defaultResult = {
67
65
  level: ODPermissionLevel["member"],
@@ -71,13 +69,12 @@ export class ODPermissionManager extends ODManager {
71
69
  };
72
70
  constructor(debug, client, useDefaultCalculation) {
73
71
  super(debug, "permission");
74
- this.#debug = debug;
75
- this.#calculation = useDefaultCalculation ? this.#defaultCalculation : null;
76
- this.#client = client;
72
+ this.calculation = useDefaultCalculation ? this.defaultCalculation : null;
73
+ this.client = client;
77
74
  }
78
75
  /**Edit the permission calculation function in this manager. */
79
76
  setCalculation(calculation) {
80
- this.#calculation = calculation;
77
+ this.calculation = calculation;
81
78
  }
82
79
  /**Edit the result which is returned when no other permissions match. (`member` by default) */
83
80
  setDefaultResult(result) {
@@ -86,9 +83,9 @@ export class ODPermissionManager extends ODManager {
86
83
  /**Get an `ODPermissionResult` based on a few context factors. Use `hasPermissions()` to simplify the result. */
87
84
  getPermissions(user, channel, guild, settings) {
88
85
  try {
89
- if (!this.#calculation)
86
+ if (!this.calculation)
90
87
  throw new ODSystemError("ODPermissionManager:getPermissions() => missing perms calculation");
91
- return this.#calculation(user, channel, guild, settings);
88
+ return this.calculation(user, channel, guild, settings);
92
89
  }
93
90
  catch (err) {
94
91
  process.emit("uncaughtException", err);
@@ -113,16 +110,16 @@ export class ODPermissionManager extends ODManager {
113
110
  throw new ODSystemError("Invalid minimum permission type at ODPermissionManager.hasPermissions()");
114
111
  }
115
112
  /**Check for permissions. (default calculation) */
116
- async #defaultCalculation(user, channel, guild, settings) {
117
- const globalCalc = await this.#defaultGlobalCalculation(user, channel, guild, settings);
118
- const channelCalc = await this.#defaultChannelCalculation(user, channel, guild, settings);
113
+ async defaultCalculation(user, channel, guild, settings) {
114
+ const globalCalc = await this.defaultGlobalCalculation(user, channel, guild, settings);
115
+ const channelCalc = await this.defaultChannelCalculation(user, channel, guild, settings);
119
116
  if (globalCalc.level > channelCalc.level)
120
117
  return globalCalc;
121
118
  else
122
119
  return channelCalc;
123
120
  }
124
121
  /**Check for global permissions. Result will be compared with the channel perms in `#defaultCalculation()`. */
125
- async #defaultGlobalCalculation(user, channel, guild, settings) {
122
+ async defaultGlobalCalculation(user, channel, guild, settings) {
126
123
  const idRegex = (settings && typeof settings.idRegex != "undefined") ? settings.idRegex : null;
127
124
  const allowGlobalUserScope = (settings && typeof settings.allowGlobalUserScope != "undefined") ? settings.allowGlobalUserScope : true;
128
125
  const allowGlobalRoleScope = (settings && typeof settings.allowGlobalRoleScope != "undefined") ? settings.allowGlobalRoleScope : true;
@@ -152,7 +149,7 @@ export class ODPermissionManager extends ODManager {
152
149
  //check for global role permissions
153
150
  if (allowGlobalRoleScope) {
154
151
  if (guild) {
155
- const member = await this.#client.fetchGuildMember(guild, user.id);
152
+ const member = await this.client.fetchGuildMember(guild, user.id);
156
153
  if (member) {
157
154
  const memberRoles = member.roles.cache.map((role) => role.id);
158
155
  const roles = this.getFiltered((permission) => (!idRegex || (idRegex && idRegex.test(permission.id.value))) && permission.scope == "global-role" && (permission.value instanceof discord.Role) && memberRoles.includes(permission.value.id) && permission.value.guild.id == guild.id);
@@ -182,7 +179,7 @@ export class ODPermissionManager extends ODManager {
182
179
  return { ...this.defaultResult };
183
180
  }
184
181
  /**Check for channel permissions. Result will be compared with the global perms in `#defaultCalculation()`. */
185
- async #defaultChannelCalculation(user, channel, guild, settings) {
182
+ async defaultChannelCalculation(user, channel, guild, settings) {
186
183
  const idRegex = (settings && typeof settings.idRegex != "undefined") ? settings.idRegex : null;
187
184
  const allowChannelUserScope = (settings && typeof settings.allowChannelUserScope != "undefined") ? settings.allowChannelUserScope : true;
188
185
  const allowChannelRoleScope = (settings && typeof settings.allowChannelRoleScope != "undefined") ? settings.allowChannelRoleScope : true;
@@ -212,7 +209,7 @@ export class ODPermissionManager extends ODManager {
212
209
  }
213
210
  //check for channel role permissions
214
211
  if (allowChannelRoleScope) {
215
- const member = await this.#client.fetchGuildMember(guild, user.id);
212
+ const member = await this.client.fetchGuildMember(guild, user.id);
216
213
  if (member) {
217
214
  const memberRoles = member.roles.cache.map((role) => role.id);
218
215
  const roles = this.getFiltered((permission) => (!idRegex || (idRegex && idRegex.test(permission.id.value))) && permission.scope == "channel-role" && permission.channel && (permission.channel.id == channel.id) && (permission.value instanceof discord.Role) && memberRoles.includes(permission.value.id) && permission.value.guild.id == guild.id);
@@ -259,12 +256,12 @@ export class ODPermissionManager extends ODManager {
259
256
  }
260
257
  else {
261
258
  if (!guild || !member) {
262
- this.#debug.debug("ODPermissionManager.checkCommandPerms(): Permission Error, Not in server! (#1)");
259
+ this.debug?.debug("ODPermissionManager.checkCommandPerms(): Permission Error, Not in server! (#1)");
263
260
  return { hasPerms: false, reason: "not-in-server" };
264
261
  }
265
- const role = await this.#client.fetchGuildRole(guild, permissionMode);
262
+ const role = await this.client.fetchGuildRole(guild, permissionMode);
266
263
  if (!role) {
267
- this.#debug.debug("ODPermissionManager.checkCommandPerms(): Permission Error, Not in server! (#2)");
264
+ this.debug?.debug("ODPermissionManager.checkCommandPerms(): Permission Error, Not in server! (#2)");
268
265
  return { hasPerms: false, reason: "not-in-server" };
269
266
  }
270
267
  if (!role.members.has(member.id))
@@ -97,7 +97,6 @@ export interface ODPluginDetails {
97
97
  * Don't re-execute plugins which are already enabled! It might break the bot or plugin.
98
98
  */
99
99
  export declare class ODPlugin extends ODManagerData {
100
- #private;
101
100
  /**The name of the directory of this plugin. (same as id) */
102
101
  dir: string;
103
102
  /**All plugin data found in the `plugin.json` file. */
@@ -123,6 +122,8 @@ export declare class ODPlugin extends ODManagerData {
123
122
  getStartFile(): string;
124
123
  /**Execute this plugin. Returns `false` on crash. */
125
124
  execute(debug: ODDebugger, force?: boolean): Promise<boolean>;
125
+ /**Check if a npm dependency exists. */
126
+ checkDependency(id: string): boolean;
126
127
  /**Get a list of all missing npm dependencies that are required for this plugin. */
127
128
  dependenciesInstalled(): string[];
128
129
  /**Get a list of all missing plugins that are required for this plugin. */
@@ -109,7 +109,7 @@ export class ODPlugin extends ODManagerData {
109
109
  return true;
110
110
  }
111
111
  /**Check if a npm dependency exists. */
112
- #checkDependency(id) {
112
+ checkDependency(id) {
113
113
  try {
114
114
  import.meta.resolve(id);
115
115
  return true;
@@ -122,7 +122,7 @@ export class ODPlugin extends ODManagerData {
122
122
  dependenciesInstalled() {
123
123
  const missing = [];
124
124
  this.data.npmDependencies.forEach((d) => {
125
- if (!this.#checkDependency(d)) {
125
+ if (!this.checkDependency(d)) {
126
126
  missing.push(d);
127
127
  }
128
128
  });
@@ -1,7 +1,9 @@
1
1
  import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
2
- import { ODMessageBuildResult, ODMessageBuildSentResult } from "./builder.js";
2
+ import { ODMessageBuildResult } from "./builder.js";
3
3
  import { ODDebugger } from "./console.js";
4
4
  import * as discord from "discord.js";
5
+ import { ODResponderSendResult } from "./responder.js";
6
+ import { ODMessageComponentBuildResult } from "./component.js";
5
7
  /**## ODPostManagerIdConstraint `type`
6
8
  * The constraint/layout for id mappings/interfaces of the `ODPostManager` class.
7
9
  */
@@ -14,7 +16,8 @@ export type ODPostManagerIdConstraint = Record<string, ODPost<discord.GuildBased
14
16
  * You can use this to get the logs channel of the bot (or some other static channel/category).
15
17
  */
16
18
  export declare class ODPostManager<IdList extends ODPostManagerIdConstraint = ODPostManagerIdConstraint> extends ODManager<ODPost<discord.GuildBasedChannel>> {
17
- #private;
19
+ /**A reference to the main server of the bot */
20
+ protected guild: discord.Guild | null;
18
21
  constructor(debug: ODDebugger);
19
22
  add(data: ODPost<discord.GuildBasedChannel>, overwrite?: boolean): boolean;
20
23
  /**Initialize the post manager & all posts. */
@@ -35,7 +38,8 @@ export declare class ODPostManager<IdList extends ODPostManagerIdConstraint = OD
35
38
  * This class also contains utilities for sending messages via the Open Discord builders.
36
39
  */
37
40
  export declare class ODPost<ChannelType extends discord.GuildBasedChannel> extends ODManagerData {
38
- #private;
41
+ /**A reference to the main server of the bot */
42
+ protected guild: discord.Guild | null;
39
43
  /**Is this post already initialized? */
40
44
  ready: boolean;
41
45
  /**The discord.js channel */
@@ -50,5 +54,9 @@ export declare class ODPost<ChannelType extends discord.GuildBasedChannel> exten
50
54
  /**Initialize the discord.js channel of this post. */
51
55
  init(): Promise<null | undefined>;
52
56
  /**Send a message to this channel using the Open Discord builder system */
53
- send(msg: ODMessageBuildResult): Promise<ODMessageBuildSentResult<true>>;
57
+ send(build: ODMessageBuildResult | ODMessageComponentBuildResult): Promise<ODResponderSendResult<true>>;
58
+ /**Get the final `messageCreateOptions` from a returned build result from builders/components. */
59
+ protected getMessageFromBuildResult(build: ODMessageBuildResult | ODMessageComponentBuildResult, type: "interaction" | "message"): discord.MessageCreateOptions & {
60
+ flags: number[];
61
+ };
54
62
  }
@@ -2,6 +2,7 @@
2
2
  //POST MODULE
3
3
  ///////////////////////////////////////
4
4
  import { ODManager, ODManagerData } from "./base.js";
5
+ import * as discord from "discord.js";
5
6
  /**## ODPostManager `class`
6
7
  * This is an Open Discord post manager.
7
8
  *
@@ -11,18 +12,18 @@ import { ODManager, ODManagerData } from "./base.js";
11
12
  */
12
13
  export class ODPostManager extends ODManager {
13
14
  /**A reference to the main server of the bot */
14
- #guild = null;
15
+ guild = null;
15
16
  constructor(debug) {
16
17
  super(debug, "post");
17
18
  }
18
19
  add(data, overwrite) {
19
- if (this.#guild)
20
- data.useGuild(this.#guild);
20
+ if (this.guild)
21
+ data.useGuild(this.guild);
21
22
  return super.add(data, overwrite);
22
23
  }
23
24
  /**Initialize the post manager & all posts. */
24
25
  async init(guild) {
25
- this.#guild = guild;
26
+ this.guild = guild;
26
27
  for (const post of this.getAll()) {
27
28
  post.useGuild(guild);
28
29
  await post.init();
@@ -48,7 +49,7 @@ export class ODPostManager extends ODManager {
48
49
  */
49
50
  export class ODPost extends ODManagerData {
50
51
  /**A reference to the main server of the bot */
51
- #guild = null;
52
+ guild = null;
52
53
  /**Is this post already initialized? */
53
54
  ready = false;
54
55
  /**The discord.js channel */
@@ -61,7 +62,7 @@ export class ODPost extends ODManagerData {
61
62
  }
62
63
  /**Use a specific guild in this class for fetching the channel*/
63
64
  useGuild(guild) {
64
- this.#guild = guild;
65
+ this.guild = guild;
65
66
  }
66
67
  /**Change the channel id to another channel! */
67
68
  setChannelId(id) {
@@ -71,10 +72,10 @@ export class ODPost extends ODManagerData {
71
72
  async init() {
72
73
  if (this.ready)
73
74
  return;
74
- if (!this.#guild)
75
+ if (!this.guild)
75
76
  return this.channel = null;
76
77
  try {
77
- this.channel = await this.#guild.channels.fetch(this.channelId);
78
+ this.channel = await this.guild.channels.fetch(this.channelId);
78
79
  }
79
80
  catch {
80
81
  this.channel = null;
@@ -82,15 +83,40 @@ export class ODPost extends ODManagerData {
82
83
  this.ready = true;
83
84
  }
84
85
  /**Send a message to this channel using the Open Discord builder system */
85
- async send(msg) {
86
+ async send(build) {
86
87
  if (!this.channel || !this.channel.isTextBased())
87
88
  return { success: false, message: null };
88
89
  try {
89
- const sent = await this.channel.send(msg.message);
90
+ const finalMessage = this.getMessageFromBuildResult(build, "message");
91
+ const sent = await this.channel.send(finalMessage);
90
92
  return { success: true, message: sent };
91
93
  }
92
94
  catch {
93
95
  return { success: false, message: null };
94
96
  }
95
97
  }
98
+ /**Get the final `messageCreateOptions` from a returned build result from builders/components. */
99
+ getMessageFromBuildResult(build, type) {
100
+ const msgFlags = [];
101
+ let msgData;
102
+ if ('message' in build) {
103
+ //USING BUILDERS (deprecated)
104
+ msgData = build.message;
105
+ if (build.ephemeral)
106
+ msgFlags.push(discord.MessageFlags.Ephemeral);
107
+ }
108
+ else {
109
+ //USING COMPONENTS
110
+ msgData = build.msg;
111
+ if (type == "interaction" && build.ephemeral)
112
+ msgFlags.push(discord.MessageFlags.Ephemeral); //disabled with regular messages
113
+ if (build.componentsV2)
114
+ msgFlags.push(discord.MessageFlags.IsComponentsV2);
115
+ if (build.supressEmbeds)
116
+ msgFlags.push(discord.MessageFlags.SuppressEmbeds);
117
+ if (build.supressNotifications)
118
+ msgFlags.push(discord.MessageFlags.SuppressNotifications);
119
+ }
120
+ return Object.assign(msgData, { flags: msgFlags });
121
+ }
96
122
  }
@@ -54,11 +54,12 @@ export type ODProgressBarRenderFunc<Settings extends {}> = (settings: Settings,
54
54
  * There are already a lot of default options available if you just want an easy progress bar!
55
55
  */
56
56
  export declare class ODProgressBarRenderer<Settings extends {}> extends ODManagerData {
57
- #private;
58
57
  settings: Settings;
59
- constructor(id: ODValidId, render: ODProgressBarRenderFunc<Settings>, settings: Settings);
58
+ private renderFunction;
59
+ constructor(id: ODValidId, renderFunction: ODProgressBarRenderFunc<Settings>, settings: Settings);
60
60
  /**Render a progress bar using this renderer. */
61
61
  render(min: number, max: number, value: number, prefix: string | null, suffix: string | null): string;
62
+ /**Create a clone of this progress bar renderer, but with additional settings. */
62
63
  withAdditionalSettings(settings: Partial<Settings>): ODProgressBarRenderer<Settings>;
63
64
  }
64
65
  /**## ODProgressBar `class`
@@ -69,10 +70,13 @@ export declare class ODProgressBarRenderer<Settings extends {}> extends ODManage
69
70
  *
70
71
  * Use other classes as existing templates or create your own progress bar from scratch using this class.
71
72
  */
72
- export declare class ODProgressBar extends ODManagerData {
73
- #private;
73
+ export declare abstract class ODProgressBar extends ODManagerData {
74
74
  /**The renderer of this progress bar. */
75
75
  renderer: ODProgressBarRenderer<{}>;
76
+ /**Is this progress bar currently active? */
77
+ protected active: boolean;
78
+ /**A list of listeners when the progress bar stops. */
79
+ protected stopListeners: Function[];
76
80
  /**The current value of the progress bar. */
77
81
  protected value: number;
78
82
  /**The minimum value of the progress bar. */
@@ -88,6 +92,10 @@ export declare class ODProgressBar extends ODManagerData {
88
92
  /**Enable automatic stopping when reaching `min` or `max`. */
89
93
  autoStop: null | "min" | "max";
90
94
  constructor(id: ODValidId, renderer: ODProgressBarRenderer<{}>, min: number, max: number, value: number, autoStop: null | "min" | "max", prefix: string | null, suffix: string | null);
95
+ /**Parse a value in such a way that it doesn't go below/above the min/max limits. */
96
+ private parseValue;
97
+ /**Render progress bar to the console. */
98
+ private renderStdout;
91
99
  /**Start showing this progress bar in the console. */
92
100
  start(): boolean;
93
101
  /**Update this progress bar while active. (will automatically update the progress bar in the console) */
@@ -102,12 +110,15 @@ export declare class ODProgressBar extends ODManagerData {
102
110
  * You can set a fixed duration (milliseconds) in the constructor.
103
111
  */
104
112
  export declare class ODTimedProgressBar extends ODProgressBar {
105
- #private;
106
113
  /**The time in milliseconds. */
107
114
  time: number;
108
115
  /**The mode of the timer. */
109
116
  mode: "increasing" | "decreasing";
110
117
  constructor(id: ODValidId, renderer: ODProgressBarRenderer<{}>, time: number, mode: "increasing" | "decreasing", prefix: string | null, suffix: string | null);
118
+ /**The timer which is used. */
119
+ private timer;
120
+ /**Run the timed progress bar. */
121
+ private execute;
111
122
  start(): boolean;
112
123
  }
113
124
  /**## ODManualProgressBar `class`
@@ -169,6 +180,7 @@ export interface ODDefaultProgressBarRendererSettings {
169
180
  showBorder: boolean;
170
181
  }
171
182
  export declare class ODDefaultProgressBarRenderer extends ODProgressBarRenderer<ODDefaultProgressBarRendererSettings> {
172
- #private;
173
183
  constructor(id: ODValidId, settings: ODDefaultProgressBarRendererSettings);
184
+ /**Switch between Ansis functions based on the specified color. */
185
+ private switchColorAnsis;
174
186
  }