@open-discord-bots/framework 0.3.0 → 0.3.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 (64) hide show
  1. package/dist/api/main.js +1 -1
  2. package/dist/api/modules/base.d.ts +27 -9
  3. package/dist/api/modules/base.js +78 -80
  4. package/dist/api/modules/builder.d.ts +0 -9
  5. package/dist/api/modules/checker.d.ts +26 -5
  6. package/dist/api/modules/checker.js +31 -31
  7. package/dist/api/modules/client.d.ts +66 -14
  8. package/dist/api/modules/client.js +146 -132
  9. package/dist/api/modules/component.d.ts +8 -2
  10. package/dist/api/modules/component.js +8 -6
  11. package/dist/api/modules/config.d.ts +0 -1
  12. package/dist/api/modules/config.js +9 -7
  13. package/dist/api/modules/console.d.ts +16 -4
  14. package/dist/api/modules/console.js +25 -25
  15. package/dist/api/modules/event.d.ts +4 -2
  16. package/dist/api/modules/event.js +8 -10
  17. package/dist/api/modules/fuse.d.ts +1 -1
  18. package/dist/api/modules/helpmenu.d.ts +2 -2
  19. package/dist/api/modules/helpmenu.js +4 -7
  20. package/dist/api/modules/language.d.ts +2 -1
  21. package/dist/api/modules/language.js +6 -9
  22. package/dist/api/modules/permission.d.ts +10 -1
  23. package/dist/api/modules/permission.js +17 -20
  24. package/dist/api/modules/plugin.d.ts +2 -1
  25. package/dist/api/modules/plugin.js +2 -2
  26. package/dist/api/modules/post.d.ts +12 -4
  27. package/dist/api/modules/post.js +36 -10
  28. package/dist/api/modules/progressbar.d.ts +16 -5
  29. package/dist/api/modules/progressbar.js +34 -34
  30. package/dist/api/modules/responder.d.ts +95 -26
  31. package/dist/api/modules/responder.js +213 -172
  32. package/dist/api/modules/session.d.ts +10 -1
  33. package/dist/api/modules/session.js +15 -15
  34. package/dist/api/modules/startscreen.d.ts +0 -1
  35. package/dist/api/modules/startscreen.js +3 -6
  36. package/dist/api/modules/statistic.d.ts +2 -1
  37. package/dist/api/modules/statistic.js +4 -7
  38. package/dist/api/modules/worker.d.ts +2 -1
  39. package/dist/api/modules/worker.js +3 -3
  40. package/dist/utilities/index.d.ts +7 -0
  41. package/dist/utilities/index.js +27 -0
  42. package/package.json +1 -1
  43. package/src/api/main.ts +1 -1
  44. package/src/api/modules/base.ts +75 -77
  45. package/src/api/modules/builder.ts +0 -10
  46. package/src/api/modules/checker.ts +31 -31
  47. package/src/api/modules/client.ts +144 -136
  48. package/src/api/modules/component.ts +11 -7
  49. package/src/api/modules/config.ts +8 -6
  50. package/src/api/modules/console.ts +25 -25
  51. package/src/api/modules/event.ts +6 -10
  52. package/src/api/modules/fuse.ts +1 -1
  53. package/src/api/modules/helpmenu.ts +4 -7
  54. package/src/api/modules/language.ts +6 -9
  55. package/src/api/modules/permission.ts +17 -20
  56. package/src/api/modules/plugin.ts +2 -2
  57. package/src/api/modules/post.ts +31 -10
  58. package/src/api/modules/progressbar.ts +34 -34
  59. package/src/api/modules/responder.ts +232 -181
  60. package/src/api/modules/session.ts +14 -14
  61. package/src/api/modules/startscreen.ts +3 -6
  62. package/src/api/modules/statistic.ts +4 -7
  63. package/src/api/modules/worker.ts +3 -3
  64. package/src/utilities/index.ts +22 -0
