reciple 4.0.0-pre.3 → 4.1.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 CHANGED
@@ -12,29 +12,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
14
  };
15
- var _a, _b, _c;
15
+ var _a, _b, _c, _d;
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const RecipleClient_1 = require("./reciple/classes/RecipleClient");
18
18
  const RecipleConfig_1 = require("./reciple/classes/RecipleConfig");
19
- const flags_1 = require("./reciple/flags");
20
19
  const version_1 = require("./reciple/version");
21
- const chalk_1 = __importDefault(require("chalk"));
22
- const fallout_utility_1 = require("fallout-utility");
23
20
  const fs_1 = require("fs");
21
+ const flags_1 = require("./reciple/flags");
22
+ const fallout_utility_1 = require("fallout-utility");
23
+ const chalk_1 = __importDefault(require("chalk"));
24
24
  require("dotenv/config");
25
- if (flags_1.flags.version) {
26
- console.log(`v${version_1.version}`);
27
- process.exit(0);
28
- }
29
25
  const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
30
26
  if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)((_a = flags_1.flags.config) !== null && _a !== void 0 ? _a : './reciple.yml')) {
31
- const ask = (_b = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _b !== void 0 ? _b : '';
27
+ 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 : '';
32
28
  if (ask.toString().toLowerCase() !== 'y')
33
29
  process.exit(0);
34
30
  }
35
31
  let configParser;
36
32
  try {
37
- configParser = new RecipleConfig_1.RecipleConfig((_c = flags_1.flags.config) !== null && _c !== void 0 ? _c : './reciple.yml').parseConfig();
33
+ configParser = new RecipleConfig_1.RecipleConfig((_d = flags_1.flags.config) !== null && _d !== void 0 ? _d : './reciple.yml').parseConfig();
38
34
  }
39
35
  catch (err) {
40
36
  console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
@@ -43,15 +39,18 @@ catch (err) {
43
39
  const config = configParser.getConfig();
44
40
  const client = new RecipleClient_1.RecipleClient(Object.assign({ config: config }, config.client));
45
41
  if (config.fileLogging.clientLogs)
46
- client.logger.info('Reciple Client v' + version_1.version + ' is starting...');
42
+ client.logger.info('Reciple Client v' + version_1.rawVersion + ' is starting...');
47
43
  (() => __awaiter(void 0, void 0, void 0, function* () {
48
44
  yield client.startModules();
49
45
  client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
50
- var _d;
46
+ var _e;
51
47
  if (client.isClientLogsEnabled())
52
- client.logger.warn(`Logged in as ${((_d = client.user) === null || _d === void 0 ? void 0 : _d.tag) || 'Unknown'}!`);
48
+ client.logger.warn(`Logged in as ${((_e = client.user) === null || _e === void 0 ? void 0 : _e.tag) || 'Unknown'}!`);
53
49
  yield client.loadModules();
54
50
  client.addCommandListeners();
55
51
  }));
56
- client.login(config.token);
52
+ client.login(config.token).catch(err => {
53
+ if (client.isClientLogsEnabled())
54
+ client.logger.error(err);
55
+ });
57
56
  }))();
package/bin/index.d.ts CHANGED
@@ -12,5 +12,5 @@ export * from './reciple/flags';
12
12
  export * from './reciple/logger';
13
13
  export * from './reciple/modules';
14
14
  export * from './reciple/permissions';
15
- export * from './reciple/registerInteractionCommands';
15
+ export * from './reciple/registerApplicationCommands';
16
16
  export * from './reciple/version';
package/bin/index.js CHANGED
@@ -28,5 +28,5 @@ __exportStar(require("./reciple/flags"), exports);
28
28
  __exportStar(require("./reciple/logger"), exports);
29
29
  __exportStar(require("./reciple/modules"), exports);
30
30
  __exportStar(require("./reciple/permissions"), exports);
31
- __exportStar(require("./reciple/registerInteractionCommands"), exports);
31
+ __exportStar(require("./reciple/registerApplicationCommands"), exports);
32
32
  __exportStar(require("./reciple/version"), exports);
