@spatulox/simplediscordbot 1.0.5 → 1.0.7
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/.env.example +1 -1
- package/LICENSE.md +21 -21
- package/README.md +44 -44
- package/dist/bot/BotMessage.js +54 -28
- package/dist/index.js +6 -2
- package/dist/manager/builder/SendableComponentBuilder.js +62 -0
- package/dist/manager/direct/UserManager.js +16 -5
- package/dist/manager/guild/ChannelManager/GuildMessageManager.js +12 -4
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.js +15 -0
- package/dist/manager/interactions/InteractionManager.js +68 -0
- package/dist/manager/{handlers/builder → interactions}/ModalManager.js +2 -2
- package/dist/manager/interactions/SelectMenuManager.js +123 -0
- package/dist/manager/messages/WebhookManager.js +8 -5
- package/package.json +36 -41
- package/dist/cli/BaseCLI.js +0 -166
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.js +0 -109
- package/dist/cli/GenerationCLI/GenerationCLI.js +0 -25
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.js +0 -166
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.js +0 -221
- package/dist/cli/GuildListManager.js +0 -61
- package/dist/cli/InteractionCLI/InteractionCLI.js +0 -30
- package/dist/cli/InteractionCLI/InteractionCLIManager.js +0 -80
- package/dist/cli/MainCLI.js +0 -32
- package/dist/cli/type/ContextMenuConfig.js +0 -2
- package/dist/cli/type/InteractionType.js +0 -14
- package/dist/cli/type/SlashCommandConfig.js +0 -2
- package/dist/manager/handlers/interactions/BaseInteractionManager.js +0 -338
- package/dist/manager/handlers/interactions/InteractionManager.js +0 -29
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlashCommandGeneratorCLI = void 0;
|
|
4
|
-
const BaseCLI_1 = require("../BaseCLI");
|
|
5
|
-
const FolderName_1 = require("../../type/FolderName");
|
|
6
|
-
const discord_js_1 = require("discord.js");
|
|
7
|
-
const DiscordRegex_1 = require("../../utils/DiscordRegex");
|
|
8
|
-
class SlashCommandGeneratorCLI extends BaseCLI_1.BaseCLI {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.menuSelection = [
|
|
12
|
-
{ label: "Generate Slash Command", action: () => this },
|
|
13
|
-
{ label: "Back", action: () => this.goBack() },
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
getTitle() {
|
|
17
|
-
return "📝 Slash Command JSON Generator";
|
|
18
|
-
}
|
|
19
|
-
async execute() {
|
|
20
|
-
const config = {
|
|
21
|
-
type: 1,
|
|
22
|
-
name: "",
|
|
23
|
-
description: "",
|
|
24
|
-
options: [],
|
|
25
|
-
dm_permission: false,
|
|
26
|
-
default_member_permissions: undefined,
|
|
27
|
-
default_member_permissions_string: undefined,
|
|
28
|
-
integration_types: [0, 1],
|
|
29
|
-
contexts: [0]
|
|
30
|
-
};
|
|
31
|
-
// 1. Command Name
|
|
32
|
-
console.clear();
|
|
33
|
-
console.log("📝 1/12 - Command Name");
|
|
34
|
-
config.name = await this.requireInput("Enter command name (lowercase, no spaces): ", val => /^[a-z_-]{1,32}$/.test(val));
|
|
35
|
-
// 2. Command Description
|
|
36
|
-
console.clear();
|
|
37
|
-
console.log("📄 2/12 - Command Description");
|
|
38
|
-
config.description = await this.requireInput("Enter command description (1-100 chars): ", val => val.length >= 1 && val.length <= 100);
|
|
39
|
-
// 3. Member Permissions
|
|
40
|
-
console.clear();
|
|
41
|
-
console.log("🔐 3/12 - Permissions");
|
|
42
|
-
console.log("📋 Valid permissions:\n", Object.keys(discord_js_1.PermissionFlagsBits).join(', '));
|
|
43
|
-
const permsInput = await this.requireInput("Default member permissions (comma separated, or 'none'): ", (val) => {
|
|
44
|
-
if (!val || val.toLowerCase() === "none" || val === '')
|
|
45
|
-
return true;
|
|
46
|
-
const permissions = val.split(",").map(p => p.trim());
|
|
47
|
-
const invalidPerms = permissions.filter(perm => !(perm in discord_js_1.PermissionFlagsBits));
|
|
48
|
-
if (invalidPerms.length > 0) {
|
|
49
|
-
console.log(`❌ Invalid: ${invalidPerms.join(', ')}`);
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}, true);
|
|
54
|
-
if (permsInput && permsInput.toLowerCase() !== "none") {
|
|
55
|
-
config.default_member_permissions_string = permsInput.split(",").map(p => p.trim());
|
|
56
|
-
}
|
|
57
|
-
// 4. DM Permission
|
|
58
|
-
console.clear();
|
|
59
|
-
console.log("💬 4/12 - DM Permission");
|
|
60
|
-
config.dm_permission = (await this.yesNoInput("Allow in DMs? (y/n): "));
|
|
61
|
-
// 5. Integration Types
|
|
62
|
-
console.clear();
|
|
63
|
-
console.log("🔗 5/12 - Integration Types");
|
|
64
|
-
console.log("0 => GUILD_INSTALL, 1 => USER_INSTALL (comma separated, or 'all')");
|
|
65
|
-
const intInput = await this.requireInput("Integration types: ");
|
|
66
|
-
if (intInput.toLowerCase() === "all") {
|
|
67
|
-
config.integration_types = [0, 1];
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
config.integration_types = intInput.split(",").map(i => parseInt(i.trim())).filter(i => !isNaN(i));
|
|
71
|
-
}
|
|
72
|
-
// 6. Contexts
|
|
73
|
-
console.clear();
|
|
74
|
-
console.log("🌐 6/12 - Contexts");
|
|
75
|
-
console.log("0 => Server, 1 => Bot DMs, 2 => Group/Other DMs (comma separated, or 'server')");
|
|
76
|
-
const ctxInput = await this.requireInput("Contexts: ", undefined, true);
|
|
77
|
-
if (!ctxInput || ctxInput.trim() === "") {
|
|
78
|
-
config.contexts = [0, 1, 2];
|
|
79
|
-
}
|
|
80
|
-
else if (ctxInput.toLowerCase() === "all") {
|
|
81
|
-
config.contexts = [0, 1, 2];
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
config.contexts = ctxInput.split(",").map(i => parseInt(i.trim())).filter(i => !isNaN(i));
|
|
85
|
-
}
|
|
86
|
-
// 7. Add Subcommands/Groups?
|
|
87
|
-
console.clear();
|
|
88
|
-
console.log("📂 7/12 - Structure");
|
|
89
|
-
const addStructure = await this.yesNoInput("Add subcommands or groups? (y/n): ");
|
|
90
|
-
if (addStructure) {
|
|
91
|
-
await this.addCommandStructure(config);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// Add basic options if no structure
|
|
95
|
-
await this.addSimpleOptions(config);
|
|
96
|
-
}
|
|
97
|
-
// 8. Guild IDs (optional)
|
|
98
|
-
console.clear();
|
|
99
|
-
console.log("🏠 8/12 - Guild IDs (optional)");
|
|
100
|
-
const guildInput = await this.requireInput("Guild IDs (comma separated, or 'none'): ", (val) => {
|
|
101
|
-
if (!val || val.toLowerCase() === "none")
|
|
102
|
-
return true;
|
|
103
|
-
const ids = val.split(",").map(id => id.trim());
|
|
104
|
-
const invalidIds = ids.filter(id => !DiscordRegex_1.DiscordRegex.GUILD_ID.test(id));
|
|
105
|
-
if (invalidIds.length > 0) {
|
|
106
|
-
console.log(`❌ Invalid Guild IDs: ${invalidIds.join(', ')}`);
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
}, true);
|
|
111
|
-
if (guildInput && guildInput.toLowerCase() !== "none") {
|
|
112
|
-
config.guildID = guildInput.split(",").map(id => id.trim());
|
|
113
|
-
}
|
|
114
|
-
// 9. Filename
|
|
115
|
-
console.clear();
|
|
116
|
-
console.log("💾 9/12 - Filename");
|
|
117
|
-
const filename = (await this.requireInput("Filename (without .json): ")) + ".json";
|
|
118
|
-
await this.saveFile(FolderName_1.FolderName.SLASH_COMMANDS, filename, config);
|
|
119
|
-
}
|
|
120
|
-
async addCommandStructure(config) {
|
|
121
|
-
console.clear();
|
|
122
|
-
console.log("📁 Structure Type");
|
|
123
|
-
console.log("1 => Add Sub Command Group");
|
|
124
|
-
console.log("2 => Add Sub Command");
|
|
125
|
-
const structureType = parseInt(await this.requireInput("Type (1 or 2): ", val => ["1", "2"].includes(val)));
|
|
126
|
-
if (structureType === 1) {
|
|
127
|
-
// Sub Command Group
|
|
128
|
-
const groupName = await this.requireInput("Group name: ");
|
|
129
|
-
const groupDesc = await this.requireInput("Group description: ");
|
|
130
|
-
config.options = config.options || [];
|
|
131
|
-
config.options.push({
|
|
132
|
-
type: 2,
|
|
133
|
-
name: groupName,
|
|
134
|
-
description: groupDesc,
|
|
135
|
-
options: []
|
|
136
|
-
});
|
|
137
|
-
await this.addSubCommands(config.options[config.options.length - 1].options);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
// Direct Sub Command
|
|
141
|
-
await this.addSubCommands(config.options);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async addSubCommands(options) {
|
|
145
|
-
let continueAdding = true;
|
|
146
|
-
while (continueAdding) {
|
|
147
|
-
console.clear();
|
|
148
|
-
console.log("➕ Add Subcommand");
|
|
149
|
-
const name = await this.requireInput("Subcommand name: ");
|
|
150
|
-
const desc = await this.requireInput("Subcommand description: ");
|
|
151
|
-
const subCmd = { type: 1, name, description: desc, options: [] };
|
|
152
|
-
await this.addSubCommandOptions(subCmd.options);
|
|
153
|
-
options.push(subCmd);
|
|
154
|
-
continueAdding = await this.yesNoInput("Add another subcommand? (y/n): ");
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async addSubCommandOptions(options) {
|
|
158
|
-
let continueAdding = await this.yesNoInput("Add options to this subcommand? (y/n): ");
|
|
159
|
-
while (continueAdding) {
|
|
160
|
-
console.clear();
|
|
161
|
-
console.log("Option Types:\n1=SUB_COMMAND,2=SUB_GROUP,3=STRING,4=INTEGER,5=BOOLEAN,6=USER,7=CHANNEL,8=ROLE,9=MENTIONNABLE,10=NUMBER");
|
|
162
|
-
const type = parseInt(await this.requireInput("Option type (3-10): ", val => {
|
|
163
|
-
const n = parseInt(val);
|
|
164
|
-
return n >= 3 && n <= 10;
|
|
165
|
-
}));
|
|
166
|
-
const name = await this.requireInput("Option name: ");
|
|
167
|
-
const description = await this.requireInput("Option description: ");
|
|
168
|
-
const required = await this.yesNoInput("Required? (y/n): ");
|
|
169
|
-
const option = { type, name, description, required };
|
|
170
|
-
if ([3, 4, 10].includes(type)) {
|
|
171
|
-
// String, Integer, Number
|
|
172
|
-
option.choices = await this.addChoices();
|
|
173
|
-
}
|
|
174
|
-
if (type === 3) { // String
|
|
175
|
-
option.min_length = parseInt(await this.prompt("Min length (optional, Enter=skip): ")) || undefined;
|
|
176
|
-
option.max_length = parseInt(await this.prompt("Max length (optional, Enter=skip): ")) || undefined;
|
|
177
|
-
}
|
|
178
|
-
else if ([4, 10].includes(type)) { // Int/Number
|
|
179
|
-
option.min_value = parseFloat(await this.prompt("Min value (optional, Enter=skip): ")) || undefined;
|
|
180
|
-
option.max_value = parseFloat(await this.prompt("Max value (optional, Enter=skip): ")) || undefined;
|
|
181
|
-
}
|
|
182
|
-
else if (type === 7) { // Channel
|
|
183
|
-
option.channel_types = await this.addChannelTypes();
|
|
184
|
-
}
|
|
185
|
-
options.push(option);
|
|
186
|
-
continueAdding = await this.yesNoInput("Add another option? (y/n): ");
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async addChoices() {
|
|
190
|
-
const choices = [];
|
|
191
|
-
let continueAdding = await this.yesNoInput("Add choices? (y/n): ");
|
|
192
|
-
while (continueAdding && choices.length < 25) {
|
|
193
|
-
const name = await this.requireInput("Choice name: ");
|
|
194
|
-
const value = await this.requireInput("Choice value: ");
|
|
195
|
-
choices.push({ name, value });
|
|
196
|
-
continueAdding = await this.yesNoInput("Add another choice? (y/n): ");
|
|
197
|
-
}
|
|
198
|
-
return choices.length > 0 ? choices : undefined;
|
|
199
|
-
}
|
|
200
|
-
async addChannelTypes() {
|
|
201
|
-
console.log("Channel types: 0=text, 2=voice, 4=category, 5=announcement, 10=thread, 11=public-thread, 12=private-thread");
|
|
202
|
-
const input = await this.requireInput("Channel types (comma sep, or Enter=none): ", undefined, true);
|
|
203
|
-
return input ? input.split(",").map(i => parseInt(i.trim())).filter(i => !isNaN(i)) : undefined;
|
|
204
|
-
}
|
|
205
|
-
async addSimpleOptions(config) {
|
|
206
|
-
console.clear();
|
|
207
|
-
console.log("➕ Simple Options");
|
|
208
|
-
let continueAdding = await this.yesNoInput("Add options? (y/n): ");
|
|
209
|
-
config.options = [];
|
|
210
|
-
while (continueAdding) {
|
|
211
|
-
console.log("Quick option types: 3=string,4=int,5=bool,6=user,7=channel,8=role,9=mentionnable,10=number");
|
|
212
|
-
const type = parseInt(await this.requireInput("Type (3-10): ", val => ["3", "4", "5", "6", "7", "8", "9", "10"].includes(val)));
|
|
213
|
-
const name = await this.requireInput("Name: ");
|
|
214
|
-
const desc = await this.requireInput("Description: ");
|
|
215
|
-
const required = await this.yesNoInput("Required?: ");
|
|
216
|
-
config.options.push({ type, name, description: desc, required });
|
|
217
|
-
continueAdding = await this.yesNoInput("Another option? (y/n): ");
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
exports.SlashCommandGeneratorCLI = SlashCommandGeneratorCLI;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildListManager = void 0;
|
|
4
|
-
const BaseCLI_1 = require("./BaseCLI");
|
|
5
|
-
const rest_1 = require("@discordjs/rest");
|
|
6
|
-
const v10_1 = require("discord-api-types/v10");
|
|
7
|
-
class GuildListManager extends BaseCLI_1.BaseCLI {
|
|
8
|
-
constructor(clientId, token) {
|
|
9
|
-
super();
|
|
10
|
-
this.guilds = [];
|
|
11
|
-
this.menuSelection = [
|
|
12
|
-
{ label: "List guilds", action: () => this.list() },
|
|
13
|
-
{ label: "Choose guild", action: () => this.chooseGuild() },
|
|
14
|
-
{ label: "Back", action: () => this.goBack() },
|
|
15
|
-
];
|
|
16
|
-
this.clientId = clientId;
|
|
17
|
-
this.token = token;
|
|
18
|
-
this.rest = new rest_1.REST({ version: '10' }).setToken(token);
|
|
19
|
-
}
|
|
20
|
-
getTitle() {
|
|
21
|
-
return "Guilds Selection";
|
|
22
|
-
}
|
|
23
|
-
async execute() {
|
|
24
|
-
throw new Error("Method not implemented.");
|
|
25
|
-
}
|
|
26
|
-
async list(printResult = true) {
|
|
27
|
-
console.clear();
|
|
28
|
-
if (printResult)
|
|
29
|
-
console.log(`${this.getTitle()}\n`);
|
|
30
|
-
try {
|
|
31
|
-
this.guilds = await this.rest.get(v10_1.Routes.userGuilds());
|
|
32
|
-
if (printResult) {
|
|
33
|
-
console.table(this.guilds.map((g, i) => ({
|
|
34
|
-
Index: i,
|
|
35
|
-
"Guild ID": g.id,
|
|
36
|
-
Nom: g.name
|
|
37
|
-
})));
|
|
38
|
-
console.log(`\n📋 ${this.guilds.length} guild(s) found\n`);
|
|
39
|
-
}
|
|
40
|
-
return this.guilds;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error(`Error when listing guilds: ${error}`);
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async chooseGuild() {
|
|
48
|
-
await this.list();
|
|
49
|
-
if (!this.guilds.length) {
|
|
50
|
-
console.log("No available Guild\n");
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const indexStr = await this.requireInput("Enter guild index (0-" + (this.guilds.length - 1) + "): ", (val) => {
|
|
54
|
-
const num = Number(val);
|
|
55
|
-
return !isNaN(num) && num >= 0 && num < this.guilds.length;
|
|
56
|
-
}, false);
|
|
57
|
-
const index = Number(indexStr);
|
|
58
|
-
return this.guilds[index] ?? null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.GuildListManager = GuildListManager;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InteractionCLI = void 0;
|
|
4
|
-
const BaseCLI_1 = require("../BaseCLI");
|
|
5
|
-
const BotEnv_1 = require("../../bot/BotEnv");
|
|
6
|
-
const InteractionManager_1 = require("../../manager/handlers/interactions/InteractionManager");
|
|
7
|
-
const InteractionCLIManager_1 = require("./InteractionCLIManager");
|
|
8
|
-
class InteractionCLI extends BaseCLI_1.BaseCLI {
|
|
9
|
-
getTitle() {
|
|
10
|
-
return '🔄 Interaction Manager CLI';
|
|
11
|
-
}
|
|
12
|
-
constructor(parent) {
|
|
13
|
-
super(parent);
|
|
14
|
-
this.managers = {};
|
|
15
|
-
this.menuSelection = [
|
|
16
|
-
{ label: "Command Manager", action: () => new InteractionCLIManager_1.InteractionManagerCLI(this, this.managers["CommandManager"], "CommandManager") },
|
|
17
|
-
{ label: "ContextMenu Manager", action: () => new InteractionCLIManager_1.InteractionManagerCLI(this, this.managers["ContextMenuManager"], "ContextMenuManager") },
|
|
18
|
-
//{ label: "All Interaction Manager", action: () => new InteractionManagerCLI(this, this.managers["InteractionManager"], "InteractionManager") },
|
|
19
|
-
{ label: 'Back', action: () => this.goBack() },
|
|
20
|
-
];
|
|
21
|
-
const { clientId, token } = BotEnv_1.BotEnv;
|
|
22
|
-
this.managers['CommandManager'] = new InteractionManager_1.CommandManager(clientId, token);
|
|
23
|
-
this.managers['ContextMenuManager'] = new InteractionManager_1.ContextMenuManager(clientId, token);
|
|
24
|
-
//this.managers['InteractionManager'] = new AllInteractionManager(clientId, token);
|
|
25
|
-
}
|
|
26
|
-
async execute() {
|
|
27
|
-
throw new Error("Method not implemented.");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.InteractionCLI = InteractionCLI;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InteractionManagerCLI = void 0;
|
|
4
|
-
const BaseCLI_1 = require("../BaseCLI");
|
|
5
|
-
const GuildListManager_1 = require("../GuildListManager");
|
|
6
|
-
const BotEnv_1 = require("../../bot/BotEnv");
|
|
7
|
-
class InteractionManagerCLI extends BaseCLI_1.BaseCLI {
|
|
8
|
-
getTitle() {
|
|
9
|
-
return `${this.managerKey} - ${this.manager.folderPath}`;
|
|
10
|
-
}
|
|
11
|
-
constructor(parent, manager, managerKey) {
|
|
12
|
-
super(parent);
|
|
13
|
-
this.menuSelection = [
|
|
14
|
-
{ label: `List Global commands`, action: () => this.listRemote() },
|
|
15
|
-
{ label: "List commands per GuildID", action: async () => this.guildListRemote(await new GuildListManager_1.GuildListManager(BotEnv_1.BotEnv.clientId, BotEnv_1.BotEnv.token).chooseGuild()) },
|
|
16
|
-
{ label: "List commands per Guild", action: async () => this.guildListAllRemote() },
|
|
17
|
-
{ label: "Deploy local", action: () => this.handleDeploy() },
|
|
18
|
-
{ label: "Update remote", action: () => this.handleUpdate() },
|
|
19
|
-
{ label: "Delete remote", action: () => this.handleDelete() },
|
|
20
|
-
{ label: 'Back', action: () => this.goBack() },
|
|
21
|
-
];
|
|
22
|
-
this.manager = manager;
|
|
23
|
-
this.managerKey = managerKey;
|
|
24
|
-
}
|
|
25
|
-
execute() {
|
|
26
|
-
throw new Error("Method not implemented.");
|
|
27
|
-
}
|
|
28
|
-
async listRemote() {
|
|
29
|
-
await this.manager.list();
|
|
30
|
-
}
|
|
31
|
-
async guildListRemote(guild) {
|
|
32
|
-
if (!guild) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
await this.manager.listGuild(guild.id);
|
|
36
|
-
}
|
|
37
|
-
async guildListAllRemote() {
|
|
38
|
-
await this.manager.listAllGuilds(await new GuildListManager_1.GuildListManager(BotEnv_1.BotEnv.clientId, BotEnv_1.BotEnv.token).list(false));
|
|
39
|
-
}
|
|
40
|
-
async handleDeploy() {
|
|
41
|
-
const selected = await this.selectCommands(this.manager, false);
|
|
42
|
-
if (selected.length === 0)
|
|
43
|
-
return;
|
|
44
|
-
await this.manager.deploy(selected);
|
|
45
|
-
}
|
|
46
|
-
async handleUpdate() {
|
|
47
|
-
const selected = await this.selectCommands(this.manager);
|
|
48
|
-
if (selected.length === 0)
|
|
49
|
-
return;
|
|
50
|
-
await this.manager.update(selected);
|
|
51
|
-
}
|
|
52
|
-
async handleDelete() {
|
|
53
|
-
const selected = await this.selectCommands(this.manager);
|
|
54
|
-
if (selected.length === 0)
|
|
55
|
-
return;
|
|
56
|
-
await this.manager.delete(selected);
|
|
57
|
-
}
|
|
58
|
-
async selectCommands(manager, remote = true) {
|
|
59
|
-
const handlerManagerType = `${manager.folderPath}(s)`;
|
|
60
|
-
const commandList = remote ? await manager.list() : await manager.listFromFile();
|
|
61
|
-
if (!commandList?.length) {
|
|
62
|
-
console.log(`No ${handlerManagerType} found`);
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
const input = await this.prompt('Enter numbers (ex: 1,3,5 or "all" or "exit"): ');
|
|
66
|
-
if (input.toLowerCase() === 'all')
|
|
67
|
-
return commandList;
|
|
68
|
-
if (input.toLowerCase() === 'exit')
|
|
69
|
-
return [];
|
|
70
|
-
const indices = input.split(',').map(i => parseInt(i.trim())).filter(i => !isNaN(i));
|
|
71
|
-
const selected = commandList.filter((cmd) => indices.includes(cmd.index));
|
|
72
|
-
if (selected.length === 0) {
|
|
73
|
-
console.log('Invalid number');
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
console.log(`${selected.length} selected ${handlerManagerType}`);
|
|
77
|
-
return selected;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.InteractionManagerCLI = InteractionManagerCLI;
|
package/dist/cli/MainCLI.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.MainCLI = void 0;
|
|
5
|
-
const BaseCLI_1 = require("./BaseCLI");
|
|
6
|
-
const InteractionCLI_1 = require("./InteractionCLI/InteractionCLI");
|
|
7
|
-
const GenerationCLI_1 = require("./GenerationCLI/GenerationCLI");
|
|
8
|
-
/**
|
|
9
|
-
* --- MainCLI ---
|
|
10
|
-
* Main controller for sub menu
|
|
11
|
-
*/
|
|
12
|
-
class MainCLI extends BaseCLI_1.BaseCLI {
|
|
13
|
-
getTitle() {
|
|
14
|
-
return "💠 SimpleDiscordBot CLI";
|
|
15
|
-
}
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this.menuSelection = [
|
|
19
|
-
{ label: "Manage Interactions", action: () => new InteractionCLI_1.InteractionCLI(this) },
|
|
20
|
-
{ label: "Generate Files", action: () => new GenerationCLI_1.GenerationCLI(this) },
|
|
21
|
-
{ label: "Help", action: () => this.showHelp() },
|
|
22
|
-
{ label: "Exit", action: () => this },
|
|
23
|
-
];
|
|
24
|
-
this.showMainMenu();
|
|
25
|
-
}
|
|
26
|
-
execute() {
|
|
27
|
-
console.log("👋 Bye !");
|
|
28
|
-
process.exit();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.MainCLI = MainCLI;
|
|
32
|
-
new MainCLI();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InteractionContextType = exports.InteractionIntegrationType = void 0;
|
|
4
|
-
var InteractionIntegrationType;
|
|
5
|
-
(function (InteractionIntegrationType) {
|
|
6
|
-
InteractionIntegrationType[InteractionIntegrationType["GUILD_INSTALL"] = 0] = "GUILD_INSTALL";
|
|
7
|
-
InteractionIntegrationType[InteractionIntegrationType["USER_INSTALL"] = 1] = "USER_INSTALL";
|
|
8
|
-
})(InteractionIntegrationType || (exports.InteractionIntegrationType = InteractionIntegrationType = {}));
|
|
9
|
-
var InteractionContextType;
|
|
10
|
-
(function (InteractionContextType) {
|
|
11
|
-
InteractionContextType[InteractionContextType["SERVER_CHANNEL"] = 0] = "SERVER_CHANNEL";
|
|
12
|
-
InteractionContextType[InteractionContextType["BOT_DM"] = 1] = "BOT_DM";
|
|
13
|
-
InteractionContextType[InteractionContextType["GROUP_DM"] = 2] = "GROUP_DM";
|
|
14
|
-
})(InteractionContextType || (exports.InteractionContextType = InteractionContextType = {}));
|