reciple 4.0.0-pre.2 → 4.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 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
  */
@@ -6,7 +6,7 @@ export declare class MessageCommandOptionManager extends Array<MessageCommandVal
6
6
  /**
7
7
  * @param options Validated options
8
8
  */
9
- constructor(options: MessageCommandValidatedOption[]);
9
+ constructor(...options: MessageCommandValidatedOption[]);
10
10
  /**
11
11
  * Get the option info
12
12
  * @param name Option name
@@ -8,9 +8,8 @@ class MessageCommandOptionManager extends Array {
8
8
  /**
9
9
  * @param options Validated options
10
10
  */
11
- constructor(options) {
12
- super();
13
- this.push(...options);
11
+ constructor(...options) {
12
+ super(...(options !== null && options !== void 0 ? options : []));
14
13
  }
15
14
  get(name, required) {
16
15
  const option = this.find(o => o.name == name);
@@ -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
@@ -195,13 +191,13 @@ class RecipleClient extends discord_js_1.Client {
195
191
  return;
196
192
  if (command.validateOptions) {
197
193
  if (commandOptions.some(o => o.invalid)) {
198
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.invalid)) }))) {
194
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.InvalidArguments, invalidArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.invalid)) }))) {
199
195
  message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this._replyError(er));
200
196
  }
201
197
  return;
202
198
  }
203
199
  if (commandOptions.some(o => o.missing)) {
204
- if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(executeData.options.filter(o => o.missing)) }))) {
200
+ if (!(yield this._haltCommand(command, { executeData, reason: commands_1.HaltedCommandReason.MissingArguments, missingArguments: new MessageCommandOptionManager_1.MessageCommandOptionManager(...executeData.options.filter(o => o.missing)) }))) {
205
201
  message.reply(this.getMessage('missingArguments', 'Not enough arguments.')).catch(er => this._replyError(er));
206
202
  }
207
203
  return;
@@ -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,10 @@
1
- import { CommandBuilderType } from '../../types/builders';
2
- import { HaltedCommandData } from '../../types/commands';
3
1
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
4
- import { RecipleClient } from '../RecipleClient';
5
2
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
6
3
  import { Awaitable, Message, PermissionResolvable } from 'discord.js';
7
4
  import { Command as CommandMessage } from 'fallout-utility';
5
+ import { CommandBuilderType } from '../../types/builders';
6
+ import { HaltedCommandData } from '../../types/commands';
7
+ import { RecipleClient } from '../RecipleClient';
8
8
  /**
9
9
  * Execute data for message command
10
10
  */
@@ -103,11 +103,5 @@ export declare class MessageCommandBuilder {
103
103
  * @param validateOptions `true` if the command options needs to be validated before executing
104
104
  */
105
105
  setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
106
- /**
107
- * validate given command options
108
- * @deprecated use `validateMessageCommandOptions()` instead
109
- * @param options Parsed message command data
110
- */
111
- getCommandOptionValues(options: CommandMessage): MessageCommandOptionManager;
112
106
  }
113
107
  export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): MessageCommandOptionManager;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
4
- const builders_1 = require("../../types/builders");
5
4
  const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
6
5
  const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
6
+ const builders_1 = require("../../types/builders");
7
7
  /**
8
8
  * Reciple builder for message command
9
9
  */
@@ -144,15 +144,6 @@ class MessageCommandBuilder {
144
144
  this.validateOptions = validateOptions;
145
145
  return this;
146
146
  }
147
- /**
148
- * validate given command options
149
- * @deprecated use `validateMessageCommandOptions()` instead
150
- * @param options Parsed message command data
151
- */
152
- // TODO: Remove this on the next major update
153
- getCommandOptionValues(options) {
154
- return validateMessageCommandOptions(this, options);
155
- }
156
147
  }
157
148
  exports.MessageCommandBuilder = MessageCommandBuilder;
158
149
  function validateMessageCommandOptions(builder, options) {
@@ -186,6 +177,6 @@ function validateMessageCommandOptions(builder, options) {
186
177
  result.push(value);
187
178
  i++;
188
179
  }
189
- return new MessageCommandOptionManager_1.MessageCommandOptionManager(result);
180
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(...result);
190
181
  }
191
182
  exports.validateMessageCommandOptions = validateMessageCommandOptions;
@@ -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,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.2",
3
+ "version": "4.0.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",