reciple 5.0.0-pre.4 → 5.0.0-pre.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/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
- 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')) {
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 : './reciple.yml').parseConfig();
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)}`);
@@ -41,7 +44,7 @@ const client = new RecipleClient_1.RecipleClient(Object.assign({ config: config
41
44
  if (config.fileLogging.clientLogs)
42
45
  client.logger.info('Reciple Client v' + version_1.rawVersion + ' is starting...');
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
- * Object interface for cooled-down user
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
- * Stores cooled-down users
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
- * Stores cooled-down users
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
- * @param options Validated options
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);
@@ -8,15 +8,15 @@ 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
- * options for Reciple client
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 object interface
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
- * Create new Reciple client
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 folder Modules folder
67
+ * @param folders List of folders that contains the modules you want to load
68
68
  */
69
- startModules(folder?: string): Promise<RecipleClient<Ready>>;
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,6 +8,9 @@ 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");
@@ -24,12 +27,14 @@ 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 folder Modules folder
54
+ * @param folders List of folders that contains the modules you want to load
50
55
  */
51
- startModules(folder) {
56
+ startModules(...folders) {
52
57
  return __awaiter(this, void 0, void 0, function* () {
53
- if (this.isClientLogsEnabled())
54
- this.logger.info(`Loading Modules from ${folder !== null && folder !== void 0 ? folder : this.config.modulesFolder}`);
55
- const modules = yield (0, modules_1.loadModules)(this, folder);
56
- if (!modules)
57
- throw new Error('Failed to load modules.');
58
- this.modules = modules.modules;
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
  }
@@ -49,7 +49,7 @@ export interface Config {
49
49
  [messageKey: string]: any;
50
50
  };
51
51
  ignoredFiles: string[];
52
- modulesFolder: string;
52
+ modulesFolder: string | string[];
53
53
  disableVersionCheck: boolean;
54
54
  version: string;
55
55
  }
@@ -19,7 +19,7 @@ class RecipleConfig {
19
19
  */
20
20
  constructor(configPath) {
21
21
  this.config = RecipleConfig.getDefaultConfig();
22
- this.configPath = './reciple.yml';
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, _b;
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)({ 'text': 'Bot Token >>> ', echo: '*', repeatIfEmpty: true, exitStrings: ['exit', 'quit', ''], sigint: true }) || null;
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,8 +1,8 @@
1
1
  import { CommandBuilderType, AnyCommandExecuteData, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
2
+ import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
2
3
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
3
4
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
4
5
  import { Command as CommandMessage } from 'fallout-utility';
5
- import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
6
6
  import { CommandHaltData } from '../../types/commands';
7
7
  import { RecipleClient } from '../RecipleClient';
8
8
  /**
@@ -26,7 +26,7 @@ export interface MessageCommandValidatedOption {
26
26
  missing: boolean;
27
27
  }
28
28
  /**
29
- * Message command halt data
29
+ * Halt data for message command
30
30
  */
31
31
  export declare type MessageCommandHaltData = CommandHaltData<CommandBuilderType.MessageCommand>;
32
32
  /**
@@ -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
  */
@@ -3,7 +3,7 @@ import { CommandHaltData } from '../../types/commands';
3
3
  import { RecipleClient } from '../RecipleClient';
4
4
  import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
5
5
  /**
6
- * Execute data for interaction command
6
+ * Execute data for slash command
7
7
  */
8
8
  export interface SlashCommandExecuteData {
9
9
  interaction: ChatInputCommandInteraction;
@@ -29,9 +29,9 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
29
29
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
30
30
  }
31
31
  /**
32
- * Reciple builder for interaction/slash command
32
+ * Reciple builder for slash command
33
33
  */
34
- export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties {
34
+ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties, SlashCommandBuilder {
35
35
  readonly type = CommandBuilderType.SlashCommand;
36
36
  cooldown: number;
37
37
  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 interaction/slash command
7
+ * Reciple builder for slash command
8
8
  */
9
9
  class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
10
10
  constructor() {
@@ -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
- * Temporary token flag
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;
@@ -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
- * Used flags
7
+ * Commander
8
8
  */
9
- exports.flags = new commander_1.Command()
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', 'Enabled debug mode')
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().opts();
19
+ .parse();
20
+ /**
21
+ * Used flags
22
+ */
23
+ exports.flags = exports.commander.opts();
19
24
  /**
20
- * Temporary token flag
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();
@@ -5,7 +5,7 @@ export declare type LoadedModules = {
5
5
  modules: RecipleModule[];
6
6
  };
7
7
  /**
8
- * Reciple script object interface
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 interface
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 loadModules(client: RecipleClient, folder?: string): Promise<LoadedModules>;
32
+ export declare function getModules(client: RecipleClient, folder?: string): Promise<LoadedModules>;
@@ -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.loadModules = void 0;
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"));
20
21
  const path_1 = __importDefault(require("path"));
21
- const discord_js_1 = require("discord.js");
22
+ const flags_1 = require("./flags");
22
23
  /**
23
24
  * Load modules from folder
24
25
  * @param client Reciple client
25
26
  * @param folder Modules folder
26
27
  */
27
- function loadModules(client, folder) {
28
- var _a, _b;
28
+ function getModules(client, folder) {
29
+ var _a;
29
30
  return __awaiter(this, void 0, void 0, function* () {
30
31
  const response = { commands: [], modules: [] };
31
- const modulesDir = client.config.modulesFolder || folder || './modules';
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,17 +37,17 @@ 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(process.cwd(), modulesDir, script);
40
+ const modulePath = path_1.default.join(modulesDir, script);
40
41
  const commands = [];
41
42
  let module_;
42
43
  try {
43
44
  const reqMod = require(modulePath);
44
- module_ = (reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) === undefined ? reqMod.default : reqMod;
45
- const versions = (0, discord_js_1.normalizeArray)([module_.versions]);
46
- if (!((_a = module_.versions) === null || _a === void 0 ? void 0 : _a.length))
45
+ module_ = (reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) !== undefined ? reqMod.default : reqMod;
46
+ if (!(module_ === null || module_ === void 0 ? void 0 : module_.versions.length))
47
47
  throw new Error(`${modulePath} does not have supported versions.`);
48
+ const versions = (0, discord_js_1.normalizeArray)([module_.versions]);
48
49
  if (!client.config.disableVersionCheck && !versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
49
- throw new Error((_b = `${modulePath} is unsupported; current version: ${version_1.version}; module supported versions: ` + versions.join(', ')) !== null && _b !== void 0 ? _b : 'none');
50
+ throw new Error((_a = `${modulePath} is unsupported; current version: ${version_1.version}; module supported versions: ` + versions.join(', ')) !== null && _a !== void 0 ? _a : 'none');
50
51
  if (!(yield Promise.resolve(module_.onStart(client)).catch(() => null)))
51
52
  throw new Error(script + ' onStart returned false or undefined.');
52
53
  if (module_.commands) {
@@ -81,7 +82,7 @@ function loadModules(client, folder) {
81
82
  script: module_,
82
83
  info: {
83
84
  filename: script,
84
- versions: (0, discord_js_1.normalizeArray)(module_.versions),
85
+ versions: (0, discord_js_1.normalizeArray)([module_.versions]),
85
86
  path: modulePath
86
87
  }
87
88
  });
@@ -91,4 +92,4 @@ function loadModules(client, folder) {
91
92
  return response;
92
93
  });
93
94
  }
94
- exports.loadModules = loadModules;
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 = typeof options.guilds == 'string' ? [options.guilds] : options.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,31 @@ 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 Reciple command builders
5
+ * Any command builders
6
6
  */
7
7
  export declare type AnyCommandBuilder = SlashCommandBuilder | MessageCommandBuilder;
8
8
  /**
9
- * Any Reciple command execute data
9
+ * Any command execute data
10
10
  */
11
11
  export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
12
12
  /**
13
- * Any Reciple command halt functions
13
+ * Any command halt functions
14
14
  */
15
15
  export declare type AnyCommandHaltFunction = SlashCommandHaltFunction | MessageCommandHaltFunction;
16
16
  /**
17
- * Any reciple command execute function
17
+ * Any command execute function
18
18
  */
19
19
  export declare type AnyCommandExecuteFunction = SlashCommandExecuteFunction | MessageCommandExecuteFunction;
20
20
  /**
21
- * Reciple command halt function
21
+ * command halt function
22
22
  */
23
23
  export declare type CommandHaltFunction<T extends CommandBuilderType> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData : MessageCommandHaltData) => Awaitable<boolean | null | undefined | void>;
24
24
  /**
25
- * Reciple command execute function
25
+ * command execute function
26
26
  */
27
27
  export declare type CommandExecuteFunction<T extends CommandBuilderType> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : MessageCommandExecuteData) => Awaitable<void>;
28
28
  /**
29
- * Types of Reciple command builders
29
+ * Types of command builders
30
30
  */
31
31
  export declare enum CommandBuilderType {
32
32
  MessageCommand = 0,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandBuilderType = void 0;
4
4
  /**
5
- * Types of Reciple command builders
5
+ * Types of command builders
6
6
  */
7
7
  var CommandBuilderType;
8
8
  (function (CommandBuilderType) {
@@ -4,15 +4,15 @@ import { MessageCommandOptionManager } from '../classes/MessageCommandOptionMana
4
4
  import { CommandBuilderType, AnyCommandExecuteData } from '../types/builders';
5
5
  import { CooledDownUser } from '../classes/CommandCooldownManager';
6
6
  /**
7
- * Any reciple halted command data
7
+ * Any command halt data
8
8
  */
9
9
  export declare type AnyCommandHaltData = SlashCommandHaltData | MessageCommandHaltData;
10
10
  /**
11
- * Halted command data
11
+ * command halt data
12
12
  */
13
13
  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
14
  /**
15
- * Command halt reason base interface
15
+ * Command halt reason base
16
16
  */
17
17
  export interface CommandHaltReasonBase<T extends CommandBuilderType> {
18
18
  executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData : AnyCommandExecuteData;
@@ -6,7 +6,7 @@ import { Config } from '../classes/RecipleConfig';
6
6
  import { AnyCommandBuilder } from './builders';
7
7
  export interface RecipleClientAddModuleOptions {
8
8
  /**
9
- * The Module script
9
+ * The module script
10
10
  */
11
11
  script: RecipleScript;
12
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "5.0.0-pre.4",
3
+ "version": "5.0.0-pre.7",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -23,8 +23,9 @@ commands:
23
23
  # enable overwriten command permissions
24
24
  enabled: false
25
25
  commands:
26
- - command: 'example-command'
27
- permissions: ['Administrator']
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: 'example-command'
49
- permissions: ['Administrator']
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: './logs/latest.log'
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
- - 'Guilds'
70
- - 'GuildMembers'
71
- - 'GuildMessages'
72
- - 'MessageContent'
71
+ - Guilds
72
+ - GuildMembers
73
+ - GuildMessages
74
+ - MessageContent
73
75
 
74
76
  # Bot messages
75
77
  messages:
76
- missingArguments: 'Not enough arguments.'
77
- invalidArguments: 'Invalid argument(s) given.'
78
+ missingArguments: Not enough arguments.
79
+ invalidArguments: Invalid argument(s) given.
78
80
  insufficientBotPerms:
79
- content: 'Insufficient bot permissions.'
81
+ content: Insufficient bot permissions.
80
82
  ephemeral: true
81
83
  noPermissions:
82
- content: 'You do not have permission to use this command.'
84
+ content: You do not have permission to use this command.
83
85
  ephemeral: true
84
86
  cooldown:
85
- content: 'You cannot execute this command right now due to the cooldown.'
87
+ content: You cannot execute this command right now due to the cooldown.
86
88
  ephemeral: true
87
89
  error:
88
- content: 'An error occurred.'
90
+ content: An error occurred.
89
91
  ephemeral: true
90
92
 
91
93
  # Ignored Files