@somehiddenkey/discord-command-utils 2.0.0 → 2.0.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.
- package/package.json +1 -1
- package/src/Configs/GlobalConfig/GlobalConfigCommunity.js +1 -1
- package/src/Configs/GlobalConfig/GlobalConfigMain.js +5 -5
- package/src/Configs/GlobalConfig/GlobalConfigStaff.js +38 -0
- package/src/Configs/GlobalConfig/GlobalConfigTutor.js +1 -1
- package/src/Configs/NestedGlobalConfig.js +14 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {string} Snowflake
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import ConfigError from "
|
|
5
|
+
import ConfigError from "../ConfigError.js";
|
|
6
6
|
import pkg from 'discord.js';
|
|
7
7
|
import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
|
|
8
8
|
const { GuildBasedChannel } = pkg;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {string} Snowflake
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import ConfigError from "
|
|
5
|
+
import ConfigError from "../ConfigError.js";
|
|
6
6
|
import pkg from 'discord.js';
|
|
7
7
|
import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
|
|
8
8
|
const { GuildBasedChannel } = pkg;
|
|
@@ -22,10 +22,10 @@ export default class Guild extends GuildBased {
|
|
|
22
22
|
throw new ConfigError('No data initialized for GlobalConfig');
|
|
23
23
|
|
|
24
24
|
super(data);
|
|
25
|
-
this.categories = new Categories(data.categories,
|
|
26
|
-
this.channels = new Channels(data.channels,
|
|
27
|
-
this.logs = new Logs(data.logs,
|
|
28
|
-
this.roles = new Roles(data.roles,
|
|
25
|
+
this.categories = new Categories(data.categories, this.guild);
|
|
26
|
+
this.channels = new Channels(data.channels, this.guild);
|
|
27
|
+
this.logs = new Logs(data.logs, this.guild);
|
|
28
|
+
this.roles = new Roles(data.roles, this.guild);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {string} Snowflake
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import ConfigError from "../ConfigError.js";
|
|
6
|
+
import pkg from 'discord.js';
|
|
7
|
+
import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
|
|
8
|
+
const { GuildBasedChannel } = pkg;
|
|
9
|
+
|
|
10
|
+
export default class Guild extends GuildBased {
|
|
11
|
+
/** @type {Categories} */
|
|
12
|
+
categories;
|
|
13
|
+
/** @type {Channels} */
|
|
14
|
+
channels;
|
|
15
|
+
/** @type {Logs} */
|
|
16
|
+
logs;
|
|
17
|
+
/** @type {Roles} */
|
|
18
|
+
roles;
|
|
19
|
+
|
|
20
|
+
constructor(data) {
|
|
21
|
+
if (!data)
|
|
22
|
+
throw new ConfigError('No data initialized for GlobalConfig');
|
|
23
|
+
|
|
24
|
+
super(data);
|
|
25
|
+
this.categories = new Categories(data.categories, data.id);
|
|
26
|
+
this.channels = new Channels(data.channels, data.id);
|
|
27
|
+
this.logs = new Logs(data.logs, data.id);
|
|
28
|
+
this.roles = new Roles(data.roles, data.id);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class Categories extends ChannelBased {}
|
|
33
|
+
|
|
34
|
+
class Channels extends ChannelBased {}
|
|
35
|
+
|
|
36
|
+
class Logs extends ChannelBased {}
|
|
37
|
+
|
|
38
|
+
class Roles extends RoleBased {}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {string} Snowflake
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import ConfigError from "
|
|
5
|
+
import ConfigError from "../ConfigError.js";
|
|
6
6
|
import pkg from 'discord.js';
|
|
7
7
|
import { GuildBased, ChannelBased, RoleBased } from '../NestedGlobalConfig.js';
|
|
8
8
|
const { GuildBasedChannel } = pkg;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import Fetchable from './Fetchable.js';
|
|
6
|
+
import {Guild} from 'discord.js';
|
|
6
7
|
|
|
7
8
|
export class GuildBased extends Fetchable {
|
|
9
|
+
/** @type {Guild} */
|
|
8
10
|
guild;
|
|
9
11
|
categories;
|
|
10
12
|
channels;
|
|
@@ -20,13 +22,17 @@ export class GuildBased extends Fetchable {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
constructor(data){
|
|
23
|
-
this.
|
|
25
|
+
this.guild = this._createLazyObject(data.id);
|
|
24
26
|
this._config_keys = Object.keys(data).filter(k => k !== 'id').push('guild');
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export class ChannelBased extends Fetchable {
|
|
29
|
-
|
|
31
|
+
/** @type {Guild} */
|
|
32
|
+
#guild;
|
|
33
|
+
|
|
34
|
+
constructor(data, guild) {
|
|
35
|
+
this.#guild = guild;
|
|
30
36
|
super(data);
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -35,12 +41,16 @@ export class ChannelBased extends Fetchable {
|
|
|
35
41
|
* @returns {Proxy}
|
|
36
42
|
*/
|
|
37
43
|
_createLazyObject(id) {
|
|
38
|
-
return super._createLazyObject(id, async (id) => await
|
|
44
|
+
return super._createLazyObject(id, async (id) => await this.#guild.fetch().then(guild => guild.channels.fetch(id)));
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
export class RoleBased extends Fetchable {
|
|
49
|
+
/** @type {Guild} */
|
|
50
|
+
#guild;
|
|
51
|
+
|
|
43
52
|
constructor(data) {
|
|
53
|
+
this.#guild = guild;
|
|
44
54
|
super(data);
|
|
45
55
|
}
|
|
46
56
|
|
|
@@ -49,6 +59,6 @@ export class RoleBased extends Fetchable {
|
|
|
49
59
|
* @returns {Proxy}
|
|
50
60
|
*/
|
|
51
61
|
_createLazyObject(id) {
|
|
52
|
-
return super._createLazyObject(id, async (id) => await
|
|
62
|
+
return super._createLazyObject(id, async (id) => await this.#guild.fetch().then(guild => guild.roles.fetch(id)));
|
|
53
63
|
}
|
|
54
64
|
}
|