@@ -1,5 +1,5 @@
1
- import { CommandBuilderType } from '../types/builders';
2
1
  import { Guild, TextBasedChannel, User } from 'discord.js';
2
+ import { CommandBuilderType } from '../types/builders';
3
3
  /**
4
4
  * Object interface for cooled-down user
5
5
  */
@@ -1,13 +1,13 @@
1
- import { RecipleModule } from '../modules';
2
- import { ApplicationCommandBuilder } from '../registerInteractionCommands';
3
- import { CommandBuilder, CommandBuilderType } from '../types/builders';
4
- import { RecipleClientAddModuleOptions } from '../types/paramOptions';
5
1
  import { MessageCommandBuilder, MessageCommandExecuteData } from './builders/MessageCommandBuilder';
2
+ import { ApplicationCommandBuilder } from '../registerApplicationCommands';
3
+ import { CommandBuilder, CommandBuilderType } from '../types/builders';
6
4
  import { SlashCommandBuilder, SlashCommandExecuteData } from './builders/SlashCommandBuilder';
7
5
  import { CommandCooldownManager } from './CommandCooldownManager';
6
+ import { RecipleClientAddModuleOptions } from '../types/paramOptions';
7
+ import { Logger as ILogger } from 'fallout-utility';
8
8
  import { Config } from './RecipleConfig';
9
+ import { RecipleModule } from '../modules';
9
10
  import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
10
- import { Logger as ILogger } from 'fallout-utility';
11
11
  /**
12
12
  * options for Reciple client
13
13
  */
@@ -49,9 +49,6 @@ export interface RecipleClient<Ready extends boolean = boolean> extends Client<R
49
49
  removeAllListeners(event?: string | symbol): this;
50
50
  isReady(): this is RecipleClient<true>;
51
51
  }
52
- /**
53
- * The reciple client
54
- */
55
52
  export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
56
53
  config: Config;
57
54
  commands: RecipleClientCommands;
@@ -10,23 +10,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RecipleClient = void 0;
13
- // Not cool code
14
- const logger_1 = require("../logger");
15
- const modules_1 = require("../modules");
13
+ const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
16
14
  const permissions_1 = require("../permissions");
17
- const registerInteractionCommands_1 = require("../registerInteractionCommands");
15
+ const registerApplicationCommands_1 = require("../registerApplicationCommands");
18
16
  const builders_1 = require("../types/builders");
19
- const commands_1 = require("../types/commands");
20
- const version_1 = require("../version");
21
- const MessageCommandBuilder_1 = require("./builders/MessageCommandBuilder");
22
17
  const CommandCooldownManager_1 = require("./CommandCooldownManager");
23
18
  const MessageCommandOptionManager_1 = require("./MessageCommandOptionManager");
19
+ const commands_1 = require("../types/commands");
20
+ const fallout_utility_1 = require("fallout-utility");
24
21
  const RecipleConfig_1 = require("./RecipleConfig");
22
+ const modules_1 = require("../modules");
23
+ const logger_1 = require("../logger");
24
+ const version_1 = require("../version");
25
25
  const discord_js_1 = require("discord.js");
