@somehiddenkey/discord-command-utils 2.2.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.2.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
  */
@@ -31,8 +31,25 @@ export default class GuildCommunity extends GuildBased {
31
31
 
32
32
  class CategoriesCommunity extends ChannelBased {}
33
33
 
34
- class ChannelsCommunity extends ChannelBased {}
34
+ class ChannelsCommunity extends ChannelBased {
35
+ /** @type {GuildBasedChannel} */
36
+ general;
37
+ /** @type {GuildBasedChannel} */
38
+ com_requests;
39
+ /** @type {GuildBasedChannel} */
40
+ managers;
41
+ /** @type {GuildBasedChannel} */
42
+ staff;
43
+ }
35
44
 
36
- class LogsCommunity extends ChannelBased {}
45
+ class LogsCommunity extends ChannelBased {
46
+ /** @type {GuildBasedChannel} */
47
+ communities;
48
+ }
37
49
 
38
- class RolesCommunity extends RoleBased {}
50
+ class RolesCommunity extends RoleBased {
51
+ /** @type {Role} */
52
+ staff;
53
+ /** @type {Role} */
54
+ com_manager;
55
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import ConfigError from "../ConfigError.js";
6
- import pkg from 'discord.js';
6
+ import pkg, { Role } from 'discord.js';
7
7
  import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
8
8
  const { GuildBasedChannel } = pkg;
9
9
 
@@ -114,52 +114,50 @@ class LogsMain extends ChannelBased {
114
114
  invites;
115
115
  /** @type {GuildBasedChannel} */
116
116
  command;
117
- /** @type {GuildBasedChannel} */
118
- communities;
119
117
  }
120
118
 
121
119
  class RolesMain extends RoleBased {
122
- /** @type {Snowflake} */
120
+ /** @type {Role} */
123
121
  cuckoo_ping;
124
- /** @type {Snowflake} */
122
+ /** @type {Role} */
125
123
  developer
126
- /** @type {Snowflake} */
124
+ /** @type {Role} */
127
125
  forest_ping;
128
- /** @type {Snowflake} */
126
+ /** @type {Role} */
129
127
  helper;
130
- /** @type {Snowflake} */
128
+ /** @type {Role} */
131
129
  member;
132
- /** @type {Snowflake} */
130
+ /** @type {Role} */
133
131
  music;
134
- /** @type {Snowflake} */
132
+ /** @type {Role} */
135
133
  muted;
136
- /** @type {Snowflake} */
134
+ /** @type {Role} */
137
135
  no_pc;
138
- /** @type {Snowflake} */
136
+ /** @type {Role} */
139
137
  screen_cam;
140
- /** @type {Snowflake} */
138
+ /** @type {Role} */
141
139
  studying;
142
- /** @type {Snowflake} */
140
+ /** @type {Role} */
143
141
  timer_25;
144
- /** @type {Snowflake} */
142
+ /** @type {Role} */
145
143
  timer_50;
146
- /** @type {Snowflake} */
144
+ /** @type {Role} */
147
145
  tutor;
148
- /** @type {Snowflake} */
146
+ /** @type {Role} */
149
147
  verified_com;
150
- /** @type {Snowflake} */
148
+ /** @type {Role} */
151
149
  water_ping;
152
- /** @type {Snowflake} */
150
+ /** @type {Role} */
153
151
  deepfocus;
154
- /** @type {Snowflake} */
152
+ /** @type {Role} */
155
153
  sr_staff;
156
- /** @type {Snowflake} */
154
+ /** @type {Role} */
157
155
  staff;
158
- /** @type {Snowflake} */
156
+ /** @type {Role} */
159
157
  jr_staff;
160
- /** @type {Snowflake} */
158
+ /** @type {Role} */
161
159
  st_team;
162
- /** @type {Snowflake} */
160
+ /** @type {Role} */
163
161
  coordinator;
164
162
 
165
163
  /** @type {Set<Snowflake>} */
@@ -168,6 +166,6 @@ class RolesMain extends RoleBased {
168
166
 
169
167
  constructor(data, guild) {
170
168
  super(data, guild);
171
- this.all_staff = [this.jr_staff, this.sr_staff, this.st_team, this.coordinator];
169
+ this.all_staff = new Set([data.jr_staff, data.sr_staff, data.st_team, data.coordinator]);
172
170
  }
173
171
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import ConfigError from "../ConfigError.js";
6
- import pkg from 'discord.js';
6
+ import pkg, {Role} from 'discord.js';
7
7
  import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
8
8
  const { GuildBasedChannel } = pkg;
9
9
 
@@ -29,10 +29,42 @@ export default class GuildStaff extends GuildBased {
29
29
  }
30
30
  }
31
31
 
32
- class CategoriesStaff extends ChannelBased {}
33
-
34
- class ChannelsStaff extends ChannelBased {}
32
+ class CategoriesStaff extends ChannelBased {
33
+ /** @type {GuildBasedChannel} */
34
+ modmail;
35
+ }
35
36
 
37
+ class ChannelsStaff extends ChannelBased {
38
+ /** @type {GuildBasedChannel} */
39
+ staff;
40
+ /** @type {GuildBasedChannel} */
41
+ sr_staff;
42
+ /** @type {GuildBasedChannel} */
43
+ developer;
44
+ /** @type {GuildBasedChannel} */
45
+ commands;
46
+ }
36
47
  class LogsStaff extends ChannelBased {}
37
48
 
38
- class RolesStaff extends RoleBased {}
49
+ class RolesStaff extends RoleBased {
50
+ /** @type {Role} */
51
+ int_coordinator;
52
+ /** @type {Role} */
53
+ ext_coordinator;
54
+ /** @type {Role} */
55
+ modmail_access;
56
+ /** @type {Role} */
57
+ sr_staff;
58
+ /** @type {Role} */
59
+ staff;
60
+ /** @type {Role} */
61
+ jr_staff;
62
+ /** @type {Role} */
63
+ developer;
64
+ /** @type {Role} */
65
+ sr_developer;
66
+ /** @type {Role} */
67
+ helper;
68
+ /** @type {Role} */
69
+ events;
70
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import ConfigError from "../ConfigError.js";
6
- import pkg from 'discord.js';
6
+ import pkg, {Role} from 'discord.js';
7
7
  import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
8
8
  const { GuildBasedChannel } = pkg;
9
9
 
@@ -29,10 +29,31 @@ export default class GuildTutor extends GuildBased {
29
29
  }
30
30
  }
31
31
 
32
- class CategoriesTutor extends ChannelBased {}
32
+ class CategoriesTutor extends ChannelBased {
33
+ /** @type {GuildBasedChannel} */
34
+ staff;
35
+ }
33
36
 
34
- class ChannelsTutor extends ChannelBased {}
37
+ class ChannelsTutor extends ChannelBased {
38
+ /** @type {GuildBasedChannel} */
39
+ general;
40
+ /** @type {GuildBasedChannel} */
41
+ commands;
42
+ /** @type {GuildBasedChannel} */
43
+ staff_commands;
44
+ /** @type {GuildBasedChannel} */
45
+ applications;
46
+ }
35
47
 
36
48
  class LogsTutor extends ChannelBased {}
37
49
 
38
- class RolesTutor extends RoleBased {}
50
+ class RolesTutor extends RoleBased {
51
+ /** @type {Role} */
52
+ staff;
53
+ /** @type {Role} */
54
+ dev;
55
+ /** @type {Role} */
56
+ tutor;
57
+ /** @type {Role} */
58
+ sr_tutor;
59
+ }
@@ -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
  }