reciple 5.0.0-pre.5 → 5.0.0
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/bin/bin.js +7 -4
- package/bin/reciple/classes/CommandCooldownManager.d.ts +4 -3
- package/bin/reciple/classes/CommandCooldownManager.js +5 -1
- package/bin/reciple/classes/MessageCommandOptionManager.d.ts +2 -4
- package/bin/reciple/classes/MessageCommandOptionManager.js +3 -5
- package/bin/reciple/classes/RecipleClient.d.ts +8 -8
- package/bin/reciple/classes/RecipleClient.js +23 -12
- package/bin/reciple/classes/RecipleConfig.d.ts +1 -1
- package/bin/reciple/classes/RecipleConfig.js +5 -10
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +5 -7
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +1 -1
- package/bin/reciple/classes/builders/SlashCommandBuilder.d.ts +6 -8
- package/bin/reciple/classes/builders/SlashCommandBuilder.js +1 -1
- package/bin/reciple/flags.d.ts +10 -1
- package/bin/reciple/flags.js +15 -6
- package/bin/reciple/modules.d.ts +3 -3
- package/bin/reciple/modules.js +7 -6
- package/bin/reciple/registerApplicationCommands.js +2 -1
- package/bin/reciple/types/builders.d.ts +6 -10
- package/bin/reciple/types/builders.js +1 -1
- package/bin/reciple/types/commands.d.ts +22 -11
- package/bin/reciple/types/paramOptions.d.ts +1 -1
- package/package.json +2 -1
- package/resource/reciple.yml +17 -15
package/bin/bin.js
CHANGED
|
@@ -22,15 +22,18 @@ const flags_1 = require("./reciple/flags");
|
|
|
22
22
|
const fallout_utility_1 = require("fallout-utility");
|
|
23
23
|
const chalk_1 = __importDefault(require("chalk"));
|
|
24
24
|
require("dotenv/config");
|
|
25
|
+
const discord_js_1 = require("discord.js");
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
25
27
|
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
|
|
26
|
-
|
|
28
|
+
const configPath = path_1.default.join(flags_1.cwd, './reciple.yml');
|
|
29
|
+
if ((0, fs_1.readdirSync)(flags_1.cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)((_a = flags_1.flags.config) !== null && _a !== void 0 ? _a : configPath)) {
|
|
27
30
|
const ask = (_c = (_b = (flags_1.flags.yes ? 'y' : null)) !== null && _b !== void 0 ? _b : (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _c !== void 0 ? _c : '';
|
|
28
31
|
if (ask.toString().toLowerCase() !== 'y')
|
|
29
32
|
process.exit(0);
|
|
30
33
|
}
|
|
31
34
|
let configParser;
|
|
32
35
|
try {
|
|
33
|
-
configParser = new RecipleConfig_1.RecipleConfig((_d = flags_1.flags.config) !== null && _d !== void 0 ? _d :
|
|
36
|
+
configParser = new RecipleConfig_1.RecipleConfig((_d = flags_1.flags.config) !== null && _d !== void 0 ? _d : configPath).parseConfig();
|
|
34
37
|
}
|
|
35
38
|
catch (err) {
|
|
36
39
|
console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
|
|
@@ -39,9 +42,9 @@ catch (err) {
|
|
|
39
42
|
const config = configParser.getConfig();
|
|
40
43
|
const client = new RecipleClient_1.RecipleClient(Object.assign({ config: config }, config.client));
|
|
41
44
|
if (config.fileLogging.clientLogs)
|
|
42
|
-
client.logger.info('Reciple
|
|
45
|
+
client.logger.info('Starting Reciple client v' + version_1.rawVersion);
|
|
43
46
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
yield client.startModules();
|
|
47
|
+
yield client.startModules((0, discord_js_1.normalizeArray)(config.modulesFolder));
|
|
45
48
|
client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
49
|
var _e;
|
|
47
50
|
if (client.isClientLogsEnabled())
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Guild, TextBasedChannel, User } from 'discord.js';
|
|
1
|
+
import { Guild, RestOrArray, TextBasedChannel, User } from 'discord.js';
|
|
2
2
|
import { CommandBuilderType } from '../types/builders';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cooled-down user object interface
|
|
5
5
|
*/
|
|
6
6
|
export interface CooledDownUser {
|
|
7
7
|
user: User;
|
|
@@ -12,9 +12,10 @@ export interface CooledDownUser {
|
|
|
12
12
|
expireTime: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* cooled-down users manager
|
|
16
16
|
*/
|
|
17
17
|
export declare class CommandCooldownManager extends Array<CooledDownUser> {
|
|
18
|
+
constructor(...data: RestOrArray<CooledDownUser>);
|
|
18
19
|
/**
|
|
19
20
|
* Alias for `CommandCooldownManager#push()`
|
|
20
21
|
* @param options Cooled-down user data
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandCooldownManager = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* cooled-down users manager
|
|
6
7
|
*/
|
|
7
8
|
class CommandCooldownManager extends Array {
|
|
9
|
+
constructor(...data) {
|
|
10
|
+
super(...(0, discord_js_1.normalizeArray)(data));
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* Alias for `CommandCooldownManager#push()`
|
|
10
14
|
* @param options Cooled-down user data
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { MessageCommandValidatedOption } from './builders/MessageCommandBuilder';
|
|
2
|
+
import { RestOrArray } from 'discord.js';
|
|
2
3
|
/**
|
|
3
4
|
* Validated message options manager
|
|
4
5
|
*/
|
|
5
6
|
export declare class MessageCommandOptionManager extends Array<MessageCommandValidatedOption> {
|
|
6
|
-
|
|
7
|
-
* @param options Validated options
|
|
8
|
-
*/
|
|
9
|
-
constructor(...options: MessageCommandValidatedOption[]);
|
|
7
|
+
constructor(...data: RestOrArray<MessageCommandValidatedOption>);
|
|
10
8
|
/**
|
|
11
9
|
* Get the option info
|
|
12
10
|
* @param name Option name
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MessageCommandOptionManager = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
4
5
|
/**
|
|
5
6
|
* Validated message options manager
|
|
6
7
|
*/
|
|
7
8
|
class MessageCommandOptionManager extends Array {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
constructor(...options) {
|
|
12
|
-
super(...(options !== null && options !== void 0 ? options : []));
|
|
9
|
+
constructor(...data) {
|
|
10
|
+
super(...(0, discord_js_1.normalizeArray)(data));
|
|
13
11
|
}
|
|
14
12
|
get(name, required) {
|
|
15
13
|
const option = this.find(o => o.name == name);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { MessageCommandBuilder, MessageCommandExecuteData } from './builders/MessageCommandBuilder';
|
|
2
2
|
import { SlashCommandBuilder, SlashCommandExecuteData } from './builders/SlashCommandBuilder';
|
|
3
3
|
import { ApplicationCommandBuilder } from '../registerApplicationCommands';
|
|
4
|
-
import {
|
|
4
|
+
import { AnyCommandExecuteData, AnyCommandHaltData } from '../types/commands';
|
|
5
5
|
import { CommandCooldownManager } from './CommandCooldownManager';
|
|
6
|
-
import {
|
|
6
|
+
import { AnyCommandBuilder, CommandBuilderType } from '../types/builders';
|
|
7
7
|
import { RecipleClientAddModuleOptions } from '../types/paramOptions';
|
|
8
8
|
import { Logger as ILogger } from 'fallout-utility';
|
|
9
9
|
import { Config } from './RecipleConfig';
|
|
10
10
|
import { RecipleModule } from '../modules';
|
|
11
|
-
import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
11
|
+
import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message, RestOrArray } from 'discord.js';
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Options for Reciple client
|
|
14
14
|
*/
|
|
15
15
|
export interface RecipleClientOptions extends ClientOptions {
|
|
16
16
|
config?: Config;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Reciple client commands
|
|
19
|
+
* Reciple client commands
|
|
20
20
|
*/
|
|
21
21
|
export interface RecipleClientCommands {
|
|
22
22
|
slashCommands: {
|
|
@@ -35,7 +35,7 @@ export interface RecipleClientEvents extends ClientEvents {
|
|
|
35
35
|
recipleReplyError: [error: unknown];
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Reciple client
|
|
39
39
|
*/
|
|
40
40
|
export interface RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
41
41
|
on<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
@@ -64,9 +64,9 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
64
64
|
constructor(options: RecipleClientOptions);
|
|
65
65
|
/**
|
|
66
66
|
* Load modules from modules folder
|
|
67
|
-
* @param
|
|
67
|
+
* @param folders List of folders that contains the modules you want to load
|
|
68
68
|
*/
|
|
69
|
-
startModules(
|
|
69
|
+
startModules(...folders: RestOrArray<string>): Promise<RecipleClient<Ready>>;
|
|
70
70
|
/**
|
|
71
71
|
* Execute `onLoad()` from client modules and register application commands if enabled
|
|
72
72
|
*/
|
|
@@ -8,28 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.RecipleClient = void 0;
|
|
13
16
|
const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
|
|
14
17
|
const SlashCommandBuilder_1 = require("./builders/SlashCommandBuilder");
|
|
15
18
|
const registerApplicationCommands_1 = require("../registerApplicationCommands");
|
|
16
|
-
const
|
|
19
|
+
const commands_1 = require("../types/commands");
|
|
17
20
|
const permissions_1 = require("../permissions");
|
|
18
21
|
const CommandCooldownManager_1 = require("./CommandCooldownManager");
|
|
19
22
|
const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
|
|
20
|
-
const
|
|
23
|
+
const builders_1 = require("../types/builders");
|
|
21
24
|
const fallout_utility_1 = require("fallout-utility");
|
|
22
25
|
const RecipleConfig_1 = require("./RecipleConfig");
|
|
23
26
|
const modules_1 = require("../modules");
|
|
24
27
|
const logger_1 = require("../logger");
|
|
25
28
|
const version_1 = require("../version");
|
|
26
29
|
const discord_js_1 = require("discord.js");
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const flags_1 = require("../flags");
|
|
27
32
|
class RecipleClient extends discord_js_1.Client {
|
|
28
33
|
/**
|
|
29
34
|
* @param options Client options
|
|
30
35
|
*/
|
|
31
36
|
constructor(options) {
|
|
32
|
-
var _a, _b, _c;
|
|
37
|
+
var _a, _b, _c, _d;
|
|
33
38
|
super(options);
|
|
34
39
|
this.config = RecipleConfig_1.RecipleConfig.getDefaultConfig();
|
|
35
40
|
this.commands = { slashCommands: {}, messageCommands: {} };
|
|
@@ -42,20 +47,26 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
42
47
|
throw new Error('Config is not defined.');
|
|
43
48
|
this.config = Object.assign(Object.assign({}, this.config), ((_c = options.config) !== null && _c !== void 0 ? _c : {}));
|
|
44
49
|
if (this.config.fileLogging.enabled)
|
|
45
|
-
this.logger.logFile(this.config.fileLogging.logFilePath, false);
|
|
50
|
+
this.logger.logFile(path_1.default.join(flags_1.cwd, (_d = this.config.fileLogging.logFilePath) !== null && _d !== void 0 ? _d : 'logs/latest.log'), false);
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* Load modules from modules folder
|
|
49
|
-
* @param
|
|
54
|
+
* @param folders List of folders that contains the modules you want to load
|
|
50
55
|
*/
|
|
51
|
-
startModules(
|
|
56
|
+
startModules(...folders) {
|
|
52
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
folders = (0, discord_js_1.normalizeArray)(folders).map(f => path_1.default.join(flags_1.cwd, f));
|
|
59
|
+
for (const folder of folders) {
|
|
60
|
+
if (this.isClientLogsEnabled())
|
|
61
|
+
this.logger.info(`Loading Modules from ${folder}`);
|
|
62
|
+
const modules = yield (0, modules_1.getModules)(this, folder).catch(() => null);
|
|
63
|
+
if (!modules) {
|
|
64
|
+
if (this.isClientLogsEnabled())
|
|
65
|
+
this.logger.error(`Failed to load modules from ${folder}`);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
this.modules = modules.modules;
|
|
69
|
+
}
|
|
59
70
|
return this;
|
|
60
71
|
});
|
|
61
72
|
}
|
|
@@ -19,7 +19,7 @@ class RecipleConfig {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor(configPath) {
|
|
21
21
|
this.config = RecipleConfig.getDefaultConfig();
|
|
22
|
-
this.configPath = '
|
|
22
|
+
this.configPath = path_1.default.join(flags_1.cwd, 'reciple.yml');
|
|
23
23
|
if (!configPath)
|
|
24
24
|
throw new Error('Config path is not defined');
|
|
25
25
|
this.configPath = configPath;
|
|
@@ -66,15 +66,10 @@ class RecipleConfig {
|
|
|
66
66
|
* @param askIfNull Ask for token if the token is null/undefined
|
|
67
67
|
*/
|
|
68
68
|
parseToken(askIfNull = true) {
|
|
69
|
-
var _a
|
|
70
|
-
let token = flags_1.token || null;
|
|
71
|
-
if (!this.config && !token)
|
|
72
|
-
return token;
|
|
73
|
-
if (this.config && !((_a = this.config) === null || _a === void 0 ? void 0 : _a.token) && !token)
|
|
74
|
-
return token || (askIfNull ? this.askToken() : null);
|
|
75
|
-
token = token || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.token) || null;
|
|
69
|
+
var _a;
|
|
70
|
+
let token = flags_1.token || ((_a = this.config) === null || _a === void 0 ? void 0 : _a.token) || null;
|
|
76
71
|
if (!token)
|
|
77
|
-
return token;
|
|
72
|
+
return token || (askIfNull ? this.askToken() : null);
|
|
78
73
|
const envToken = token.toString().split(':');
|
|
79
74
|
if (envToken.length === 2 && envToken[0].toLocaleLowerCase() === 'env' && envToken[1]) {
|
|
80
75
|
token = process.env[envToken[1]] || null;
|
|
@@ -92,7 +87,7 @@ class RecipleConfig {
|
|
|
92
87
|
* Ask for a token
|
|
93
88
|
*/
|
|
94
89
|
askToken() {
|
|
95
|
-
return flags_1.token || (0, fallout_utility_1.input)({
|
|
90
|
+
return flags_1.token || (0, fallout_utility_1.input)({ text: 'Bot Token >>> ', echo: '*', repeatIfEmpty: true, sigint: true }) || null;
|
|
96
91
|
}
|
|
97
92
|
/**
|
|
98
93
|
* Get default config
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { CommandBuilderType,
|
|
1
|
+
import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
|
|
2
|
+
import { AnyCommandExecuteData, BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
|
|
3
|
+
import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
|
|
2
4
|
import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
|
|
3
5
|
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
4
6
|
import { Command as CommandMessage } from 'fallout-utility';
|
|
5
|
-
import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
|
|
6
|
-
import { CommandHaltData } from '../../types/commands';
|
|
7
|
-
import { RecipleClient } from '../RecipleClient';
|
|
8
7
|
/**
|
|
9
8
|
* Execute data for message command
|
|
10
9
|
*/
|
|
11
|
-
export interface MessageCommandExecuteData {
|
|
10
|
+
export interface MessageCommandExecuteData extends BaseCommandExecuteData {
|
|
12
11
|
message: Message;
|
|
13
12
|
options: MessageCommandOptionManager;
|
|
14
13
|
command: CommandMessage;
|
|
15
14
|
builder: MessageCommandBuilder;
|
|
16
|
-
client: RecipleClient<true>;
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* Validated message command option
|
|
@@ -26,7 +24,7 @@ export interface MessageCommandValidatedOption {
|
|
|
26
24
|
missing: boolean;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
27
|
+
* Halt data for message command
|
|
30
28
|
*/
|
|
31
29
|
export declare type MessageCommandHaltData = CommandHaltData<CommandBuilderType.MessageCommand>;
|
|
32
30
|
/**
|
|
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
|
|
13
13
|
const builders_1 = require("../../types/builders");
|
|
14
|
+
const discord_js_1 = require("discord.js");
|
|
14
15
|
const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
|
|
15
16
|
const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
|
|
16
|
-
const discord_js_1 = require("discord.js");
|
|
17
17
|
/**
|
|
18
18
|
* Reciple builder for message command
|
|
19
19
|
*/
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { CommandBuilderType,
|
|
2
|
-
import { CommandHaltData } from '../../types/commands';
|
|
3
|
-
import { RecipleClient } from '../RecipleClient';
|
|
1
|
+
import { CommandBuilderType, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
|
|
2
|
+
import { AnyCommandExecuteData, BaseCommandExecuteData, CommandHaltData } from '../../types/commands';
|
|
4
3
|
import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
|
|
5
4
|
/**
|
|
6
|
-
* Execute data for
|
|
5
|
+
* Execute data for slash command
|
|
7
6
|
*/
|
|
8
|
-
export interface SlashCommandExecuteData {
|
|
7
|
+
export interface SlashCommandExecuteData extends BaseCommandExecuteData {
|
|
9
8
|
interaction: ChatInputCommandInteraction;
|
|
10
9
|
builder: SlashCommandBuilder;
|
|
11
|
-
client: RecipleClient<true>;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* Slash command halt data
|
|
@@ -29,9 +27,9 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
|
|
|
29
27
|
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
|
-
* Reciple builder for
|
|
30
|
+
* Reciple builder for slash command
|
|
33
31
|
*/
|
|
34
|
-
export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties {
|
|
32
|
+
export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties, SlashCommandBuilder {
|
|
35
33
|
readonly type = CommandBuilderType.SlashCommand;
|
|
36
34
|
cooldown: number;
|
|
37
35
|
requiredBotPermissions: PermissionResolvable[];
|
|
@@ -4,7 +4,7 @@ exports.SlashCommandBuilder = void 0;
|
|
|
4
4
|
const builders_1 = require("../../types/builders");
|
|
5
5
|
const discord_js_1 = require("discord.js");
|
|
6
6
|
/**
|
|
7
|
-
* Reciple builder for
|
|
7
|
+
* Reciple builder for slash command
|
|
8
8
|
*/
|
|
9
9
|
class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
10
10
|
constructor() {
|
package/bin/reciple/flags.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Commander
|
|
4
|
+
*/
|
|
5
|
+
export declare const commander: Command;
|
|
1
6
|
/**
|
|
2
7
|
* Used flags
|
|
3
8
|
*/
|
|
4
9
|
export declare const flags: import("commander").OptionValues;
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Token flag
|
|
7
12
|
*/
|
|
8
13
|
export declare const token: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Current working directory
|
|
16
|
+
*/
|
|
17
|
+
export declare const cwd: string;
|
package/bin/reciple/flags.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.token = exports.flags = void 0;
|
|
3
|
+
exports.cwd = exports.token = exports.flags = exports.commander = void 0;
|
|
4
4
|
const version_1 = require("./version");
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Commander
|
|
8
8
|
*/
|
|
9
|
-
exports.
|
|
9
|
+
exports.commander = new commander_1.Command()
|
|
10
10
|
.name('reciple')
|
|
11
11
|
.description('Reciple.js - Discord.js handler cli')
|
|
12
12
|
.version(`v${version_1.rawVersion}`, '-v, --version')
|
|
13
|
+
.argument('[current-working-directory]', 'Change the current working directory')
|
|
13
14
|
.option('-t, --token <token>', 'Replace used bot token')
|
|
14
15
|
.option('-c, --config <config>', 'Change path to config file')
|
|
15
|
-
.option('-D, --debugmode', '
|
|
16
|
+
.option('-D, --debugmode', 'Enable debug mode')
|
|
16
17
|
.option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
|
|
17
18
|
.option('-v, --version', 'Display version')
|
|
18
|
-
.parse()
|
|
19
|
+
.parse();
|
|
20
|
+
/**
|
|
21
|
+
* Used flags
|
|
22
|
+
*/
|
|
23
|
+
exports.flags = exports.commander.opts();
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
25
|
+
* Token flag
|
|
21
26
|
*/
|
|
22
27
|
exports.token = exports.flags.token;
|
|
28
|
+
/**
|
|
29
|
+
* Current working directory
|
|
30
|
+
*/
|
|
31
|
+
exports.cwd = exports.commander.args[0] || process.cwd();
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare type LoadedModules = {
|
|
|
5
5
|
modules: RecipleModule[];
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Reciple script object
|
|
8
|
+
* Reciple script object
|
|
9
9
|
*/
|
|
10
10
|
export interface RecipleScript {
|
|
11
11
|
versions: string | string[];
|
|
@@ -14,7 +14,7 @@ export interface RecipleScript {
|
|
|
14
14
|
onStart(reciple: RecipleClient): boolean | Promise<boolean>;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Reciple module object
|
|
17
|
+
* Reciple module object
|
|
18
18
|
*/
|
|
19
19
|
export interface RecipleModule {
|
|
20
20
|
script: RecipleScript;
|
|
@@ -29,4 +29,4 @@ export interface RecipleModule {
|
|
|
29
29
|
* @param client Reciple client
|
|
30
30
|
* @param folder Modules folder
|
|
31
31
|
*/
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function getModules(client: RecipleClient, folder?: string): Promise<LoadedModules>;
|
package/bin/reciple/modules.js
CHANGED
|
@@ -12,23 +12,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.getModules = void 0;
|
|
16
16
|
const builders_1 = require("./types/builders");
|
|
17
|
+
const discord_js_1 = require("discord.js");
|
|
17
18
|
const version_1 = require("./version");
|
|
18
19
|
const fs_1 = require("fs");
|
|
19
20
|
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
21
|
+
const flags_1 = require("./flags");
|
|
20
22
|
const path_1 = __importDefault(require("path"));
|
|
21
|
-
const discord_js_1 = require("discord.js");
|
|
22
23
|
/**
|
|
23
24
|
* Load modules from folder
|
|
24
25
|
* @param client Reciple client
|
|
25
26
|
* @param folder Modules folder
|
|
26
27
|
*/
|
|
27
|
-
function
|
|
28
|
+
function getModules(client, folder) {
|
|
28
29
|
var _a;
|
|
29
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
31
|
const response = { commands: [], modules: [] };
|
|
31
|
-
const modulesDir =
|
|
32
|
+
const modulesDir = folder || path_1.default.join(flags_1.cwd, 'modules');
|
|
32
33
|
if (!(0, fs_1.existsSync)(modulesDir))
|
|
33
34
|
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
34
35
|
const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
|
|
@@ -36,7 +37,7 @@ function loadModules(client, folder) {
|
|
|
36
37
|
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
|
|
37
38
|
});
|
|
38
39
|
for (const script of scripts) {
|
|
39
|
-
const modulePath = path_1.default.join(
|
|
40
|
+
const modulePath = path_1.default.join(modulesDir, script);
|
|
40
41
|
const commands = [];
|
|
41
42
|
let module_;
|
|
42
43
|
try {
|
|
@@ -91,4 +92,4 @@ function loadModules(client, folder) {
|
|
|
91
92
|
return response;
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
|
-
exports.
|
|
95
|
+
exports.getModules = getModules;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerApplicationCommands = void 0;
|
|
13
|
+
const discord_js_1 = require("discord.js");
|
|
13
14
|
const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
|
|
14
15
|
/**
|
|
15
16
|
* Register application commands
|
|
@@ -19,7 +20,7 @@ function registerApplicationCommands(options) {
|
|
|
19
20
|
var _a, _b, _c, _d;
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
const client = options.client;
|
|
22
|
-
const guilds =
|
|
23
|
+
const guilds = (0, discord_js_1.normalizeArray)(options.guilds);
|
|
23
24
|
const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.slashCommands).map(cmd => {
|
|
24
25
|
var _a;
|
|
25
26
|
if (typeof (cmd === null || cmd === void 0 ? void 0 : cmd.toJSON) == 'undefined')
|
|
@@ -2,31 +2,27 @@ import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecute
|
|
|
2
2
|
import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction } from '../classes/builders/SlashCommandBuilder';
|
|
3
3
|
import { Awaitable, PermissionResolvable, RestOrArray } from 'discord.js';
|
|
4
4
|
/**
|
|
5
|
-
* Any
|
|
5
|
+
* Any command builders
|
|
6
6
|
*/
|
|
7
7
|
export declare type AnyCommandBuilder = SlashCommandBuilder | MessageCommandBuilder;
|
|
8
8
|
/**
|
|
9
|
-
* Any
|
|
10
|
-
*/
|
|
11
|
-
export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
|
|
12
|
-
/**
|
|
13
|
-
* Any Reciple command halt functions
|
|
9
|
+
* Any command halt functions
|
|
14
10
|
*/
|
|
15
11
|
export declare type AnyCommandHaltFunction = SlashCommandHaltFunction | MessageCommandHaltFunction;
|
|
16
12
|
/**
|
|
17
|
-
* Any
|
|
13
|
+
* Any command execute function
|
|
18
14
|
*/
|
|
19
15
|
export declare type AnyCommandExecuteFunction = SlashCommandExecuteFunction | MessageCommandExecuteFunction;
|
|
20
16
|
/**
|
|
21
|
-
*
|
|
17
|
+
* command halt function
|
|
22
18
|
*/
|
|
23
19
|
export declare type CommandHaltFunction<T extends CommandBuilderType> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData : MessageCommandHaltData) => Awaitable<boolean | null | undefined | void>;
|
|
24
20
|
/**
|
|
25
|
-
*
|
|
21
|
+
* command execute function
|
|
26
22
|
*/
|
|
27
23
|
export declare type CommandExecuteFunction<T extends CommandBuilderType> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : MessageCommandExecuteData) => Awaitable<void>;
|
|
28
24
|
/**
|
|
29
|
-
* Types of
|
|
25
|
+
* Types of command builders
|
|
30
26
|
*/
|
|
31
27
|
export declare enum CommandBuilderType {
|
|
32
28
|
MessageCommand = 0,
|
|
@@ -1,41 +1,52 @@
|
|
|
1
1
|
import { MessageCommandExecuteData, MessageCommandHaltData } from '../classes/builders/MessageCommandBuilder';
|
|
2
2
|
import { SlashCommandExecuteData, SlashCommandHaltData } from '../classes/builders/SlashCommandBuilder';
|
|
3
3
|
import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
|
|
4
|
-
import { CommandBuilderType, AnyCommandExecuteData } from '../types/builders';
|
|
5
4
|
import { CooledDownUser } from '../classes/CommandCooldownManager';
|
|
5
|
+
import { RecipleClient } from '../classes/RecipleClient';
|
|
6
|
+
import { CommandBuilderType } from '../types/builders';
|
|
6
7
|
/**
|
|
7
|
-
* Any
|
|
8
|
+
* Any command halt data
|
|
8
9
|
*/
|
|
9
10
|
export declare type AnyCommandHaltData = SlashCommandHaltData | MessageCommandHaltData;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
+
* command halt data
|
|
12
13
|
*/
|
|
13
14
|
export declare type CommandHaltData<T extends CommandBuilderType> = CommandErrorData<T> | CommandCooldownData<T> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T> | CommandMissingArguments<T>) | CommandMissingMemberPermissions<T> | CommandMissingBotPermissions<T>;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Any command execute data
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
+
export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
|
|
19
|
+
/**
|
|
20
|
+
* Command execute data
|
|
21
|
+
*/
|
|
22
|
+
export interface BaseCommandExecuteData {
|
|
23
|
+
client: RecipleClient<true>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Command halt reason base
|
|
27
|
+
*/
|
|
28
|
+
export interface BaseCommandHaltData<T extends CommandBuilderType> {
|
|
18
29
|
executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData : AnyCommandExecuteData;
|
|
19
30
|
}
|
|
20
|
-
export interface CommandErrorData<T extends CommandBuilderType> extends
|
|
31
|
+
export interface CommandErrorData<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
21
32
|
reason: CommandHaltReason.Error;
|
|
22
33
|
error: any;
|
|
23
34
|
}
|
|
24
|
-
export interface CommandCooldownData<T extends CommandBuilderType> extends
|
|
35
|
+
export interface CommandCooldownData<T extends CommandBuilderType> extends BaseCommandHaltData<T>, CooledDownUser {
|
|
25
36
|
reason: CommandHaltReason.Cooldown;
|
|
26
37
|
}
|
|
27
|
-
export interface CommandInvalidArguments<T extends CommandBuilderType> extends
|
|
38
|
+
export interface CommandInvalidArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
28
39
|
reason: CommandHaltReason.InvalidArguments;
|
|
29
40
|
invalidArguments: MessageCommandOptionManager;
|
|
30
41
|
}
|
|
31
|
-
export interface CommandMissingArguments<T extends CommandBuilderType> extends
|
|
42
|
+
export interface CommandMissingArguments<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
32
43
|
reason: CommandHaltReason.MissingArguments;
|
|
33
44
|
missingArguments: MessageCommandOptionManager;
|
|
34
45
|
}
|
|
35
|
-
export interface CommandMissingMemberPermissions<T extends CommandBuilderType> extends
|
|
46
|
+
export interface CommandMissingMemberPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
36
47
|
reason: CommandHaltReason.MissingMemberPermissions;
|
|
37
48
|
}
|
|
38
|
-
export interface CommandMissingBotPermissions<T extends CommandBuilderType> extends
|
|
49
|
+
export interface CommandMissingBotPermissions<T extends CommandBuilderType> extends BaseCommandHaltData<T> {
|
|
39
50
|
reason: CommandHaltReason.MissingBotPermissions;
|
|
40
51
|
}
|
|
41
52
|
/**
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"bin": "bin/bin.js",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "bin/index.js",
|
|
7
|
+
"typings": "bin/index.d.ts",
|
|
7
8
|
"author": "FalloutStudios",
|
|
8
9
|
"description": "Handler for Discord.js",
|
|
9
10
|
"homepage": "https://reciple.js.org",
|
package/resource/reciple.yml
CHANGED
|
@@ -23,8 +23,9 @@ commands:
|
|
|
23
23
|
# enable overwriten command permissions
|
|
24
24
|
enabled: false
|
|
25
25
|
commands:
|
|
26
|
-
- command:
|
|
27
|
-
permissions:
|
|
26
|
+
- command: example-command
|
|
27
|
+
permissions:
|
|
28
|
+
- Administrator
|
|
28
29
|
|
|
29
30
|
# Interaction command options
|
|
30
31
|
slashCommand:
|
|
@@ -45,8 +46,9 @@ commands:
|
|
|
45
46
|
# enable overwriten command permissions
|
|
46
47
|
enabled: false
|
|
47
48
|
commands:
|
|
48
|
-
- command:
|
|
49
|
-
permissions:
|
|
49
|
+
- command: example-command
|
|
50
|
+
permissions:
|
|
51
|
+
- Administrator
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
# Logger options
|
|
@@ -60,32 +62,32 @@ fileLogging:
|
|
|
60
62
|
# stringify logged JSONs
|
|
61
63
|
stringifyLoggedJSON: false
|
|
62
64
|
# log file path
|
|
63
|
-
logFilePath:
|
|
65
|
+
logFilePath: logs/latest.log
|
|
64
66
|
|
|
65
67
|
# Client options
|
|
66
68
|
# Learn more about client options at https://discord.js.org/#/docs/discord.js/main/typedef/ClientOptions
|
|
67
69
|
client:
|
|
68
70
|
intents:
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
71
|
+
- Guilds
|
|
72
|
+
- GuildMembers
|
|
73
|
+
- GuildMessages
|
|
74
|
+
- MessageContent
|
|
73
75
|
|
|
74
76
|
# Bot messages
|
|
75
77
|
messages:
|
|
76
|
-
missingArguments:
|
|
77
|
-
invalidArguments:
|
|
78
|
+
missingArguments: Not enough arguments.
|
|
79
|
+
invalidArguments: Invalid argument(s) given.
|
|
78
80
|
insufficientBotPerms:
|
|
79
|
-
content:
|
|
81
|
+
content: Insufficient bot permissions.
|
|
80
82
|
ephemeral: true
|
|
81
83
|
noPermissions:
|
|
82
|
-
content:
|
|
84
|
+
content: You do not have permission to use this command.
|
|
83
85
|
ephemeral: true
|
|
84
86
|
cooldown:
|
|
85
|
-
content:
|
|
87
|
+
content: You cannot execute this command right now due to the cooldown.
|
|
86
88
|
ephemeral: true
|
|
87
89
|
error:
|
|
88
|
-
content:
|
|
90
|
+
content: An error occurred.
|
|
89
91
|
ephemeral: true
|
|
90
92
|
|
|
91
93
|
# Ignored Files
|