26
- const fallout_utility_1 = require("fallout-utility");
27
- /**
28
- * The reciple client
29
- */
30
26
  class RecipleClient extends discord_js_1.Client {
31
27
  /**
32
28
  * @param options Client options
@@ -40,7 +36,7 @@ class RecipleClient extends discord_js_1.Client {
40
36
  this.commandCooldowns = new CommandCooldownManager_1.CommandCooldownManager();
41
37
  this.modules = [];
42
38
  this.version = version_1.version;
43
- this.logger = (0, logger_1.createLogger)(!!((_a = options.config) === null || _a === void 0 ? void 0 : _a.fileLogging.stringifyLoggedJSON), !!((_b = options.config) === null || _b === void 0 ? void 0 : _b.fileLogging.debugmode));
39
+ this.logger = (0, logger_1.createLogger)(!!((_a = options.config) === null || _a === void 0 ? void 0 : _a.fileLogging.stringifyLoggedJSON), (_b = options.config) === null || _b === void 0 ? void 0 : _b.fileLogging.debugmode);
44
40
  if (!options.config)
45
41
  throw new Error('Config is not defined.');
46
42
  this.config = Object.assign(Object.assign({}, this.config), ((_c = options.config) !== null && _c !== void 0 ? _c : {}));
@@ -92,7 +88,7 @@ class RecipleClient extends discord_js_1.Client {
92
88
  this.logger.info(`${Object.keys(this.commands.slashCommands).length} slash commands loaded.`);
93
89
  }
94
90
  if (this.config.commands.slashCommand.registerCommands) {
95
- yield (0, registerInteractionCommands_1.registerApplicationCommands)({
91
+ yield (0, registerApplicationCommands_1.registerApplicationCommands)({
96
92
  client: this,
97
93
  commands: [...Object.values(this.commands.slashCommands), ...this.otherApplicationCommandData],
98
94
  guilds: this.config.commands.slashCommand.guilds
@@ -125,7 +121,7 @@ class RecipleClient extends discord_js_1.Client {
125
121
  this.addCommand(command);
126
122
  }
127
123
  if (registerCommands)
128
- yield (0, registerInteractionCommands_1.registerApplicationCommands)({
124
+ yield (0, registerApplicationCommands_1.registerApplicationCommands)({
129
125
  client: this,
130
126
  commands: [...Object.values(this.commands.slashCommands), ...this.otherApplicationCommandData],
131
127
  guilds: this.config.commands.slashCommand.guilds
@@ -175,7 +171,7 @@ class RecipleClient extends discord_js_1.Client {
175
171
  const command = this.findCommand(parseCommand.command, builders_1.CommandBuilderType.MessageCommand);
176
172
  if (!command)
177
173
  return;
178
- const commandOptions = (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
174
+ const commandOptions = yield (0, MessageCommandBuilder_1.validateMessageCommandOptions)(command, parseCommand);
179
175
  const executeData = {
180
176
  message: message,
181
177
  options: commandOptions,
@@ -72,7 +72,7 @@ export declare class RecipleConfig {
72
72
  /**
73
73
  * Parse the config file
74
74
  */
75
- parseConfig(): RecipleConfig;
75
+ parseConfig(): this;
76
76
  /**
77
77
  * Returns the parsed config file
78
78
  */
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RecipleConfig = void 0;
7
- const flags_1 = require("../flags");
7
+ const fs_1 = require("fs");
8
8
  const version_1 = require("../version");
9
9
  const fallout_utility_1 = require("fallout-utility");
10
- const fs_1 = require("fs");
10
+ const flags_1 = require("../flags");
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const yaml_1 = __importDefault(require("yaml"));
13
13
  /**
@@ -1,10 +1,9 @@
1
- import { CommandBuilderType } from '../../types/builders';
2
- import { HaltedCommandData } from '../../types/commands';
1
+ import { CommandBuilderType, CommandExecuteFunction, CommandHaltFunction } from '../../types/builders';
3
2
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
4
- import { RecipleClient } from '../RecipleClient';
5
3
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
6
- import { Awaitable, Message, PermissionResolvable } from 'discord.js';
7
4
  import { Command as CommandMessage } from 'fallout-utility';
5
+ import { Message, PermissionResolvable } from 'discord.js';
6
+ import { RecipleClient } from '../RecipleClient';
8
7
  /**
9
8
  * Execute data for message command
10
9
  */
@@ -40,68 +39,68 @@ export declare class MessageCommandBuilder {
40
39
  requiredMemberPermissions: PermissionResolvable[];
41
40
  allowExecuteInDM: boolean;
42
41
  allowExecuteByBots: boolean;
43
- halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
44
- execute: (executeData: MessageCommandExecuteData) => void;
42
+ halt?: CommandHaltFunction<this>;
43
+ execute: CommandExecuteFunction<this>;
45
44
  /**
46
45
  * Sets the command name
47
46
  * @param name Command name
48
47
  */
49
- setName(name: string): MessageCommandBuilder;
48
+ setName(name: string): this;
50
49
  /**
51
50
  * Sets the command description
52
51
  * @param description Command description
53
52
  */
54
- setDescription(description: string): MessageCommandBuilder;
53
+ setDescription(description: string): this;
55
54
  /**
56
55
  * Sets the execute cooldown for this command.
57
56
  * - `0` means no cooldown
58
57
  * @param cooldown Command cooldown in milliseconds
59
58
  */
60
- setCooldown(cooldown: number): MessageCommandBuilder;
59
+ setCooldown(cooldown: number): this;
61
60
  /**
62
61
  * Add aliases to the command
63
62
  * @param aliases Command aliases
64
63
  */
65
- addAliases(...aliases: string[]): MessageCommandBuilder;
64
+ addAliases(...aliases: string[]): this;
66
65
  /**
67
66
  * Set required bot permissions to execute the command
68
67
  * @param permissions Bot's required permissions
69
68
  */
70
- setRequiredBotPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
69
+ setRequiredBotPermissions(...permissions: PermissionResolvable[]): this;
71
70
  /**
72
71
  * Set required permissions to execute the command
73
72
  * @param permissions User's return permissions
74
73
  */
75
- setRequiredMemberPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
74
+ setRequiredMemberPermissions(...permissions: PermissionResolvable[]): this;
76
75
  /**
77
76
  * Set if command can be executed in dms
78
77
  * @param allowExecuteInDM `true` if the command can execute in DMs
79
78
  */
80
- setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
79
+ setAllowExecuteInDM(allowExecuteInDM: boolean): this;
81
80
  /**
82
81
  * Allow command to be executed by bots
83
82
  * @param allowExecuteByBots `true` if the command can be executed by bots
84
83
  */
85
- setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
84
+ setAllowExecuteByBots(allowExecuteByBots: boolean): this;
86
85
  /**
87
86
  * Function when the command is interupted
88
87
  * @param halt Function to execute when command is halted
89
88
  */
90
- setHalt(halt?: (haltData: HaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
89
+ setHalt(halt?: CommandHaltFunction<this>): this;
91
90
  /**
92
91
  * Function when the command is executed
93
92
  * @param execute Function to execute when the command is called
94
93
  */
95
- setExecute(execute: (executeData: MessageCommandExecuteData) => void): MessageCommandBuilder;
94
+ setExecute(execute: CommandExecuteFunction<this>): this;
96
95
  /**
97
96
  * Add option to the command
98
97
  * @param option Message option builder
99
98
  */
100
- addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
99
+ addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): this;
101
100
  /**
102
101
  * Validate options before executing
103
102
  * @param validateOptions `true` if the command options needs to be validated before executing
104
103
  */
105
- setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
104
+ setValidateOptions(validateOptions: boolean): this;
106
105
  }
107
- export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): MessageCommandOptionManager;
106
+ export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): Promise<MessageCommandOptionManager>;
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
4
13
  const builders_1 = require("../../types/builders");