@@ -64,18 +64,10 @@ export type ODNoGeneric<T extends Record<string|number|symbol,any>> = {
64
64
  * You can use this class to assign a unique id when creating configs, databases, languages & more!
65
65
  */
66
66
  export class ODId {
67
- /**The full value of this `ODId` as a `string`. */
68
- #value: string
69
- /**The full value of this `ODId` as a `string`. */
70
- set value(id:string){
71
- this._change(this.#value,id)
72
- this.#value = id
73
- }
74
- get value(){
75
- return this.#value
76
- }
67
+ /**The raw value of this `ODId` as a `string`. */
68
+ private rawValue: string
77
69
  /**The change listener for the parent `ODManager` of this `ODId`. */
78
- #change: ((oldId:string,newId:string) => void)|null = null
70
+ private changeListener: ((oldId:string,newId:string) => void)|null = null
79
71
 
80
72
  constructor(id:ODValidId){
81
73
  if (typeof id != "string" && !(id instanceof ODId)) throw new ODSystemError("Invalid constructor parameter => id:ODValidId")
@@ -91,37 +83,45 @@ export class ODId {
91
83
  }
92
84
  })
93
85
 
94
- if (result.length > 0) this.#value = result.join("")
86
+ if (result.length > 0) this.rawValue = result.join("")
95
87
  else throw new ODSystemError("invalid ID at 'new ODID(id: "+id+")'")
96
88
  }else{
97
89
  //id is ODId
98
- this.#value = id.#value
90
+ this.rawValue = id.rawValue
99
91
  }
100
92
  }
101
93
 
94
+ /**The full value of this `ODId` as a `string`. */
95
+ set value(id:string){
96
+ this._change(this.rawValue,id)
97
+ this.rawValue = id
98
+ }
99
+ get value(){
100
+ return this.rawValue
101
+ }
102
102
  /**Returns a string representation of this id. (same as `this.value`) */
103
103
  toString(){
104
- return this.#value
104
+ return this.rawValue
105
105
  }
106
106
  /**The namespace of the id before `:`. (e.g. `opendiscord` for `opendiscord:autoclose-enabled`) */
107
107
  getNamespace(){
108
- const splitted = this.#value.split(":")
108
+ const splitted = this.rawValue.split(":")
109
109
  if (splitted.length > 1) return splitted[0]
110
110
  else return ""
111
111
  }
112
112
  /**The identifier of the id after `:`. (e.g. `autoclose-enabled` for `opendiscord:autoclose-enabled`) */
113
113
  getIdentifier(){
114
- const splitted = this.#value.split(":")
114
+ const splitted = this.rawValue.split(":")
115
115
  if (splitted.length > 1){
116
116
  splitted.shift()
117
117
  return splitted.join(":")
118
- }else return this.#value
118
+ }else return this.rawValue
119
119
  }
120
120
  /**Trigger an `onChange()` event in the parent `ODManager` of this class. */
