reciple 6.0.0-dev.18 → 6.0.0-dev.19
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/LICENSE +674 -674
- package/README.md +183 -183
- package/dist/lib/bin.mjs +65 -66
- package/dist/lib/esm.mjs +1 -1
- package/dist/lib/index.js +35 -35
- package/dist/lib/reciple/classes/RecipleClient.js +296 -300
- package/dist/lib/reciple/classes/RecipleConfig.js +106 -106
- package/dist/lib/reciple/classes/RecipleModule.js +94 -94
- package/dist/lib/reciple/classes/builders/MessageCommandBuilder.js +242 -242
- package/dist/lib/reciple/classes/builders/MessageCommandOptionBuilder.js +85 -85
- package/dist/lib/reciple/classes/builders/SlashCommandBuilder.js +216 -216
- package/dist/lib/reciple/classes/managers/ApplicationCommandManager.js +172 -172
- package/dist/lib/reciple/classes/managers/ClientCommandManager.js +62 -62
- package/dist/lib/reciple/classes/managers/ClientModuleManager.js +183 -183
- package/dist/lib/reciple/classes/managers/CommandCooldownManager.js +100 -100
- package/dist/lib/reciple/classes/managers/MessageCommandOptionManager.js +25 -25
- package/dist/lib/reciple/flags.js +31 -31
- package/dist/lib/reciple/permissions.js +30 -30
- package/dist/lib/reciple/types/builders.js +11 -11
- package/dist/lib/reciple/types/commands.js +15 -15
- package/dist/lib/reciple/types/paramOptions.js +2 -2
- package/dist/lib/reciple/util.js +68 -66
- package/dist/lib/reciple/version.js +47 -47
- package/dist/types/bin.d.mts +2 -2
- package/dist/types/esm.d.mts +1 -1
- package/dist/types/index.d.ts +19 -19
- package/dist/types/reciple/classes/RecipleClient.d.ts +103 -103
- package/dist/types/reciple/classes/RecipleConfig.d.ts +100 -100
- package/dist/types/reciple/classes/RecipleModule.d.ts +56 -56
- package/dist/types/reciple/classes/builders/MessageCommandBuilder.d.ts +150 -150
- package/dist/types/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +43 -43
- package/dist/types/reciple/classes/builders/SlashCommandBuilder.d.ts +88 -88
- package/dist/types/reciple/classes/managers/ApplicationCommandManager.d.ts +51 -51
- package/dist/types/reciple/classes/managers/ClientCommandManager.d.ts +37 -37
- package/dist/types/reciple/classes/managers/ClientModuleManager.d.ts +49 -49
- package/dist/types/reciple/classes/managers/CommandCooldownManager.d.ts +70 -70
- package/dist/types/reciple/classes/managers/MessageCommandOptionManager.d.ts +22 -22
- package/dist/types/reciple/flags.d.ts +17 -17
- package/dist/types/reciple/permissions.d.ts +19 -19
- package/dist/types/reciple/types/builders.d.ts +197 -197
- package/dist/types/reciple/types/commands.d.ts +81 -81
- package/dist/types/reciple/types/paramOptions.d.ts +101 -101
- package/dist/types/reciple/util.d.ts +23 -20
- package/dist/types/reciple/version.d.ts +25 -25
- package/package.json +1 -1
- package/resource/reciple.yml +120 -120
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationCommandManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
|
|
6
|
-
class ApplicationCommandManager {
|
|
7
|
-
constructor(client) {
|
|
8
|
-
this.client = client;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sets application commands globally or in guilds
|
|
12
|
-
* @param commands Application commands
|
|
13
|
-
* @param guilds set only to guilds
|
|
14
|
-
*/
|
|
15
|
-
async set(commands, ...guilds) {
|
|
16
|
-
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
17
|
-
if (!this.client.isReady())
|
|
18
|
-
throw new Error('Client is not ready');
|
|
19
|
-
if (guilds && guilds.length > 1) {
|
|
20
|
-
for (const guild of guilds) {
|
|
21
|
-
await this.set(commands, guild);
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
let guild = guilds?.shift();
|
|
26
|
-
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
27
|
-
if (!guild) {
|
|
28
|
-
await this.client.application.commands.set(commands);
|
|
29
|
-
if (!this.client.isClientLogsSilent)
|
|
30
|
-
this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) globally...`);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
await this.client.application.commands.set(commands, guild);
|
|
34
|
-
if (!this.client.isClientLogsSilent)
|
|
35
|
-
this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) to guild ${guild}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Add command globally or in guilds
|
|
40
|
-
* @param command Application command
|
|
41
|
-
* @param guilds add only in guilds
|
|
42
|
-
*/
|
|
43
|
-
async add(command, ...guilds) {
|
|
44
|
-
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
45
|
-
if (!this.client.isReady())
|
|
46
|
-
throw new Error('Client is not ready');
|
|
47
|
-
if (!command)
|
|
48
|
-
throw new Error('Command is undefined');
|
|
49
|
-
if (guilds && guilds.length > 1) {
|
|
50
|
-
for (const guild of guilds) {
|
|
51
|
-
await this.add(command, guild);
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
let guild = guilds?.shift();
|
|
56
|
-
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
57
|
-
if (!guild) {
|
|
58
|
-
await this.client.application.commands.create(command);
|
|
59
|
-
if (!this.client.isClientLogsSilent)
|
|
60
|
-
this.client.logger.log(`Created application command '${command.name}' globally`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
await this.client.application.commands.create(command, guild);
|
|
64
|
-
if (!this.client.isClientLogsSilent)
|
|
65
|
-
this.client.logger.log(`Created application command '${command.name}' to guild ${guild}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Remove application command globally or in guilds
|
|
70
|
-
* @param command id of application commmand or ApplicationCommand class
|
|
71
|
-
* @param guilds Remove from guilds
|
|
72
|
-
*/
|
|
73
|
-
async remove(command, ...guilds) {
|
|
74
|
-
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
75
|
-
if (!this.client.isReady())
|
|
76
|
-
throw new Error('Client is not ready');
|
|
77
|
-
if (!command)
|
|
78
|
-
throw new Error('Command is undefined');
|
|
79
|
-
if (guilds && guilds.length > 1) {
|
|
80
|
-
for (const guild of guilds) {
|
|
81
|
-
await this.remove(command, guild);
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
let guild = guilds?.shift();
|
|
86
|
-
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
87
|
-
if (!guild) {
|
|
88
|
-
await this.client.application.commands.delete(command);
|
|
89
|
-
if (!this.client.isClientLogsSilent)
|
|
90
|
-
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
await this.client.application.commands.delete(command, guild);
|
|
94
|
-
if (!this.client.isClientLogsSilent)
|
|
95
|
-
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Edit application command globally or in guilds
|
|
100
|
-
* @param command id of application command or ApplicationCommand class
|
|
101
|
-
* @param newCommand new application command data
|
|
102
|
-
* @param guilds Edit only from guilds
|
|
103
|
-
*/
|
|
104
|
-
async edit(command, newCommand, ...guilds) {
|
|
105
|
-
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
106
|
-
if (!this.client.isReady())
|
|
107
|
-
throw new Error('Client is not ready');
|
|
108
|
-
if (!command)
|
|
109
|
-
throw new Error('Command is undefined');
|
|
110
|
-
if (guilds && guilds.length > 1) {
|
|
111
|
-
for (const guild of guilds) {
|
|
112
|
-
await this.edit(command, newCommand, guild);
|
|
113
|
-
}
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
let guild = guilds?.shift();
|
|
117
|
-
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
118
|
-
if (!guild) {
|
|
119
|
-
await this.client.application.commands.edit(command, newCommand);
|
|
120
|
-
if (!this.client.isClientLogsSilent)
|
|
121
|
-
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
await this.client.application.commands.edit(command, newCommand, guild);
|
|
125
|
-
if (!this.client.isClientLogsSilent)
|
|
126
|
-
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get application command from cache by application command data, builder, id, or name globally or from guid
|
|
131
|
-
* @param command application command data, builder, id, or name
|
|
132
|
-
* @param guild get command from guild
|
|
133
|
-
*/
|
|
134
|
-
get(command, guild) {
|
|
135
|
-
const commands = guild ? this.client.guilds.resolve(guild)?.commands.cache : this.client.application?.commands.cache;
|
|
136
|
-
if (!commands)
|
|
137
|
-
throw new Error('Guild not found in cache');
|
|
138
|
-
return commands.find(cmd => (typeof command === 'string' ? cmd.id === command || cmd.name === command : cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id)));
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Fetch application command by id globally or from guild
|
|
142
|
-
* @param commandId command id
|
|
143
|
-
* @param guild fetch from guild
|
|
144
|
-
*/
|
|
145
|
-
async fetch(commandId, guild) {
|
|
146
|
-
const manager = guild ? this.client.guilds.resolve(guild)?.commands : this.client.application?.commands;
|
|
147
|
-
if (!manager)
|
|
148
|
-
throw new Error('Guild not found in cache');
|
|
149
|
-
return manager.fetch(commandId);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Parse application command builders to command data
|
|
153
|
-
* @param commands Application command builders
|
|
154
|
-
* @param setPermissions set slash commands permissions
|
|
155
|
-
*/
|
|
156
|
-
parseCommands(commands, setPermissions = true) {
|
|
157
|
-
return commands.map(cmd => {
|
|
158
|
-
if (cmd?.toJSON === undefined)
|
|
159
|
-
return cmd;
|
|
160
|
-
if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && this.client.config.commands.slashCommand.setRequiredPermissions) {
|
|
161
|
-
const permissions = setPermissions || this.client.config.commands.slashCommand.permissions.enabled ? this.client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions : undefined;
|
|
162
|
-
if (permissions) {
|
|
163
|
-
cmd.setRequiredMemberPermissions(...permissions);
|
|
164
|
-
if (!this.client.isClientLogsSilent)
|
|
165
|
-
this.client.logger.debug(`Set required permissions for ${cmd.name}`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return cmd.toJSON();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.ApplicationCommandManager = ApplicationCommandManager;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationCommandManager = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
|
|
6
|
+
class ApplicationCommandManager {
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets application commands globally or in guilds
|
|
12
|
+
* @param commands Application commands
|
|
13
|
+
* @param guilds set only to guilds
|
|
14
|
+
*/
|
|
15
|
+
async set(commands, ...guilds) {
|
|
16
|
+
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
17
|
+
if (!this.client.isReady())
|
|
18
|
+
throw new Error('Client is not ready');
|
|
19
|
+
if (guilds && guilds.length > 1) {
|
|
20
|
+
for (const guild of guilds) {
|
|
21
|
+
await this.set(commands, guild);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let guild = guilds?.shift();
|
|
26
|
+
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
27
|
+
if (!guild) {
|
|
28
|
+
await this.client.application.commands.set(commands);
|
|
29
|
+
if (!this.client.isClientLogsSilent)
|
|
30
|
+
this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) globally...`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
await this.client.application.commands.set(commands, guild);
|
|
34
|
+
if (!this.client.isClientLogsSilent)
|
|
35
|
+
this.client.logger.log(`Registered ${this.client.commands.applicationCommandsSize} application command(s) to guild ${guild}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Add command globally or in guilds
|
|
40
|
+
* @param command Application command
|
|
41
|
+
* @param guilds add only in guilds
|
|
42
|
+
*/
|
|
43
|
+
async add(command, ...guilds) {
|
|
44
|
+
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
45
|
+
if (!this.client.isReady())
|
|
46
|
+
throw new Error('Client is not ready');
|
|
47
|
+
if (!command)
|
|
48
|
+
throw new Error('Command is undefined');
|
|
49
|
+
if (guilds && guilds.length > 1) {
|
|
50
|
+
for (const guild of guilds) {
|
|
51
|
+
await this.add(command, guild);
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let guild = guilds?.shift();
|
|
56
|
+
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
57
|
+
if (!guild) {
|
|
58
|
+
await this.client.application.commands.create(command);
|
|
59
|
+
if (!this.client.isClientLogsSilent)
|
|
60
|
+
this.client.logger.log(`Created application command '${command.name}' globally`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await this.client.application.commands.create(command, guild);
|
|
64
|
+
if (!this.client.isClientLogsSilent)
|
|
65
|
+
this.client.logger.log(`Created application command '${command.name}' to guild ${guild}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove application command globally or in guilds
|
|
70
|
+
* @param command id of application commmand or ApplicationCommand class
|
|
71
|
+
* @param guilds Remove from guilds
|
|
72
|
+
*/
|
|
73
|
+
async remove(command, ...guilds) {
|
|
74
|
+
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
75
|
+
if (!this.client.isReady())
|
|
76
|
+
throw new Error('Client is not ready');
|
|
77
|
+
if (!command)
|
|
78
|
+
throw new Error('Command is undefined');
|
|
79
|
+
if (guilds && guilds.length > 1) {
|
|
80
|
+
for (const guild of guilds) {
|
|
81
|
+
await this.remove(command, guild);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
let guild = guilds?.shift();
|
|
86
|
+
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
87
|
+
if (!guild) {
|
|
88
|
+
await this.client.application.commands.delete(command);
|
|
89
|
+
if (!this.client.isClientLogsSilent)
|
|
90
|
+
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
await this.client.application.commands.delete(command, guild);
|
|
94
|
+
if (!this.client.isClientLogsSilent)
|
|
95
|
+
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Edit application command globally or in guilds
|
|
100
|
+
* @param command id of application command or ApplicationCommand class
|
|
101
|
+
* @param newCommand new application command data
|
|
102
|
+
* @param guilds Edit only from guilds
|
|
103
|
+
*/
|
|
104
|
+
async edit(command, newCommand, ...guilds) {
|
|
105
|
+
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
106
|
+
if (!this.client.isReady())
|
|
107
|
+
throw new Error('Client is not ready');
|
|
108
|
+
if (!command)
|
|
109
|
+
throw new Error('Command is undefined');
|
|
110
|
+
if (guilds && guilds.length > 1) {
|
|
111
|
+
for (const guild of guilds) {
|
|
112
|
+
await this.edit(command, newCommand, guild);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
let guild = guilds?.shift();
|
|
117
|
+
guild = guild ? this.client.guilds.resolveId(guild) || undefined : undefined;
|
|
118
|
+
if (!guild) {
|
|
119
|
+
await this.client.application.commands.edit(command, newCommand);
|
|
120
|
+
if (!this.client.isClientLogsSilent)
|
|
121
|
+
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' globally`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
await this.client.application.commands.edit(command, newCommand, guild);
|
|
125
|
+
if (!this.client.isClientLogsSilent)
|
|
126
|
+
this.client.logger.log(`Removed application command '${typeof command === 'string' ? command : command.name}' from guild ${guild}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get application command from cache by application command data, builder, id, or name globally or from guid
|
|
131
|
+
* @param command application command data, builder, id, or name
|
|
132
|
+
* @param guild get command from guild
|
|
133
|
+
*/
|
|
134
|
+
get(command, guild) {
|
|
135
|
+
const commands = guild ? this.client.guilds.resolve(guild)?.commands.cache : this.client.application?.commands.cache;
|
|
136
|
+
if (!commands)
|
|
137
|
+
throw new Error('Guild not found in cache');
|
|
138
|
+
return commands.find(cmd => (typeof command === 'string' ? cmd.id === command || cmd.name === command : cmd.name === command.name || (command instanceof discord_js_1.ApplicationCommand && cmd.id === command.id)));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Fetch application command by id globally or from guild
|
|
142
|
+
* @param commandId command id
|
|
143
|
+
* @param guild fetch from guild
|
|
144
|
+
*/
|
|
145
|
+
async fetch(commandId, guild) {
|
|
146
|
+
const manager = guild ? this.client.guilds.resolve(guild)?.commands : this.client.application?.commands;
|
|
147
|
+
if (!manager)
|
|
148
|
+
throw new Error('Guild not found in cache');
|
|
149
|
+
return manager.fetch(commandId);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Parse application command builders to command data
|
|
153
|
+
* @param commands Application command builders
|
|
154
|
+
* @param setPermissions set slash commands permissions
|
|
155
|
+
*/
|
|
156
|
+
parseCommands(commands, setPermissions = true) {
|
|
157
|
+
return commands.map(cmd => {
|
|
158
|
+
if (cmd?.toJSON === undefined)
|
|
159
|
+
return cmd;
|
|
160
|
+
if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && this.client.config.commands.slashCommand.setRequiredPermissions) {
|
|
161
|
+
const permissions = setPermissions || this.client.config.commands.slashCommand.permissions.enabled ? this.client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions : undefined;
|
|
162
|
+
if (permissions) {
|
|
163
|
+
cmd.setRequiredMemberPermissions(...permissions);
|
|
164
|
+
if (!this.client.isClientLogsSilent)
|
|
165
|
+
this.client.logger.debug(`Set required permissions for ${cmd.name}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return cmd.toJSON();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.ApplicationCommandManager = ApplicationCommandManager;
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientCommandManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const builders_1 = require("../../types/builders");
|
|
6
|
-
const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
|
|
7
|
-
const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
|
|
8
|
-
class ClientCommandManager {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.slashCommands = new discord_js_1.Collection();
|
|
11
|
-
this.messageCommands = new discord_js_1.Collection();
|
|
12
|
-
this.additionalApplicationCommands = [];
|
|
13
|
-
this.client = options.client;
|
|
14
|
-
options.slashCommands?.forEach(e => this.slashCommands.set(e.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(e)));
|
|
15
|
-
options.messageCommands?.forEach(e => this.messageCommands.set(e.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(e)));
|
|
16
|
-
}
|
|
17
|
-
get applicationCommandsSize() {
|
|
18
|
-
return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Add command to command manager
|
|
22
|
-
* @param commands Any command data or builder
|
|
23
|
-
*/
|
|
24
|
-
add(...commands) {
|
|
25
|
-
for (const command of (0, discord_js_1.normalizeArray)(commands)) {
|
|
26
|
-
if (command.type === builders_1.CommandType.SlashCommand) {
|
|
27
|
-
this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
|
|
28
|
-
}
|
|
29
|
-
else if (command.type === builders_1.CommandType.MessageCommand) {
|
|
30
|
-
this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
throw new Error(`Unknown reciple command type`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
get(command, type) {
|
|
39
|
-
switch (type) {
|
|
40
|
-
case builders_1.CommandType.SlashCommand:
|
|
41
|
-
return this.slashCommands.get(command);
|
|
42
|
-
case builders_1.CommandType.MessageCommand:
|
|
43
|
-
return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
|
|
44
|
-
default:
|
|
45
|
-
throw new TypeError('Unknown command type');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Register application commands
|
|
50
|
-
* @param guilds Register application commands to guilds
|
|
51
|
-
*/
|
|
52
|
-
async registerApplicationCommands(...guilds) {
|
|
53
|
-
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
54
|
-
guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
|
|
55
|
-
if (!this.client.isClientLogsSilent)
|
|
56
|
-
this.client.logger.log(`Regestering ${this.applicationCommandsSize} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
|
|
57
|
-
await this.client.applicationCommands.set([...this.slashCommands.toJSON(), ...this.additionalApplicationCommands], guilds);
|
|
58
|
-
this.client.emit('recipleRegisterApplicationCommands');
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.ClientCommandManager = ClientCommandManager;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientCommandManager = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const builders_1 = require("../../types/builders");
|
|
6
|
+
const MessageCommandBuilder_1 = require("../builders/MessageCommandBuilder");
|
|
7
|
+
const SlashCommandBuilder_1 = require("../builders/SlashCommandBuilder");
|
|
8
|
+
class ClientCommandManager {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.slashCommands = new discord_js_1.Collection();
|
|
11
|
+
this.messageCommands = new discord_js_1.Collection();
|
|
12
|
+
this.additionalApplicationCommands = [];
|
|
13
|
+
this.client = options.client;
|
|
14
|
+
options.slashCommands?.forEach(e => this.slashCommands.set(e.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(e)));
|
|
15
|
+
options.messageCommands?.forEach(e => this.messageCommands.set(e.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(e)));
|
|
16
|
+
}
|
|
17
|
+
get applicationCommandsSize() {
|
|
18
|
+
return this.client.commands.slashCommands.size + this.client.commands.additionalApplicationCommands.length;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Add command to command manager
|
|
22
|
+
* @param commands Any command data or builder
|
|
23
|
+
*/
|
|
24
|
+
add(...commands) {
|
|
25
|
+
for (const command of (0, discord_js_1.normalizeArray)(commands)) {
|
|
26
|
+
if (command.type === builders_1.CommandType.SlashCommand) {
|
|
27
|
+
this.slashCommands.set(command.name, SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
|
|
28
|
+
}
|
|
29
|
+
else if (command.type === builders_1.CommandType.MessageCommand) {
|
|
30
|
+
this.messageCommands.set(command.name, MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new Error(`Unknown reciple command type`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
get(command, type) {
|
|
39
|
+
switch (type) {
|
|
40
|
+
case builders_1.CommandType.SlashCommand:
|
|
41
|
+
return this.slashCommands.get(command);
|
|
42
|
+
case builders_1.CommandType.MessageCommand:
|
|
43
|
+
return this.messageCommands.get(command.toLowerCase()) ?? (this.client.config.commands.messageCommand.allowCommandAlias ? this.messageCommands.find(c => c.aliases.some(a => a == command?.toLowerCase())) : undefined);
|
|
44
|
+
default:
|
|
45
|
+
throw new TypeError('Unknown command type');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Register application commands
|
|
50
|
+
* @param guilds Register application commands to guilds
|
|
51
|
+
*/
|
|
52
|
+
async registerApplicationCommands(...guilds) {
|
|
53
|
+
guilds = (0, discord_js_1.normalizeArray)(guilds);
|
|
54
|
+
guilds = guilds.length ? guilds : (0, discord_js_1.normalizeArray)([this.client.config.commands.slashCommand.guilds]);
|
|
55
|
+
if (!this.client.isClientLogsSilent)
|
|
56
|
+
this.client.logger.log(`Regestering ${this.applicationCommandsSize} application command(s) ${!guilds.length ? 'globaly' : 'to ' + guilds.length + ' guilds'}...`);
|
|
57
|
+
await this.client.applicationCommands.set([...this.slashCommands.toJSON(), ...this.additionalApplicationCommands], guilds);
|
|
58
|
+
this.client.emit('recipleRegisterApplicationCommands');
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ClientCommandManager = ClientCommandManager;
|