@@ -147,36 +156,38 @@ class MessageCommandBuilder {
147
156
  }
148
157
  exports.MessageCommandBuilder = MessageCommandBuilder;
149
158
  function validateMessageCommandOptions(builder, options) {
150
- const args = options.args || [];
151
- const required = builder.options.filter(o => o.required);
152
- const optional = builder.options.filter(o => !o.required);
153
- const allOptions = [...required, ...optional];
154
- const result = [];
155
- let i = 0;
156
- for (const option of allOptions) {
157
- const arg = args[i];
158
- const value = {
159
- name: option.name,
160
- value: arg !== null && arg !== void 0 ? arg : undefined,
161
- required: option.required,
162
- invalid: false,
163
- missing: false
164
- };
165
- if (arg == undefined && option.required) {
166
- value.missing = true;
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ const args = options.args || [];
161
+ const required = builder.options.filter(o => o.required);
162
+ const optional = builder.options.filter(o => !o.required);
163
+ const allOptions = [...required, ...optional];
164
+ const result = [];
165
+ let i = 0;
166
+ for (const option of allOptions) {
167
+ const arg = args[i];
168
+ const value = {
169
+ name: option.name,
170
+ value: arg !== null && arg !== void 0 ? arg : undefined,
171
+ required: option.required,
172
+ invalid: false,
173
+ missing: false
174
+ };
175
+ if (arg == undefined && option.required) {
176
+ value.missing = true;
177
+ result.push(value);
178
+ continue;
179
+ }
180
+ if (arg == undefined && !option.required) {
181
+ result.push(value);
182
+ continue;
183
+ }
184
+ const validate = option.validator ? yield Promise.resolve(option.validator(arg)) : true;
185
+ if (!validate)
186
+ value.invalid = true;
167
187
  result.push(value);
168
- continue;
188
+ i++;
169
189
  }
170
- if (arg == undefined && !option.required) {
171
- result.push(value);
172
- continue;
173
- }
174
- const validate = option.validator ? option.validator(arg) : true;
175
- if (!validate)
176
- value.invalid = true;
177
- result.push(value);
178
- i++;
179
- }
180
- return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
190
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
191
+ });
181
192
  }
