spacecommands 3.6.4 → 3.6.5
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/dist/SlashCommands.js
CHANGED
|
@@ -6,6 +6,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
const discord_js_1 = require("discord.js");
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const get_all_files_1 = __importDefault(require("./get-all-files"));
|
|
9
|
+
const convertOptions = (options) => {
|
|
10
|
+
if (!options)
|
|
11
|
+
return options;
|
|
12
|
+
return options.map((option) => {
|
|
13
|
+
// Convert type from string to integer if needed
|
|
14
|
+
if (typeof option.type === 'string') {
|
|
15
|
+
const typeMap = {
|
|
16
|
+
SUB_COMMAND: discord_js_1.ApplicationCommandOptionType.Subcommand,
|
|
17
|
+
SUB_COMMAND_GROUP: discord_js_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
18
|
+
STRING: discord_js_1.ApplicationCommandOptionType.String,
|
|
19
|
+
INTEGER: discord_js_1.ApplicationCommandOptionType.Integer,
|
|
20
|
+
BOOLEAN: discord_js_1.ApplicationCommandOptionType.Boolean,
|
|
21
|
+
USER: discord_js_1.ApplicationCommandOptionType.User,
|
|
22
|
+
CHANNEL: discord_js_1.ApplicationCommandOptionType.Channel,
|
|
23
|
+
ROLE: discord_js_1.ApplicationCommandOptionType.Role,
|
|
24
|
+
MENTIONABLE: discord_js_1.ApplicationCommandOptionType.Mentionable,
|
|
25
|
+
NUMBER: discord_js_1.ApplicationCommandOptionType.Number,
|
|
26
|
+
ATTACHMENT: discord_js_1.ApplicationCommandOptionType.Attachment,
|
|
27
|
+
};
|
|
28
|
+
const upperType = option.type.toUpperCase();
|
|
29
|
+
if (typeMap[upperType]) {
|
|
30
|
+
option.type = typeMap[upperType];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Handle nested options recursively
|
|
34
|
+
if (option.options) {
|
|
35
|
+
option.options = convertOptions(option.options);
|
|
36
|
+
}
|
|
37
|
+
return option;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
9
40
|
class SlashCommands {
|
|
10
41
|
_client;
|
|
11
42
|
_instance;
|
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
const required_roles_1 = __importDefault(require("../models/required-roles"));
|
|
6
6
|
const commands_1 = __importDefault(require("../models/commands"));
|
|
7
|
+
const { ApplicationCommandOptionType } = require('discord.js');
|
|
7
8
|
module.exports = {
|
|
8
|
-
description: 'Specifies what role each command requires (Config)',
|
|
9
|
+
description: 'Specifies what role each command requires (Config v2)',
|
|
9
10
|
category: 'Configuration',
|
|
10
11
|
permissions: ['Administrator'],
|
|
11
12
|
aliases: ['requiredroles', 'requirerole', 'requireroles'],
|
|
@@ -17,14 +18,14 @@ module.exports = {
|
|
|
17
18
|
name: 'command',
|
|
18
19
|
description: 'The command to set required roles for',
|
|
19
20
|
required: true,
|
|
20
|
-
type:
|
|
21
|
+
type: ApplicationCommandOptionType.String,
|
|
21
22
|
autocomplete: true,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
|
-
name: 'roleid',
|
|
25
|
+
name: 'none-or-roleid',
|
|
25
26
|
description: 'The role ID to require, or "none" to clear',
|
|
26
27
|
required: true,
|
|
27
|
-
type:
|
|
28
|
+
type: ApplicationCommandOptionType.String,
|
|
28
29
|
autocomplete: true,
|
|
29
30
|
}
|
|
30
31
|
],
|