121
121
  protected _change(oldId:string,newId:string){
122
- if (this.#change){
122
+ if (this.changeListener){
123
123
  try{
124
- this.#change(oldId,newId)
124
+ this.changeListener(oldId,newId)
125
125
  }catch(err){
126
126
  process.emit("uncaughtException",err)
127
127
  throw new ODSystemError("Failed to execute _change() callback!")
@@ -130,7 +130,7 @@ export class ODId {
130
130
  }
131
131
  /****(❌ SYSTEM ONLY!!)** Set the callback executed when a value inside this class changes. */
132
132
  changed(callback:((oldId:string,newId:string) => void)|null){
133
- this.#change = callback
133
+ this.changeListener = callback
134
134
  }
135
135
  }
136
136
 
@@ -141,13 +141,13 @@ export class ODId {
141
141
  * You can use this class when extending your own `ODManager`
142
142
  */
143
143
  export abstract class ODManagerChangeHelper {
144
- #change: (() => void)|null = null
144
+ private changeListener: (() => void)|null = null
145
145
 
146
146
  /**Trigger an `onChange()` event in the parent `ODManager` of this class. */
147
147
  protected _change(){
148
- if (this.#change){
148
+ if (this.changeListener){
149
149
  try{
150
- this.#change()
150
+ this.changeListener()
151
151
  }catch(err){
152
152
  process.emit("uncaughtException",err)
153
153
  throw new ODSystemError("Failed to execute _change() callback!")
@@ -156,7 +156,7 @@ export abstract class ODManagerChangeHelper {
156
156
  }
157
157
  /****(❌ SYSTEM ONLY!!)** Set the callback executed when a value inside this class changes. */
158
158
  changed(callback:(() => void)|null){
159
- this.#change = callback
159
+ this.changeListener = callback
160
160
  }
161
161
  }
162
162
 
@@ -198,22 +198,22 @@ export type ODManagerAddCallback<DataType extends ODManagerData> = (data:DataTyp
198
198
  */
199
199
  export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHelper {
200
200
  /**Alias to Open Discord debugger. */
201
- #debug?: ODDebugger
201
+ protected debug?: ODDebugger
202
202
  /**The message to send when debugging this manager. */
203
- #debugname?: string
203
+ protected debugname?: string
204
204
  /**The map storing all data classes in this manager. */
205
- #data: Map<string,DataType> = new Map()
205
+ private data: Map<string,DataType> = new Map()
206
206
  /**An array storing all listeners when data is added. */
207
- #addListeners: ODManagerAddCallback<DataType>[] = []
207
+ private addListeners: ODManagerAddCallback<DataType>[] = []
208
208
  /**An array storing all listeners when data has changed. */
209
- #changeListeners: ODManagerCallback<DataType>[] = []
209
+ private changeListeners: ODManagerCallback<DataType>[] = []
210
210
  /**An array storing all listeners when data is removed. */
211
- #removeListeners: ODManagerCallback<DataType>[] = []
211
+ private removeListeners: ODManagerCallback<DataType>[] = []
212
212
 
213
213
  constructor(debug?:ODDebugger, debugname?:string){
214
- super()
215
- this.#debug = debug
216
- this.#debugname = debugname
214
+ super()
215
+ this.debug = debug
216
+ this.debugname = debugname
217
217
  }
218
218
 
219
219
  /**Add data to the manager. The `ODId` in the data class will be used as identifier! You can optionally select to overwrite existing data!*/
@@ -228,22 +228,22 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
228
228
 
229
229
  //add listener for data id change => transfer data within manager
230
230
  data.id.changed((oldId,newId) => {
231
- this.#data.delete(oldId)
232
- this.#data.set(newId,data)
231
+ this.data.delete(oldId)
232
+ this.data.set(newId,data)
233
233
  })
234
234
 
235
235
  //add data
236
236
  let didOverwrite: boolean
237
- if (this.#data.has(data.id.value)){
238
- if (!overwrite) throw new ODSystemError("Id '"+data.id.value+"' already exists in "+this.#debugname+" manager. Use 'overwrite:true' to allow overwriting!")
239
- this.#data.set(data.id.value,data)
237
+ if (this.data.has(data.id.value)){
238
+ if (!overwrite) throw new ODSystemError("Id '"+data.id.value+"' already exists in "+this.debugname+" manager. Use 'overwrite:true' to allow overwriting!")
239
+ this.data.set(data.id.value,data)
240
240
  didOverwrite = true
241
- if (this.#debug) this.#debug.debug("Added new "+this.#debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"true"}])
241
+ if (this.debug) this.debug.debug("Added new "+this.debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"true"}])
242
242
 
243
243
  }else{
244
- this.#data.set(data.id.value,data)
244
+ this.data.set(data.id.value,data)
245
245
  didOverwrite = false
246
- if (this.#debug) this.#debug.debug("Added new "+this.#debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"false"}])
246
+ if (this.debug) this.debug.debug("Added new "+this.debugname+" to manager",[{key:"id",value:data.id.value},{key:"overwrite",value:"false"}])
247
247
 
248
248
  }
249
249
 
@@ -251,7 +251,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
251
251
  data.changed(() => {
252
252
  //notify change in upper-manager (because data in this manager changed)
253
253
  this._change()
254
- this.#changeListeners.forEach((cb) => {
254
+ this.changeListeners.forEach((cb) => {
255
255
  try{
256
256
  cb(data)
257
257
  }catch(err){
@@ -261,7 +261,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
261
261
  })
262
262
 
263
263
  //emit add listeners
264
- this.#addListeners.forEach((cb) => {
264
+ this.addListeners.forEach((cb) => {
265
265
  try{
266
266
  cb(data,didOverwrite)
267
267
  }catch(err){
@@ -277,21 +277,21 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
277
277
  /**Get data that matches the `ODId`. Returns the found data.*/
278
278
  get(id:ODValidId): DataType|null {
279
279
  const newId = new ODId(id)
280
- const data = this.#data.get(newId.value)
280
+ const data = this.data.get(newId.value)
281
281
  if (data) return data
282
282
  else return null
283
283
  }
284
284
  /**Remove data that matches the `ODId`. Returns the removed data. */
285
285
  remove(id:ODValidId): DataType|null {
286
286
  const newId = new ODId(id)
287
- const data = this.#data.get(newId.value)
287
+ const data = this.data.get(newId.value)
288
288
 
289
289
  if (!data){
290
- if (this.#debug) this.#debug.debug("Removed "+this.#debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"false"}])
290
+ if (this.debug) this.debug.debug("Removed "+this.debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"false"}])
291
291
  return null
292
292
  }else{
293
- this.#data.delete(newId.value)
294
- if (this.#debug) this.#debug.debug("Removed "+this.#debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"true"}])
293
+ this.data.delete(newId.value)
294
+ if (this.debug) this.debug.debug("Removed "+this.debugname+" from manager",[{key:"id",value:newId.value},{key:"found",value:"true"}])
295
295
  }
296
296
 
297
297
  //remove all listeners
@@ -299,7 +299,7 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
299
299
  data.changed(null)
300
300
 
301
301
  //emit remove listeners
302
- this.#removeListeners.forEach((cb) => {
302
+ this.removeListeners.forEach((cb) => {
303
303
  try{
304
304
  cb(data)
305
305
  }catch(err){
@@ -315,28 +315,28 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
315
315
  /**Check if data that matches the `ODId` exists. Returns a boolean. */
316
316
  exists(id:ODValidId): boolean {
317
317
  const newId = new ODId(id)
318
- if (this.#data.has(newId.value)) return true
318
+ if (this.data.has(newId.value)) return true
319
319
  else return false
320
320
  }
321
321
  /**Get all data inside this manager*/
322
322
  getAll(): DataType[] {
323
- return Array.from(this.#data.values())
323
+ return Array.from(this.data.values())
324
324
  }
325
325
  /**Get all data that matches inside the filter function*/
326
326
  getFiltered(predicate:(value:DataType, index:number, array:DataType[]) => unknown): DataType[] {
327
- return Array.from(this.#data.values()).filter(predicate)
327
+ return Array.from(this.data.values()).filter(predicate)
328
328
  }
329
329
  /**Get all data where the `ODId` matches the provided RegExp. */
330
330
  getRegex(regex:RegExp): DataType[] {
331
- return Array.from(this.#data.values()).filter((data) => regex.test(data.id.value))
331
+ return Array.from(this.data.values()).filter((data) => regex.test(data.id.value))
332
332
  }
333
333
  /**Get the length/size/amount of the data inside this manager. */
334
334
  getLength(){
335
- return this.#data.size
335
+ return this.data.size
336
336
  }
337
337
  /**Get a list of all the ids inside this manager*/
338
338
  getIds(): ODId[] {
339
- const ids = Array.from(this.#data.keys())
339
+ const ids = Array.from(this.data.keys())
340
340
  return ids.map((id) => new ODId(id))
341
341
  }
342
342
  /**Run an iterator over all data in this manager. This method also supports async-await behaviour!*/
@@ -347,20 +347,20 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
347
347
  }
348
348
  /**Use the Open Discord debugger in this manager for logs*/
349
349
  useDebug(debug?:ODDebugger, debugname?:string){
350
- this.#debug = debug
351
- this.#debugname = debugname
350
+ this.debug = debug
351
+ this.debugname = debugname
352
352
  }
353
353
  /**Listen for when data is added to this manager. */
354
354
  onAdd(callback:ODManagerAddCallback<DataType>){
355
- this.#addListeners.push(callback)
355
+ this.addListeners.push(callback)
356
356
  }
357
357
  /**Listen for when data is changed in this manager. */
358
358
  onChange(callback:ODManagerCallback<DataType>){
359
- this.#changeListeners.push(callback)
359
+ this.changeListeners.push(callback)
360
360
  }
361
361
  /**Listen for when data is removed from this manager. */
362
362
  onRemove(callback:ODManagerCallback<DataType>){
363
- this.#removeListeners.push(callback)
363
+ this.removeListeners.push(callback)
364
364
  }
365
365
  }
366
366
 
@@ -372,14 +372,11 @@ export class ODManager<DataType extends ODManagerData> extends ODManagerChangeHe
372
372
  */
373
373
  export class ODManagerWithSafety<DataType extends ODManagerData> extends ODManager<DataType> {
374
374
  /**The function that creates backup data returned in `getSafe()` when an id is missing in this manager. */
375
- #backupCreator: () => DataType
376
- /** Temporary storage for manager debug name. */
377
- #debugname: string
375
+ protected backupGenerator: () => DataType
378
376
 
379
- constructor(backupCreator:() => DataType, debug?:ODDebugger, debugname?:string){
377
+ constructor(backupGenerator:() => DataType, debug?:ODDebugger, debugname?:string){
380
378
  super(debug,debugname)
381
- this.#backupCreator = backupCreator
382
- this.#debugname = debugname ?? "unknown"
379
+ this.backupGenerator = backupGenerator
383
380
  }
384
381
 
385
382
  /**Get data that matches the `ODId`. Returns the backup data when not found.
@@ -390,8 +387,8 @@ export class ODManagerWithSafety<DataType extends ODManagerData> extends ODManag
390
387
  const newId = new ODId(id)
391
388
  const data = super.get(id)
392
389
  if (!data){
393
- process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+newId.value+"\") => Unknown Id => Used backup data ("+this.#debugname+" manager)"))
394
- return this.#backupCreator()
390
+ process.emit("uncaughtException",new ODSystemError("ODManagerWithSafety:getSafe(\""+newId.value+"\") => Unknown Id => Used backup data ("+this.debugname+" manager)"))
391
+ return this.backupGenerator()
395
392
  }
396
393
  else return data
397
394
  }
@@ -578,19 +575,19 @@ export class ODVersionMigration {
578
575
  /**The version to migrate data to */
579
576
  version: ODVersion
580
577
  /**The migration function */
581
- #func: () => void|Promise<void>
578
+ private migrateFunc: () => void|Promise<void>
582
579
  /**The migration function */
583
- #afterInitFunc: () => void|Promise<void>
580
+ private migrateAfterInitFunc: () => void|Promise<void>
584
581
 
585
- constructor(version:ODVersion,func:() => void|Promise<void>,afterInitFunc:() => void|Promise<void>){
582
+ constructor(version:ODVersion,migrateFunc:() => void|Promise<void>,migrateAfterInitFunc:() => void|Promise<void>){
586
583
  this.version = version
587
- this.#func = func
588
- this.#afterInitFunc = afterInitFunc
584
+ this.migrateFunc = migrateFunc
585
+ this.migrateAfterInitFunc = migrateAfterInitFunc
589
586
  }
590
587
  /**Run this version migration as a plugin. Returns `false` when something goes wrong. */
591
588
  async migrate(): Promise<boolean> {
592
589
  try{
593
- await this.#func()
590
+ await this.migrateFunc()
594
591
  return true
595
592
  }catch(err){
596
593
  process.emit("uncaughtException",err)
@@ -600,7 +597,7 @@ export class ODVersionMigration {
600
597
  /**Run this version migration as a plugin (after other plugins have loaded). Returns `false` when something goes wrong. */
601
598
  async migrateAfterInit(): Promise<boolean> {
602
599
  try{
603
- await this.#afterInitFunc()
600
+ await this.migrateAfterInitFunc()
604
601
  return true
605
602
  }catch(err){
606
603
  process.emit("uncaughtException",err)
@@ -742,7 +739,7 @@ export class ODEnvHelper {
742
739
  if (typeof customEnvPath != "undefined" && typeof customEnvPath != "string") throw new ODSystemError("Invalid constructor parameter => customEnvPath?:string")
743
740
 
744
741
  const path = customEnvPath ? customEnvPath : ".env"
745
- this.dotenv = fs.existsSync(path) ? this.#readDotEnv(fs.readFileSync(path)) : {}
742
+ this.dotenv = fs.existsSync(path) ? this.readDotEnv(fs.readFileSync(path)) : {}
746
743
  this.env = process.env
747
744
  }
748
745
 
@@ -765,7 +762,8 @@ export class ODEnvHelper {
765
762
  //THIS CODE IS COPIED FROM THE DODENV-LIB
766
763
  //Repo: https://github.com/motdotla/dotenv
767
764
  //Source: https://github.com/motdotla/dotenv/blob/master/lib/main.js#L12
768
- #readDotEnv(src:Buffer){
765
+ //All rights go to the original authors of the dotenv library.
766
+ protected readDotEnv(src:Buffer){
769
767
  const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
770
768
  const obj: Record<string,any> = {}
771
769
 
@@ -1295,16 +1295,6 @@ export interface ODMessageBuildResult {
1295
1295
  ephemeral:boolean
1296
1296
  }
1297
1297
 
1298
- /**## ODMessageBuildSentResult `interface`
1299
- * This interface contains the result from a sent built message. This can be used to edit, view & save the message that got created.
1300
- */
1301
- export interface ODMessageBuildSentResult<InGuild extends boolean> {
1302
- /**Did the message get sent successfully? */
1303
- success:boolean,
1304
- /**The message that got sent. */
1305
- message:discord.Message<InGuild>|null
1306
- }
1307
-
1308
1298
  /**## ODMessageInstance `class`
1309
1299
  * This is an Open Discord message instance.
1310
1300
  *
@@ -306,7 +306,7 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
306
306
  const finalFooter = [footerErrorText,footerWarningText,footerSupportText,...this.extraFooterText]
307
307
  const finalTop = [...this.extraTopText]
308
308
  const finalBottom = [bottomCompactInfo,...this.extraBottomText]
309
- const borderLength = this.#getLongestLength([...finalHeader,...finalFooter])
309
+ const borderLength = this.getLongestLength([...finalHeader,...finalFooter])
310
310
 
311
311
  const finalComponents: string[] = []
312
312
 
@@ -314,10 +314,10 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
314
314
  if (!this.disableHeader){
315
315
  finalHeader.forEach((text) => {
316
316
  if (text.length < 1) return
317
- finalComponents.push(this.#createBlockFromText(text,borderLength))
317
+ finalComponents.push(this.createBlockFromText(text,borderLength))
318
318
  })
319
319
  }
320
- finalComponents.push(this.#getHorizontalDivider(borderLength+4))
320
+ finalComponents.push(this.getHorizontalDivider(borderLength+4))
321
321
 
322
322
  //top
323
323
  finalTop.forEach((text) => {
@@ -371,31 +371,31 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
371
371
  })
372
372
 
373
373
  //footer
374
- finalComponents.push(this.#getHorizontalDivider(borderLength+4))
374
+ finalComponents.push(this.getHorizontalDivider(borderLength+4))
375
375
  if (!this.disableFooter){
376
376
  finalFooter.forEach((text) => {
377
377
  if (text.length < 1) return
378
- finalComponents.push(this.#createBlockFromText(text,borderLength))
378
+ finalComponents.push(this.createBlockFromText(text,borderLength))
379
379
  })
380
- finalComponents.push(this.#getHorizontalDivider(borderLength+4))
380
+ finalComponents.push(this.getHorizontalDivider(borderLength+4))
381
381
  }
382
382
 
383
383
  //return all components
384
384
  return finalComponents
385
385
  }
386
386
  /**Get the length of the longest string in the array. */
387
- #getLongestLength(texts:string[]): number {
387
+ private getLongestLength(texts:string[]): number {
388
388
  return Math.max(...texts.map((t) => ansis.strip(t).length))
389
389
  }
390
390
  /**Get a horizontal divider used between different parts of the config checker result. */
391
- #getHorizontalDivider(width:number): string {
391
+ private getHorizontalDivider(width:number): string {
392
392
  if (width > 2) width = width-2
393
393
  else return this.verticalFiller+this.verticalFiller
394
394
  let divider = this.verticalFiller + this.horizontalFiller.repeat(width) + this.verticalFiller
395
395
  return divider
396
396
  }
397
397
  /**Create a block of text with a vertical divider on the left & right side. */
398
- #createBlockFromText(text:string,width:number): string {
398
+ private createBlockFromText(text:string,width:number): string {
399
399
  if (width < 3) return this.verticalFiller+this.verticalFiller
400
400
  let newWidth = width-ansis.strip(text).length+1
401
401
  let final = this.verticalFiller+" "+text+" ".repeat(newWidth)+this.verticalFiller
@@ -413,14 +413,14 @@ export class ODDefaultCheckerRenderer extends ODCheckerRenderer {
413
413
  */
414
414
  export class ODCheckerTranslationRegister<MessageIds extends string = string, OtherIds extends string = string> {
415
415
  /**This is the array that stores all the data. ❌ **(don't edit unless really needed!)***/
416
- #translations: {type:"message"|"other", id:string, translation:string}[] = []
416
+ protected translations: {type:"message"|"other", id:string, translation:string}[] = []
417
417
 
418
418
  /**Get the translation from a config checker message/sentence */
419
419
  get(type:"other", id:OtherIds): string
420
420
  get(type:"message", id:MessageIds): string
421
421
  get(type:"message"|"other", id:string): string|null
422
422
  get(type:"message"|"other", id:string): string|null {
423
- const result = this.#translations.find(d => (d.id == id) && (d.type == type))
423
+ const result = this.translations.find(d => (d.id == id) && (d.type == type))
424
424
  return (result) ? result.translation : null
425
425
  }
426
426
  /**Set the translation for a config checker message/sentence. This function also overwrites existing translations!*/
@@ -428,13 +428,13 @@ export class ODCheckerTranslationRegister<MessageIds extends string = string, Ot
428
428
  set(type:"message", id:MessageIds, translation:string): boolean
429
429
  set(type:"message"|"other", id:string, translation:string): boolean
430
430
  set(type:"message"|"other", id:string, translation:string){
431
- const index = this.#translations.findIndex(d => (d.id == id) && (d.type == type))
431
+ const index = this.translations.findIndex(d => (d.id == id) && (d.type == type))
432
432
  if (index > -1){
433
433
  //overwrite
434
- this.#translations[index] = {type,id,translation}
434
+ this.translations[index] = {type,id,translation}
435
435
  return true
436
436
  }else{
437
- this.#translations.push({type,id,translation})
437
+ this.translations.push({type,id,translation})
438
438
  return false
439
439
  }
440
440
  }
@@ -443,16 +443,16 @@ export class ODCheckerTranslationRegister<MessageIds extends string = string, Ot
443
443
  delete(type:"message", id:MessageIds): boolean
444
444
  delete(type:"message"|"other", id:string): boolean
445
445
  delete(type:"message"|"other", id:string){
446
- const index = this.#translations.findIndex(d => (d.id == id) && (d.type == type))
446
+ const index = this.translations.findIndex(d => (d.id == id) && (d.type == type))
447
447
  if (index > -1){
448
448
  //delete
449
- this.#translations.splice(index,1)
449
+ this.translations.splice(index,1)
450
450
  return true
451
451
  }else return false
452
452
  }
453
453
  /**Get all translations */
454
454
  getAll(){
455
- return this.#translations
455
+ return this.translations
456
456
  }
457
457
  /**Insert the translation params into the text. */
458
458
  insertTranslationParams(text:string, translationParams:string[]){
@@ -611,7 +611,7 @@ export class ODChecker extends ODManagerData {
611
611
  }
612
612
 
613
613
  /**Get a human-readable number string. */
614
- #ordinalNumber(num:number){
614
+ protected ordinalNumber(num:number){
615
615
  const i = Math.abs(Math.round(num))
616
616
  const cent = i % 100
617
617
  if (cent >= 10 && cent <= 20) return i+'th'
@@ -637,7 +637,7 @@ export class ODChecker extends ODManagerData {
637
637
  const final: ODCheckerLocationTrace = []
638
638
  trace.forEach((t) => {
639
639
  if (typeof t == "number"){
640
- final.push(`:(${this.#ordinalNumber(t+1)})`)
640
+ final.push(`:(${this.ordinalNumber(t+1)})`)
641
641
  }else{
642
642
  final.push(`."${t}"`)
643
643
  }
@@ -1122,10 +1122,10 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
1122
1122
  }else if (typeof this.options.length != "undefined" && value.length == this.options.length){
1123
1123
  checker.createMessage("opendiscord:array-length-invalid","error",`This array needs to have a length of ${this.options.length}!`,lt,null,[this.options.length.toString()],this.id,(this.options.docs ?? null))
1124
1124
  return false
1125
- }else if (typeof this.options.allowedTypes != "undefined" && !this.#arrayAllowedTypesCheck(value,this.options.allowedTypes)){
1125
+ }else if (typeof this.options.allowedTypes != "undefined" && !this.arrayAllowedTypesCheck(value,this.options.allowedTypes)){
1126
1126
  checker.createMessage("opendiscord:array-invalid-types","error",`This array can only contain the following types: ${this.options.allowedTypes.join(", ")}!`,lt,null,[this.options.allowedTypes.join(", ").toString()],this.id,(this.options.docs ?? null))
1127
1127
  return false
1128
- }else if (typeof this.options.allowDoubles != "undefined" && !this.options.allowDoubles && this.#arrayHasDoubles(value)){
1128
+ }else if (typeof this.options.allowDoubles != "undefined" && !this.options.allowDoubles && this.arrayHasDoubles(value)){
1129
1129
  checker.createMessage("opendiscord:array-double","error","This array doesn't allow the same value twice!",lt,null,[],this.id,(this.options.docs ?? null))
1130
1130
  return false
1131
1131
  }else{
@@ -1149,7 +1149,7 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
1149
1149
  }
1150
1150
 
1151
1151
  /**Check this array for the allowed types */
1152
- #arrayAllowedTypesCheck(array:any[],allowedTypes:("string"|"number"|"boolean"|"null"|"array"|"object"|"other")[]): boolean {
1152
+ protected arrayAllowedTypesCheck(array:any[],allowedTypes:("string"|"number"|"boolean"|"null"|"array"|"object"|"other")[]): boolean {
1153
1153
  //return TRUE if ALL values are valid
1154
1154
  return !array.some((value) => {
1155
1155
  if (allowedTypes.includes("string") && typeof value == "string"){
@@ -1172,7 +1172,7 @@ export class ODCheckerArrayStructure extends ODCheckerStructure {
1172
1172
  })
1173
1173
  }
1174
1174
  /**Check this array for doubles */
1175
- #arrayHasDoubles(array:any[]): boolean {
1175
+ protected arrayHasDoubles(array:any[]): boolean {
1176
1176
  const alreadyFound: string[] = []
1177
1177
  let hasDoubles = false
1178
1178
  array.forEach((value) => {
@@ -1622,7 +1622,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1622
1622
  if (typeof value != "string") return false
1623
1623
  else if (emptyAllowed && value.length == 0){
1624
1624
  return true
1625
- }else if (!this.#urlIsValid(value)){
1625
+ }else if (!this.urlIsValid(value)){
1626
1626
  checker.createMessage("opendiscord:url-invalid","error","This url is invalid!",lt,null,[],this.id,(this.options.docs ?? null))
1627
1627
  return false
1628
1628
  }else if (typeof this.urlSettings.allowHttp != "undefined" && !this.urlSettings.allowHttp && !/^(https:\/\/)/.test(value)){
@@ -1631,13 +1631,13 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1631
1631
  }else if (!/^(http(s)?:\/\/)/.test(value)){
1632
1632
  checker.createMessage("opendiscord:url-invalid-protocol","error","This url can only use the http:// & https:// protocols!",lt,null,[],this.id,(this.options.docs ?? null))
1633
1633
  return false
1634
- }else if (typeof this.urlSettings.allowedHostnames != "undefined" && !this.#urlHasValidHostname(value,this.urlSettings.allowedHostnames)){
1634
+ }else if (typeof this.urlSettings.allowedHostnames != "undefined" && !this.urlHasValidHostname(value,this.urlSettings.allowedHostnames)){
1635
1635
  checker.createMessage("opendiscord:url-invalid-hostname","error","This url has a disallowed hostname!",lt,null,[],this.id,(this.options.docs ?? null))
1636
1636
  return false
1637
- }else if (typeof this.urlSettings.allowedExtensions != "undefined" && !this.#urlHasValidExtension(value,this.urlSettings.allowedExtensions)){
1637
+ }else if (typeof this.urlSettings.allowedExtensions != "undefined" && !this.urlHasValidExtension(value,this.urlSettings.allowedExtensions)){
1638
1638
  checker.createMessage("opendiscord:url-invalid-extension","error",`This url has an invalid extension! Choose between: ${this.urlSettings.allowedExtensions.join(", ")}!"`,lt,null,[this.urlSettings.allowedExtensions.join(", ")],this.id,(this.options.docs ?? null))
1639
1639
  return false
1640
- }else if (typeof this.urlSettings.allowedPaths != "undefined" && !this.#urlHasValidPath(value,this.urlSettings.allowedPaths)){
1640
+ }else if (typeof this.urlSettings.allowedPaths != "undefined" && !this.urlHasValidPath(value,this.urlSettings.allowedPaths)){
1641
1641
  checker.createMessage("opendiscord:url-invalid-path","error","This url has an invalid path!",lt,null,[],this.id,(this.options.docs ?? null))
1642
1642
  return false
1643
1643
  }else if (typeof this.urlSettings.regex != "undefined" && !this.urlSettings.regex.test(value)){
@@ -1651,7 +1651,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1651
1651
  }
1652
1652
 
1653
1653
  /**Check for the hostname */
1654
- #urlHasValidHostname(url:string,hostnames:(string|RegExp)[]): boolean {
1654
+ protected urlHasValidHostname(url:string,hostnames:(string|RegExp)[]): boolean {
1655
1655
  try {
1656
1656
  const hostname = new URL(url).hostname
1657
1657
  return hostnames.some((rule) => {
@@ -1667,7 +1667,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1667
1667
  }
1668
1668
  }
1669
1669
  /**Check for the extension */
1670
- #urlHasValidExtension(url:string,extensions:string[]): boolean {
1670
+ protected urlHasValidExtension(url:string,extensions:string[]): boolean {
1671
1671
  try {
1672
1672
  const path = new URL(url).pathname
1673
1673
  return extensions.some((rule) => {
@@ -1678,7 +1678,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1678
1678
  }
1679
1679
  }
1680
1680
  /**Check for the path */
1681
- #urlHasValidPath(url:string,paths:(string|RegExp)[]): boolean {
1681
+ protected urlHasValidPath(url:string,paths:(string|RegExp)[]): boolean {
1682
1682
  try {
1683
1683
  const path = new URL(url).pathname
1684
1684
  return paths.some((rule) => {
@@ -1693,7 +1693,7 @@ export class ODCheckerCustomStructure_UrlString extends ODCheckerStringStructure
1693
1693
  }
1694
1694
  }
1695
1695
  /**Do general syntax check on url */
1696
- #urlIsValid(url:string){
1696
+ protected urlIsValid(url:string){
1697
1697
  try {
1698
1698
  new URL(url)
1699
1699
  return true