182
193
  exports.validateMessageCommandOptions = validateMessageCommandOptions;
@@ -1,3 +1,4 @@
1
+ import { Awaitable } from 'discord.js';
1
2
  /**
2
3
  * Option builder for MessageCommandBuilder
3
4
  */
@@ -5,25 +6,25 @@ export declare class MessageCommandOptionBuilder {
5
6
  name: string;
6
7
  description: string;
7
8
  required: boolean;
8
- validator: (value: string) => boolean;
9
+ validator: (value: string) => Awaitable<boolean>;
9
10
  /**
10
11
  * Set command option name
11
12
  * @param name Option name
12
13
  */
13
- setName(name: string): MessageCommandOptionBuilder;
14
+ setName(name: string): this;
14
15
  /**
15
16
  * Set command option description
16
17
  * @param description Option description
17
18
  */
18
- setDescription(description: string): MessageCommandOptionBuilder;
19
+ setDescription(description: string): this;
19
20
  /**
20
21
  * Set if this option is required
21
22
  * @param required `true` if this option is required
22
23
  */
23
- setRequired(required: boolean): MessageCommandOptionBuilder;
24
+ setRequired(required: boolean): this;
24
25
  /**
25
26
  * Set your custom function to validate given value for this option
26
27
  * @param validator Custom function to validate value given for this option
27
28
  */
28
- setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
29
+ setValidator(validator: (value: string) => Awaitable<boolean>): this;
29
30
  }
@@ -1,7 +1,6 @@
1
- import { CommandBuilderType } from '../../types/builders';
2
- import { HaltedCommandData } from '../../types/commands';
1
+ import { CommandBuilderType, CommandExecuteFunction, CommandHaltFunction } from '../../types/builders';
3
2
  import { RecipleClient } from '../RecipleClient';
