@somehiddenkey/discord-command-utils 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somehiddenkey/discord-command-utils",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "A utility library for building Discord bot commands using discord.js",
5
5
  "author": {
6
6
  "email": "k3y.throwaway@gmail.com",
@@ -1,6 +1,10 @@
1
1
  export default class ConfigError extends Error {
2
- constructor(message) {
3
- super(message);
2
+ constructor(message, cause) {
3
+ if (cause) {
4
+ super(message, { cause });
5
+ } else {
6
+ super(message);
7
+ }
4
8
  this.name = "ConfigError";
5
9
  }
6
10
  }
@@ -10,6 +10,7 @@ import GuildTutor from './GlobalConfigTutor.js';
10
10
  import GuildStaff from './GlobalConfigStaff.js';
11
11
  import { GuildBased } from '../NestedGlobalConfig.js';
12
12
  import { Client } from 'discord.js';
13
+ import ConfigError from '../ConfigError.js';
13
14
 
14
15
  export default class GlobalConfig {
15
16
  /** @type {GuildMain} */
@@ -27,18 +28,20 @@ export default class GlobalConfig {
27
28
  * @param {Client} bot
28
29
  * @returns {GlobalConfig}
29
30
  */
30
- static async load(path, bot) {
31
+ static load(path, bot) {
31
32
  var json;
32
33
  try {
33
34
  const raw = fs.readFileSync(path, { encoding: 'utf8', flag: 'r' });
34
35
  json = JSON.parse(raw);
35
- return new GlobalConfig(json.guilds, bot);
36
+ const g = new GlobalConfig(json.guilds, bot);
37
+ consola.start(`Loaded GlobalConfig from path: ${path}`);
38
+ return g;
36
39
  } catch (error) {
37
40
  throw new ConfigError(`Failed to load GlobalConfig from path: ${path}`, error);
38
41
  }
39
42
  }
40
43
 
41
- /**
44
+ /**
42
45
  * @param {Snowflake} guild_id
43
46
  * @returns {InteractionScope} scope
44
47
  */
@@ -35,7 +35,7 @@ export default class LocalConfig {
35
35
  * @param {string} path
36
36
  * @returns {LocalConfig}
37
37
  */
38
- static async load(path) {
38
+ static load(path) {
39
39
  var json
40
40
  try {
41
41
  const raw = fs.readFileSync(path, { encoding: 'utf8', flag: 'r' });
@@ -40,12 +40,12 @@ export default class SecretConfig {
40
40
  }
41
41
 
42
42
  databaseConfigs.push(db_config);
43
- consola.start(`Loaded database config for section: ${section}`);
44
43
  } catch (error) {
45
44
  consola.error(`Failed to load database config for section: ${section}`, error);
46
45
  throw error;
47
46
  }
48
47
  }
49
48
  this.databaseConfig = databaseConfigs;
49
+ consola.start(`Loaded SecretConfig for environment: ${this.environment}`);
50
50
  }
51
51
  }