@spatulox/simplediscordbot 1.0.6 â 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 +2 -0
- 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 -42
- package/dist/bot/Bot.d.ts +0 -32
- package/dist/bot/BotEnv.d.ts +0 -5
- package/dist/bot/BotLog.d.ts +0 -51
- package/dist/bot/BotMessage.d.ts +0 -16
- package/dist/cli/BaseCLI.d.ts +0 -25
- package/dist/cli/BaseCLI.js +0 -166
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.d.ts +0 -6
- package/dist/cli/GenerationCLI/ContextMenuGeneratorCLI.js +0 -109
- package/dist/cli/GenerationCLI/GenerationCLI.d.ts +0 -6
- package/dist/cli/GenerationCLI/GenerationCLI.js +0 -25
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.d.ts +0 -44
- package/dist/cli/GenerationCLI/ModalGeneratorCLI.js +0 -166
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.d.ts +0 -12
- package/dist/cli/GenerationCLI/SlashCommandsGeneratorCLI.js +0 -221
- package/dist/cli/GuildListManager.d.ts +0 -24
- package/dist/cli/GuildListManager.js +0 -61
- package/dist/cli/InteractionCLI/InteractionCLI.d.ts +0 -8
- package/dist/cli/InteractionCLI/InteractionCLI.js +0 -30
- package/dist/cli/InteractionCLI/InteractionCLIManager.d.ts +0 -17
- package/dist/cli/InteractionCLI/InteractionCLIManager.js +0 -80
- package/dist/cli/MainCLI.d.ts +0 -12
- package/dist/cli/MainCLI.js +0 -32
- package/dist/cli/type/ContextMenuConfig.d.ts +0 -12
- package/dist/cli/type/ContextMenuConfig.js +0 -2
- package/dist/cli/type/InteractionType.d.ts +0 -9
- package/dist/cli/type/InteractionType.js +0 -14
- package/dist/cli/type/SlashCommandConfig.d.ts +0 -43
- package/dist/cli/type/SlashCommandConfig.js +0 -2
- package/dist/index.d.ts +0 -14
- package/dist/manager/FileManager.d.ts +0 -36
- package/dist/manager/direct/UserManager.d.ts +0 -23
- package/dist/manager/guild/ChannelManager/ForumChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/GuildChannelList.d.ts +0 -16
- package/dist/manager/guild/ChannelManager/GuildChannelManager.d.ts +0 -17
- package/dist/manager/guild/ChannelManager/GuildMessageManager.d.ts +0 -21
- package/dist/manager/guild/ChannelManager/GuildTextChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/GuildVoiceChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/NewsChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/StageChannelManager.d.ts +0 -8
- package/dist/manager/guild/ChannelManager/ThreadChannelManager.d.ts +0 -8
- package/dist/manager/guild/GuildManager.d.ts +0 -30
- package/dist/manager/guild/GuildUserManager.d.ts +0 -46
- package/dist/manager/guild/InviteManager.d.ts +0 -20
- package/dist/manager/guild/InviteManager_old.d.ts +0 -23
- package/dist/manager/guild/RoleManager.d.ts +0 -23
- package/dist/manager/handlers/builder/ModalManager.d.ts +0 -22
- package/dist/manager/handlers/interactions/BaseInteractionManager.d.ts +0 -44
- package/dist/manager/handlers/interactions/BaseInteractionManager.js +0 -338
- package/dist/manager/handlers/interactions/InteractionManager.d.ts +0 -14
- package/dist/manager/handlers/interactions/InteractionManager.js +0 -29
- package/dist/manager/messages/EmbedManager.d.ts +0 -83
- package/dist/manager/messages/ReactionManager.d.ts +0 -25
- package/dist/manager/messages/WebhookManager.d.ts +0 -29
- package/dist/type/FolderName.d.ts +0 -5
- package/dist/utils/DiscordRegex.d.ts +0 -65
- package/dist/utils/Log.d.ts +0 -8
- package/dist/utils/SimpleMutex.d.ts +0 -15
- package/dist/utils/network/InternetChecker.d.ts +0 -9
- package/dist/utils/times/UnitTime.d.ts +0 -186
|
@@ -5,6 +5,7 @@ const discord_js_1 = require("discord.js");
|
|
|
5
5
|
const EmbedManager_1 = require("./EmbedManager");
|
|
6
6
|
const Log_1 = require("../../utils/Log");
|
|
7
7
|
const Bot_1 = require("../../bot/Bot");
|
|
8
|
+
const SendableComponentBuilder_1 = require("../builder/SendableComponentBuilder");
|
|
8
9
|
class WebhookManager {
|
|
9
10
|
constructor(channel, name = Bot_1.Bot.config.botName || "", avatarURL) {
|
|
10
11
|
this.channel = channel;
|
|
@@ -39,14 +40,16 @@ class WebhookManager {
|
|
|
39
40
|
throw error;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Send message/text/embed - EmbedBuilder NATIVE !
|
|
44
|
-
*/
|
|
45
43
|
async send(content) {
|
|
46
44
|
const webhook = await this.getWebhook();
|
|
47
45
|
const options = {};
|
|
48
|
-
if (content
|
|
49
|
-
|
|
46
|
+
if (SendableComponentBuilder_1.SendableComponentBuilder.isSendableComponent(content)) {
|
|
47
|
+
const t = SendableComponentBuilder_1.SendableComponentBuilder.buildMessage(content);
|
|
48
|
+
options.embeds = t.embeds;
|
|
49
|
+
options.components = t.components;
|
|
50
|
+
}
|
|
51
|
+
else if (typeof content == 'string') {
|
|
52
|
+
options.content = content;
|
|
50
53
|
}
|
|
51
54
|
else if (typeof content === 'object') {
|
|
52
55
|
Object.assign(options, content);
|
package/package.json
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@spatulox/simplediscordbot",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"author": "Spatulox",
|
|
5
|
-
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"node"
|
|
38
|
-
],
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/Spatulox/SimpleDiscordBot/issues"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@spatulox/simplediscordbot",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"author": "Spatulox",
|
|
5
|
+
"description": "Simple discord bot framework to set up a bot under 30 secondes",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "nodemon --exec tsx src/test/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@spatulox/discord-interaction-manager": "^1.0.8",
|
|
14
|
+
"discord.js": "^14.25.1"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^22.14.0",
|
|
18
|
+
"@types/node-schedule": "^2.1.7",
|
|
19
|
+
"dotenv": "^17.2.4",
|
|
20
|
+
"nodemon": "^3.1.9",
|
|
21
|
+
"tsx": "^4.20.3",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"discord",
|
|
26
|
+
"framework",
|
|
27
|
+
"bot",
|
|
28
|
+
"client",
|
|
29
|
+
"discordjs",
|
|
30
|
+
"discord.js",
|
|
31
|
+
"node"
|
|
32
|
+
],
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/Spatulox/SimpleDiscordBot/issues"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/bot/Bot.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Client, ActivityType } from 'discord.js';
|
|
2
|
-
import { BotLog, ConfigLog } from "./BotLog";
|
|
3
|
-
import { EmbedColor } from "../manager/messages/EmbedManager";
|
|
4
|
-
import { BotMessage } from "./BotMessage";
|
|
5
|
-
export type BotConfig = {
|
|
6
|
-
botIconUrl?: string;
|
|
7
|
-
defaultEmbedColor?: number | EmbedColor;
|
|
8
|
-
botName?: string;
|
|
9
|
-
log?: ConfigLog;
|
|
10
|
-
};
|
|
11
|
-
export type InternalBotConfig = {
|
|
12
|
-
clientId: string;
|
|
13
|
-
} & BotConfig;
|
|
14
|
-
export type RandomBotActivity = {
|
|
15
|
-
type: ActivityType;
|
|
16
|
-
message: string;
|
|
17
|
-
}[];
|
|
18
|
-
export declare class Bot {
|
|
19
|
-
static _client: Client;
|
|
20
|
-
static readonly log: typeof BotLog;
|
|
21
|
-
static readonly message: BotMessage;
|
|
22
|
-
private static criticConfig;
|
|
23
|
-
private static _config;
|
|
24
|
-
get config(): InternalBotConfig;
|
|
25
|
-
get client(): Client;
|
|
26
|
-
static get client(): Client;
|
|
27
|
-
static get config(): InternalBotConfig;
|
|
28
|
-
constructor(client: Client, config: BotConfig);
|
|
29
|
-
login(maxTries?: number): Promise<boolean>;
|
|
30
|
-
static setActivity(message: string, type: ActivityType): void;
|
|
31
|
-
static setRandomActivity(randomActivity: RandomBotActivity, intervalMs?: number | null): void;
|
|
32
|
-
}
|
package/dist/bot/BotEnv.d.ts
DELETED
package/dist/bot/BotLog.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { EmbedBuilder, Message } from 'discord.js';
|
|
2
|
-
export type ConfigLog = {
|
|
3
|
-
logChannelId: string;
|
|
4
|
-
errorChannelId: string;
|
|
5
|
-
info: {
|
|
6
|
-
console: boolean;
|
|
7
|
-
discord: boolean;
|
|
8
|
-
};
|
|
9
|
-
error: {
|
|
10
|
-
console: boolean;
|
|
11
|
-
discord: boolean;
|
|
12
|
-
};
|
|
13
|
-
warn: {
|
|
14
|
-
console: boolean;
|
|
15
|
-
discord: boolean;
|
|
16
|
-
};
|
|
17
|
-
debug: {
|
|
18
|
-
console: boolean;
|
|
19
|
-
discord: boolean;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export declare class BotLog {
|
|
23
|
-
private static logChannel;
|
|
24
|
-
private static errorChannel;
|
|
25
|
-
constructor();
|
|
26
|
-
static config(): ConfigLog | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Initialize Discord logging channels and update Bot.log references
|
|
29
|
-
*/
|
|
30
|
-
static initDiscordLogging(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Send content to specific Discord channel
|
|
33
|
-
*/
|
|
34
|
-
private static _sendToChannel;
|
|
35
|
-
/**
|
|
36
|
-
* Send INFO log - TEXT or EMBED ! Respecte config.log.info
|
|
37
|
-
*/
|
|
38
|
-
static sendLog(content: string | EmbedBuilder): Promise<Message | void>;
|
|
39
|
-
/**
|
|
40
|
-
* Send ERROR log - TEXT or EMBED ! Respecte config.log.error
|
|
41
|
-
*/
|
|
42
|
-
static sendError(content: string | EmbedBuilder): Promise<Message | void>;
|
|
43
|
-
/**
|
|
44
|
-
* Send WARNING log - TEXT or EMBED ! Respecte config.log.warn
|
|
45
|
-
*/
|
|
46
|
-
static sendWarn(content: string | EmbedBuilder): Promise<Message | void>;
|
|
47
|
-
/**
|
|
48
|
-
* Send DEBUG log - TEXT or EMBED ! Respecte config.log.debug
|
|
49
|
-
*/
|
|
50
|
-
static sendDebug(content: string | EmbedBuilder): Promise<Message | void>;
|
|
51
|
-
}
|
package/dist/bot/BotMessage.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { TextChannel, DMChannel, ThreadChannel, EmbedBuilder, Message, User, GuildMember } from 'discord.js';
|
|
2
|
-
export declare class BotMessage {
|
|
3
|
-
/**
|
|
4
|
-
* Send message to any text-based channel
|
|
5
|
-
*/
|
|
6
|
-
send(channel: TextChannel | DMChannel | ThreadChannel | string, content: string | EmbedBuilder): Promise<Message | boolean>;
|
|
7
|
-
sendDM(user: User | GuildMember | string, content: string | EmbedBuilder): Promise<Message | boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Quick success message
|
|
10
|
-
*/
|
|
11
|
-
success(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Quick error message
|
|
14
|
-
*/
|
|
15
|
-
error(channel: TextChannel | DMChannel | ThreadChannel | User | GuildMember, message: string): Promise<Message | boolean>;
|
|
16
|
-
}
|
package/dist/cli/BaseCLI.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import readline from "readline";
|
|
3
|
-
export type MenuSelectionCLI = {
|
|
4
|
-
label: string;
|
|
5
|
-
action: () => BaseCLI | Promise<any> | null;
|
|
6
|
-
}[];
|
|
7
|
-
/**
|
|
8
|
-
* --- BaseCLI ---
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class BaseCLI {
|
|
11
|
-
protected parent?: BaseCLI | undefined;
|
|
12
|
-
private static _rl;
|
|
13
|
-
protected get rl(): readline.Interface;
|
|
14
|
-
constructor(parent?: BaseCLI | undefined);
|
|
15
|
-
protected abstract readonly menuSelection: MenuSelectionCLI;
|
|
16
|
-
protected abstract execute(): Promise<void>;
|
|
17
|
-
protected getTitle(): string;
|
|
18
|
-
protected showMainMenu(): Promise<void>;
|
|
19
|
-
protected prompt(question: string): Promise<string>;
|
|
20
|
-
protected requireInput(message: string, validator?: (val: string) => boolean, canBeEmpty?: boolean): Promise<string>;
|
|
21
|
-
protected yesNoInput(message: string): Promise<boolean>;
|
|
22
|
-
protected showHelp(): Promise<void>;
|
|
23
|
-
protected goBack(): Promise<void>;
|
|
24
|
-
protected saveFile<T>(folderName: string, filename: string, data: T): Promise<void>;
|
|
25
|
-
}
|
package/dist/cli/BaseCLI.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.BaseCLI = void 0;
|
|
8
|
-
const readline_1 = __importDefault(require("readline"));
|
|
9
|
-
const FileManager_1 = require("../manager/FileManager");
|
|
10
|
-
/**
|
|
11
|
-
* --- BaseCLI ---
|
|
12
|
-
*/
|
|
13
|
-
class BaseCLI {
|
|
14
|
-
get rl() {
|
|
15
|
-
if (!BaseCLI._rl) {
|
|
16
|
-
BaseCLI._rl = readline_1.default.createInterface({
|
|
17
|
-
input: process.stdin,
|
|
18
|
-
output: process.stdout
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return BaseCLI._rl;
|
|
22
|
-
}
|
|
23
|
-
constructor(parent) {
|
|
24
|
-
this.parent = parent;
|
|
25
|
-
}
|
|
26
|
-
getTitle() {
|
|
27
|
-
return "BaseCLI";
|
|
28
|
-
}
|
|
29
|
-
async showMainMenu() {
|
|
30
|
-
console.clear();
|
|
31
|
-
console.log(this.getTitle());
|
|
32
|
-
console.log('â'.repeat(40));
|
|
33
|
-
this.menuSelection.forEach((option, index) => {
|
|
34
|
-
console.log(`${index + 1}. ${option.label}`);
|
|
35
|
-
});
|
|
36
|
-
console.log('â'.repeat(40));
|
|
37
|
-
const choice = await this.prompt('Choose an option: ');
|
|
38
|
-
if (choice == "exit") {
|
|
39
|
-
return this.goBack();
|
|
40
|
-
}
|
|
41
|
-
const choiceIndex = parseInt(choice) - 1;
|
|
42
|
-
if (choiceIndex >= 0 && choiceIndex < this.menuSelection.length) {
|
|
43
|
-
const option = this.menuSelection[choiceIndex];
|
|
44
|
-
if (!option) {
|
|
45
|
-
console.log("Invalid Choice");
|
|
46
|
-
return this.showMainMenu();
|
|
47
|
-
}
|
|
48
|
-
const result = await option.action();
|
|
49
|
-
if (result instanceof BaseCLI) {
|
|
50
|
-
if (result == this) {
|
|
51
|
-
await this.execute();
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return await result.showMainMenu();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
await this.prompt('Press Enter to continue...');
|
|
59
|
-
return this.showMainMenu();
|
|
60
|
-
}
|
|
61
|
-
async prompt(question) {
|
|
62
|
-
return new Promise(resolve => this.rl.question(question, resolve));
|
|
63
|
-
}
|
|
64
|
-
async requireInput(message, validator, canBeEmpty = false) {
|
|
65
|
-
while (true) {
|
|
66
|
-
const value = (await this.prompt(message));
|
|
67
|
-
if (!value && !canBeEmpty) {
|
|
68
|
-
console.log("â ī¸ This field is required. Please enter a value.");
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (validator && !validator(value)) {
|
|
72
|
-
console.log("â ī¸ Invalid input. Try again.");
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async yesNoInput(message) {
|
|
79
|
-
while (true) {
|
|
80
|
-
const value = (await this.prompt(message));
|
|
81
|
-
if (!value) {
|
|
82
|
-
console.log("â ī¸ This field is required. Please enter a value.");
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (!["y", "n", "yes", "no"].includes(value.toLowerCase())) {
|
|
86
|
-
console.log("â ī¸ Invalid input. Try again.");
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
return value == "y" || value == "yes";
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async showHelp() {
|
|
93
|
-
console.clear();
|
|
94
|
-
console.log('');
|
|
95
|
-
console.log('||| HELP - Discord Bot Command Manager CLI |||');
|
|
96
|
-
console.log('');
|
|
97
|
-
console.log('đ Wiki: https://github.com/Spatulox/SimpleDiscordBot/wiki');
|
|
98
|
-
console.log('â'.repeat(80));
|
|
99
|
-
console.log('đ¤ What it does:');
|
|
100
|
-
console.log(' âĸ Manage your Discord interactions (slash commands & context menus) via an interactive CLI');
|
|
101
|
-
console.log(' âĸ Let you deploy/update/delete any interaction');
|
|
102
|
-
console.log(' âĸ Let you generate an interaction files');
|
|
103
|
-
console.log('');
|
|
104
|
-
console.log('How you need to save your interaction files');
|
|
105
|
-
console.log('đ Folder Structure:');
|
|
106
|
-
console.log(' âââ handlers/ â In the root folder of your project');
|
|
107
|
-
console.log(' â âââ commands/ â Slash Commands (type 1)');
|
|
108
|
-
console.log(' â âââ context_menu/ â Context Menus (type 2/3)');
|
|
109
|
-
console.log('');
|
|
110
|
-
console.log('đ¯ Features:');
|
|
111
|
-
console.log(' đ 1. List Remote â Show deployed commands on Discord');
|
|
112
|
-
console.log(' đ 2. Deploy Local â Deploy local JSON files â Discord');
|
|
113
|
-
console.log(' đ 3. Update Remote â Update Discord commands based on local JSON file');
|
|
114
|
-
console.log(' đī¸ 4. Delete Remote â Remove Discord commands based on local JSON file');
|
|
115
|
-
console.log('');
|
|
116
|
-
console.log('đŽ Selection:');
|
|
117
|
-
console.log(' âĸ Numbered lists appear after the interaction list');
|
|
118
|
-
console.log(' âĸ Enter: "1,3,5" or "all" to select which interaction you want to apply the action');
|
|
119
|
-
console.log('');
|
|
120
|
-
console.log('đ Wiki: https://github.com/Spatulox/SimpleDiscordBot/wiki');
|
|
121
|
-
console.log('đ Bugs: https://github.com/Spatulox/SimpleDiscordBot/issues');
|
|
122
|
-
console.log('â'.repeat(80));
|
|
123
|
-
await this.prompt('Press Enter to continue...');
|
|
124
|
-
if (this.parent) {
|
|
125
|
-
await this.parent.showMainMenu();
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
await this.showMainMenu();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async goBack() {
|
|
132
|
-
if (this.parent) {
|
|
133
|
-
return this.parent?.showMainMenu();
|
|
134
|
-
}
|
|
135
|
-
return this.execute(); // Fallback for MainCLI
|
|
136
|
-
}
|
|
137
|
-
async saveFile(folderName, filename, data) {
|
|
138
|
-
let finalFilename = filename;
|
|
139
|
-
if (await FileManager_1.FileManager.readJsonFile(`./handlers/${folderName}/${filename}`)) {
|
|
140
|
-
if (!await this.yesNoInput(`"${finalFilename}" already exists. Overwrite? (y/n): `)) {
|
|
141
|
-
const timestamp = Date.now();
|
|
142
|
-
finalFilename = `${filename.replace('.json', '')}-${timestamp}`;
|
|
143
|
-
console.log(`đ New filename: ${finalFilename}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
// 2. Preview + Confirmation
|
|
147
|
-
console.clear();
|
|
148
|
-
console.log("⨠Final JSON preview:");
|
|
149
|
-
console.log(JSON.stringify(data, null, 2));
|
|
150
|
-
if (!await this.yesNoInput("\nSave this file? (y/n): ")) {
|
|
151
|
-
console.log("Cancelled");
|
|
152
|
-
await this.prompt('Press Enter to continue...');
|
|
153
|
-
return this.showMainMenu();
|
|
154
|
-
}
|
|
155
|
-
try {
|
|
156
|
-
await FileManager_1.FileManager.writeJsonFile(`./handlers/${folderName}`, finalFilename, data, false);
|
|
157
|
-
console.log(`File saved: ./handlers/${folderName}/${finalFilename}`);
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
console.error("Error saving file:", error);
|
|
161
|
-
}
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.BaseCLI = BaseCLI;
|
|
166
|
-
BaseCLI._rl = null;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextMenuGeneratorCLI = void 0;
|
|
4
|
-
const BaseCLI_1 = require("../BaseCLI");
|
|
5
|
-
const discord_js_1 = require("discord.js");
|
|
6
|
-
const DiscordRegex_1 = require("../../utils/DiscordRegex");
|
|
7
|
-
const FolderName_1 = require("../../type/FolderName");
|
|
8
|
-
class ContextMenuGeneratorCLI extends BaseCLI_1.BaseCLI {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.menuSelection = [
|
|
12
|
-
{ label: "Generate Context Menu", action: () => this },
|
|
13
|
-
{ label: "Back", action: () => this.goBack() },
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
getTitle() {
|
|
17
|
-
return "đ Context Menu JSON Generator";
|
|
18
|
-
}
|
|
19
|
-
async execute() {
|
|
20
|
-
const config = { dm_permission: false, integration_types: [], name: "", type: 2 };
|
|
21
|
-
// 1. Context Menu Name
|
|
22
|
-
console.clear();
|
|
23
|
-
console.log("đ¤ 1/10 - Name");
|
|
24
|
-
config.name = await this.requireInput("Enter Context Menu name (ex: 'Example context Menu'): ");
|
|
25
|
-
// 2. Type (2=User, 3=Message)
|
|
26
|
-
console.clear();
|
|
27
|
-
console.log("đ§ 2/10 - Type");
|
|
28
|
-
console.log("2 => Context Menu for users");
|
|
29
|
-
console.log("3 => Context Menu for messages");
|
|
30
|
-
config.type = parseInt(await this.requireInput("Enter type (2 or 3): ", val => ["2", "3"].includes(val)));
|
|
31
|
-
// 3. Member Permissions
|
|
32
|
-
console.clear();
|
|
33
|
-
console.log("đ 3/10 - Permissions");
|
|
34
|
-
console.log("đ Valid permissions:\n", Object.keys(discord_js_1.PermissionFlagsBits).join(', '));
|
|
35
|
-
const permsInput = await this.requireInput("Default member permissions (comma separated, or 'none'): ", (val) => {
|
|
36
|
-
if (!val || val.toLowerCase() === "none" || val == '')
|
|
37
|
-
return true;
|
|
38
|
-
const permissions = val.split(",").map(p => p.trim());
|
|
39
|
-
const invalidPerms = permissions.filter(perm => !(perm in discord_js_1.PermissionFlagsBits));
|
|
40
|
-
if (invalidPerms.length > 0) {
|
|
41
|
-
console.log(`â Invalid permissions: ${invalidPerms.join(', ')}`);
|
|
42
|
-
console.log("đ Valid permissions:\n", Object.keys(discord_js_1.PermissionFlagsBits).join(', '));
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}, true);
|
|
47
|
-
if (permsInput !== '' && permsInput.toLowerCase() !== "none") {
|
|
48
|
-
config.default_member_permissions = permsInput.split(",")
|
|
49
|
-
.map(p => p.trim());
|
|
50
|
-
}
|
|
51
|
-
// 4. DM Permission
|
|
52
|
-
console.clear();
|
|
53
|
-
console.log("đŦ 4/10 - DM Permission");
|
|
54
|
-
config.dm_permission = (await this.yesNoInput("Allow in DMs? (y/n): "));
|
|
55
|
-
// 5. Integration Types
|
|
56
|
-
console.clear();
|
|
57
|
-
console.log("đ 5/10 - Integration Types");
|
|
58
|
-
console.log("0 => GUILD_INSTALL");
|
|
59
|
-
console.log("1 => USER_INSTALL");
|
|
60
|
-
console.log("(comma separated, or 'all')");
|
|
61
|
-
const intInput = await this.requireInput("Integration types: ");
|
|
62
|
-
if (intInput.toLowerCase() === "all") {
|
|
63
|
-
config.integration_types = [0, 1];
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
config.integration_types = intInput.split(",").map(i => parseInt(i.trim())).filter(i => !isNaN(i));
|
|
67
|
-
}
|
|
68
|
-
console.clear();
|
|
69
|
-
console.log("đ 6/10 - Contexts");
|
|
70
|
-
console.log("0 => Can be used inside server");
|
|
71
|
-
console.log("1 => Can be used inside DMs with bot");
|
|
72
|
-
console.log("2 => Group DMs & other DMs");
|
|
73
|
-
console.log("(comma separated, or 'all')");
|
|
74
|
-
const ctxInput = await this.requireInput("Contexts: ");
|
|
75
|
-
if (ctxInput.toLowerCase() === "all") {
|
|
76
|
-
config.contexts = [0, 1, 2];
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
config.contexts = ctxInput.split(",").map(i => parseInt(i.trim())).filter(i => !isNaN(i));
|
|
80
|
-
}
|
|
81
|
-
// 7. Guild IDs
|
|
82
|
-
console.clear();
|
|
83
|
-
console.log("đ 7/10 - Guild IDs (optional)");
|
|
84
|
-
console.log(" => Used to deploy specific context menu for specific guild");
|
|
85
|
-
const guildInput = await this.requireInput("Guild IDs (comma separated, or 'none'): ", (val) => {
|
|
86
|
-
if (!val || val.toLowerCase() === "none")
|
|
87
|
-
return true;
|
|
88
|
-
const ids = val.split(",").map(id => id.trim());
|
|
89
|
-
const invalidIds = ids.filter(id => !DiscordRegex_1.DiscordRegex.GUILD_ID.test(id));
|
|
90
|
-
if (invalidIds.length > 0) {
|
|
91
|
-
console.log(`â Invalid Guild IDs: ${invalidIds.join(', ')}`);
|
|
92
|
-
console.log("âšī¸ Discord Guild ID = 18 chiffres (ex: 1111160769132896377)");
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
console.log("â
Valid Guild IDs:", ids.join(', '));
|
|
96
|
-
return true;
|
|
97
|
-
}, true);
|
|
98
|
-
if (guildInput.toLowerCase() !== "none" && guildInput !== "") {
|
|
99
|
-
config.guildID = guildInput.split(",").map(id => id.trim());
|
|
100
|
-
}
|
|
101
|
-
// 8. Filename
|
|
102
|
-
console.clear();
|
|
103
|
-
console.log("đž 8/10 - File");
|
|
104
|
-
const filename = (await this.requireInput("Filename (ex: my-context-menu): ")) + ".json";
|
|
105
|
-
await this.saveFile(FolderName_1.FolderName.CONTEXT_MENU, filename, config);
|
|
106
|
-
return this.showMainMenu();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.ContextMenuGeneratorCLI = ContextMenuGeneratorCLI;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GenerationCLI = void 0;
|
|
4
|
-
const BaseCLI_1 = require("../BaseCLI");
|
|
5
|
-
const ContextMenuGeneratorCLI_1 = require("./ContextMenuGeneratorCLI");
|
|
6
|
-
const ModalGeneratorCLI_1 = require("./ModalGeneratorCLI");
|
|
7
|
-
const SlashCommandsGeneratorCLI_1 = require("./SlashCommandsGeneratorCLI");
|
|
8
|
-
class GenerationCLI extends BaseCLI_1.BaseCLI {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.menuSelection = [
|
|
12
|
-
{ label: 'Generate Slash Command Template', action: () => new SlashCommandsGeneratorCLI_1.SlashCommandGeneratorCLI(this) },
|
|
13
|
-
{ label: 'Generate Context Menu Template', action: () => new ContextMenuGeneratorCLI_1.ContextMenuGeneratorCLI(this) },
|
|
14
|
-
{ label: 'Generate Modal Template', action: () => new ModalGeneratorCLI_1.ModalGeneratorCLI(this) },
|
|
15
|
-
{ label: 'Back', action: () => this.goBack() },
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
getTitle() {
|
|
19
|
-
return 'âī¸ Generation Manager CLI';
|
|
20
|
-
}
|
|
21
|
-
async execute() {
|
|
22
|
-
throw new Error("Method not implemented.");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.GenerationCLI = GenerationCLI;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ModalBuilder } from "discord.js";
|
|
2
|
-
import { BaseCLI, MenuSelectionCLI } from "../BaseCLI";
|
|
3
|
-
export interface ModalCreateOption {
|
|
4
|
-
title: string;
|
|
5
|
-
customId: string;
|
|
6
|
-
label: string;
|
|
7
|
-
fields: ModalField[];
|
|
8
|
-
}
|
|
9
|
-
export interface ModalField {
|
|
10
|
-
title: string;
|
|
11
|
-
customId: string;
|
|
12
|
-
style: ModalFieldStyle;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
minLength?: number;
|
|
16
|
-
maxLength?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface SimpleModalCreateOption {
|
|
19
|
-
customId: string;
|
|
20
|
-
title: string;
|
|
21
|
-
label: string;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare enum ModalFieldStyle {
|
|
25
|
-
Short = 1,
|
|
26
|
-
Paragraph = 2,
|
|
27
|
-
Number = "Number",
|
|
28
|
-
Phone = "Phone",
|
|
29
|
-
Date = "Date"
|
|
30
|
-
}
|
|
31
|
-
export declare class ModalGeneratorCLI extends BaseCLI {
|
|
32
|
-
protected getTitle(): string;
|
|
33
|
-
protected readonly menuSelection: MenuSelectionCLI;
|
|
34
|
-
protected execute(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Create modal from declarative config - SIMPLE API !
|
|
37
|
-
*/
|
|
38
|
-
static create(options: ModalCreateOption): ModalBuilder;
|
|
39
|
-
private static buildInput;
|
|
40
|
-
/**
|
|
41
|
-
* Quick helpers
|
|
42
|
-
*/
|
|
43
|
-
static simple(option: SimpleModalCreateOption): ModalBuilder;
|
|
44
|
-
}
|