4
- import { Awaitable, ChatInputCommandInteraction, PermissionResolvable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
3
+ import { ChatInputCommandInteraction, PermissionResolvable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
5
4
  /**
6
5
  * Execute data for interaction command
7
6
  */
@@ -25,32 +24,32 @@ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
25
24
  requiredBotPermissions: PermissionResolvable[];
26
25
  requiredMemberPermissions: PermissionResolvable[];
27
26
  allowExecuteInDM: boolean;
28
- halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>;
29
- execute: (executeData: SlashCommandExecuteData) => Awaitable<void>;
27
+ halt?: CommandHaltFunction<this>;
28
+ execute: CommandExecuteFunction<this>;
30
29
  /**
31
30
  * Sets the execute cooldown for this command.
32
31
  * - `0` means no cooldown
33
32
  * @param cooldown Command cooldown in milliseconds
34
33
  */
35
- setCooldown(cooldown: number): SlashCommandBuilder;
34
+ setCooldown(cooldown: number): this;
36
35
  /**
37
36
  * Set required bot permissions to execute the command
38
37
  * @param permissions Bot's required permissions
39
38
  */
40
- setRequiredBotPermissions(...permissions: PermissionResolvable[]): SlashCommandBuilder;
39
+ setRequiredBotPermissions(...permissions: PermissionResolvable[]): this;
41
40
  /**
42
41
  * Set required permissions to execute the command
43
42
  * @param permissions User's return permissions
44
43
  */
45
- setRequiredMemberPermissions(...permissions: PermissionResolvable[]): SlashCommandBuilder;
44
+ setRequiredMemberPermissions(...permissions: PermissionResolvable[]): this;
46
45
  /**
47
46
  * Function when the command is interupted
48
47
  * @param halt Function to execute when command is halted
49
48
  */
50
- setHalt(halt?: (haltData: HaltedCommandData<SlashCommandBuilder>) => Awaitable<boolean | void>): SlashCommandBuilder;
49
+ setHalt(halt?: CommandHaltFunction<this>): this;
51
50
  /**
52
51
  * Function when the command is executed
53
52
  * @param execute Function to execute when the command is called
54
53
  */
55
- setExecute(execute: (executeData: SlashCommandExecuteData) => void): SlashCommandBuilder;
54
+ setExecute(execute: CommandExecuteFunction<this>): this;
56
55
  }
@@ -5,10 +5,14 @@ const commander_1 = require("commander");
5
5
  /**
6
6
  * Used flags
7
7
  */
8
- exports.flags = commander_1.program
8
+ exports.flags = new commander_1.Command()
9
+ .name('reciple')
10
+ .description('Reciple.js - Discord.js handler cli')
11
+ .version(`v${require('../../package.json').version}`, '-v, --version')
9
12
  .option('-t, --token <token>', 'Replace used bot token')
10
13
  .option('-c, --config <config>', 'Change path to config file')
11
14
  .option('-D, --debugmode', 'Enabled debug mode')
15
+ .option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
12
16
  .option('-v, --version', 'Display version')
13
17
  .parse().opts();
14
18
  /**
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createLogger = void 0;
7
+ const fallout_utility_1 = require("fallout-utility");
7
8
  const flags_1 = require("./flags");
8
9
  const chalk_1 = __importDefault(require("chalk"));
9
- const fallout_utility_1 = require("fallout-utility");
10
10
  /**
11
11
  * Create new logger
12
12
  * @param stringifyJSON stringify json objects in console
@@ -1,5 +1,5 @@
1
- import { RecipleClient } from './classes/RecipleClient';
2
1
  import { CommandBuilder } from './types/builders';
2
+ import { RecipleClient } from './classes/RecipleClient';
3
3
  export declare type LoadedModules = {
4
4
  commands: CommandBuilder[];
5
5
  modules: RecipleModule[];
@@ -16,8 +16,8 @@ exports.loadModules = void 0;
16
16
  const builders_1 = require("./types/builders");
17
17
  const version_1 = require("./version");
18
18
  const fs_1 = require("fs");
19
- const path_1 = __importDefault(require("path"));
20
19
  const wildcard_match_1 = __importDefault(require("wildcard-match"));
20
+ const path_1 = __importDefault(require("path"));
21
21
  /**
22
22
  * Load modules from folder
23
23
  * @param client Reciple client
@@ -1,6 +1,6 @@
1
- import { Config } from './classes/RecipleConfig';
2
1
  import { UserHasCommandPermissionsOptions } from './types/paramOptions';
3
2
  import { Guild, PermissionResolvable } from 'discord.js';
3
+ import { Config } from './classes/RecipleConfig';
4
4
  /**
5
5
  * Check if the user has permissions to execute the given command name
6
6
  * @param options options
@@ -1,6 +1,6 @@
1
+ import { ContextMenuCommandBuilder, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
1
2
  import { SlashCommandBuilder } from './classes/builders/SlashCommandBuilder';
2
3
  import { RegisterApplicationCommandsOptions } from './types/paramOptions';
3
- import { ContextMenuCommandBuilder, SlashCommandBuilder as DiscordJsSlashCommandBuilder } from 'discord.js';
4
4
  export declare type ApplicationCommandBuilder = SlashCommandBuilder | ContextMenuCommandBuilder | DiscordJsSlashCommandBuilder;
5
5
  /**
6
6
  * Register application commands
@@ -1,5 +1,7 @@
1
+ import { Awaitable } from 'discord.js';
1
2
  import { MessageCommandBuilder, MessageCommandExecuteData } from '../classes/builders/MessageCommandBuilder';
2
3
  import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builders/SlashCommandBuilder';
4
+ import { HaltedCommandData } from './commands';
3
5
  /**
4
6
  * Reciple command builders
5
7
  */
@@ -8,6 +10,14 @@ export declare type CommandBuilder = MessageCommandBuilder | SlashCommandBuilder
8
10
  * Reciple command builders execute data
9
11
  */
10
12
  export declare type CommandBuilderExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
13
+ /**
14
+ * Reciple command halt function
15
+ */
16
+ export declare type CommandHaltFunction<Builder extends CommandBuilder> = (haltData: HaltedCommandData<Builder>) => Awaitable<boolean | null | undefined | void>;
17
+ /**
18
+ * Reciple command execute function
19
+ */
20
+ export declare type CommandExecuteFunction<Builder extends CommandBuilder> = (executeData: Builder extends MessageCommandBuilder ? MessageCommandExecuteData : SlashCommandExecuteData) => Awaitable<void>;
11
21
  /**
12
22
  * Types of Reciple command builders
13
23
  */
@@ -1,7 +1,7 @@
1
1
  import { MessageCommandExecuteData } from '../classes/builders/MessageCommandBuilder';
2
2
  import { SlashCommandBuilder, SlashCommandExecuteData } from '../classes/builders/SlashCommandBuilder';
3
- import { CooledDownUser } from '../classes/CommandCooldownManager';
4
3
  import { MessageCommandOptionManager } from '../classes/MessageCommandOptionManager';
4
+ import { CooledDownUser } from '../classes/CommandCooldownManager';
5
5
  import { CommandBuilder } from '../types/builders';
6
6
  /**
7
7
  * Halted command's data
@@ -1,9 +1,9 @@
1
+ import { ApplicationCommandBuilder } from '../registerApplicationCommands';
2
+ import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
3
+ import { RecipleModule, RecipleScript } from '../modules';
1
4
  import { RecipleClient } from '../classes/RecipleClient';
2
5
  import { Config } from '../classes/RecipleConfig';
3
- import { RecipleModule, RecipleScript } from '../modules';
4
- import { ApplicationCommandBuilder } from '../registerInteractionCommands';
5
6
  import { CommandBuilder } from './builders';
6
- import { ApplicationCommandData, PermissionsBitField } from 'discord.js';
7
7
  export interface RecipleClientAddModuleOptions {
8
8
  /**
9
9
  * The Module script
@@ -3,6 +3,10 @@ import semver from 'semver';
3
3
  * Current reciple version
4
4
  */
5
5
  export declare const version: string;
6
+ /**
7
+ * Current reciple version from package.json
8
+ */
9
+ export declare const rawVersion: any;
6
10
  /**
7
11
  * Check if the version is valid
8
12
  * @param ver Version string to validated
@@ -3,12 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isSupportedVersion = exports.parseVersion = exports.isValidVersion = exports.version = void 0;
6
+ exports.isSupportedVersion = exports.parseVersion = exports.isValidVersion = exports.rawVersion = exports.version = void 0;
7
7
  const semver_1 = __importDefault(require("semver"));
8
8
  /**
9
9
  * Current reciple version
10
10
  */
11
11
  exports.version = `${semver_1.default.coerce(require('../../package.json').version)}`;
12
+ /**
13
+ * Current reciple version from package.json
14
+ */
15
+ exports.rawVersion = require('../../package.json').version;
12
16
  /**
13
17
  * Check if the version is valid
14
18
  * @param ver Version string to validated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "4.0.0-pre.3",
3
+ "version": "4.1.0",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -22,7 +22,7 @@
22
22
  "clean": "yarn exec rimraf bin",
23
23
  "build": "yarn clean && yarn exec tsc",
24
24
  "build:publish": "yarn build && yarn npm publish && yarn build:docs && yarn publish:docs",
25
- "build:pub-prerelease": "yarn build && yarn npm publish --tag pre",
25
+ "build:publish-prerelease": "yarn build && yarn npm publish --tag pre",
26
26
  "build:docs": "yarn exec typedoc --tsconfig ./docs/typedoc.json",
27
27
  "update:docs": "yarn workspace docs update",
28
28
  "test": "yarn build && yarn test:start",