reciple 5.4.1 → 5.4.4

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
@@ -1,18 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
5
  };
15
- var _a, _b, _c, _d;
16
6
  Object.defineProperty(exports, "__esModule", { value: true });
17
7
  const RecipleClient_1 = require("./reciple/classes/RecipleClient");
18
8
  const RecipleConfig_1 = require("./reciple/classes/RecipleConfig");
@@ -26,37 +16,36 @@ const discord_js_1 = require("discord.js");
26
16
  const path_1 = __importDefault(require("path"));
27
17
  const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
28
18
  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)) {
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 : '';
19
+ if ((0, fs_1.readdirSync)(flags_1.cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)(flags_1.flags.config ?? configPath)) {
20
+ const ask = (flags_1.flags.yes ? 'y' : null) ?? (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ') ?? '';
31
21
  if (ask.toString().toLowerCase() !== 'y')
32
22
  process.exit(0);
33
23
  }
34
24
  let configParser;
35
25
  try {
36
- configParser = new RecipleConfig_1.RecipleConfig((_d = flags_1.flags.config) !== null && _d !== void 0 ? _d : configPath).parseConfig();
26
+ configParser = new RecipleConfig_1.RecipleConfig(flags_1.flags.config ?? configPath).parseConfig();
37
27
  }
38
28
  catch (err) {
39
29
  console.error(`${chalk_1.default.bold.red('Config Error')}: ${chalk_1.default.white(err.message)}`);
40
30
  process.exit(1);
41
31
  }
42
32
  const config = configParser.getConfig();
43
- const client = new RecipleClient_1.RecipleClient(Object.assign({ config: config }, config.client));
33
+ const client = new RecipleClient_1.RecipleClient({ config: config, ...config.client });
44
34
  if (config.fileLogging.clientLogs)
45
35
  client.logger.info('Starting Reciple client v' + version_1.rawVersion);
46
- (() => __awaiter(void 0, void 0, void 0, function* () {
47
- yield client.startModules((0, discord_js_1.normalizeArray)(config.modulesFolder));
48
- client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
49
- var _e;
36
+ (async () => {
37
+ await client.startModules((0, discord_js_1.normalizeArray)(config.modulesFolder));
38
+ client.on('ready', async () => {
50
39
  if (client.isClientLogsEnabled())
51
- client.logger.warn(`Logged in as ${((_e = client.user) === null || _e === void 0 ? void 0 : _e.tag) || 'Unknown'}!`);
40
+ client.logger.warn(`Logged in as ${client.user?.tag || 'Unknown'}!`);
52
41
  client.on('cacheSweep', () => {
53
42
  client.cooldowns.clean();
54
43
  });
55
- yield client.loadModules();
44
+ await client.loadModules();
56
45
  client.addCommandListeners();
57
- }));
46
+ });
58
47
  client.login(config.token).catch(err => {
59
48
  if (client.isClientLogsEnabled())
60
49
  client.logger.error(err);
61
50
  });
62
- }))();
51
+ })();
@@ -44,7 +44,7 @@ class CommandCooldownManager extends Array {
44
44
  const data = this.get(options);
45
45
  if (!data)
46
46
  return false;
47
- this.remove(Object.assign(Object.assign({}, data), { channel: undefined, guild: undefined, type: undefined, command: undefined }));
47
+ this.remove({ ...data, channel: undefined, guild: undefined, type: undefined, command: undefined });
48
48
  if (data.expireTime < Date.now())
49
49
  return false;
50
50
  return true;
@@ -75,16 +75,15 @@ class CommandCooldownManager extends Array {
75
75
  * @param data Cooled-down user data
76
76
  */
77
77
  static checkOptions(options, data) {
78
- var _a, _b;
79
- if ((options === null || options === void 0 ? void 0 : options.user) && options.user.id !== data.user.id)
78
+ if (options?.user !== undefined && options.user.id !== data.user.id)
80
79
  return false;
81
- if ((options === null || options === void 0 ? void 0 : options.guild) && options.guild.id !== ((_a = data.guild) === null || _a === void 0 ? void 0 : _a.id))
80
+ if (options?.guild !== undefined && options.guild?.id !== data.guild?.id)
82
81
  return false;
83
- if ((options === null || options === void 0 ? void 0 : options.channel) && options.channel.id !== ((_b = data.channel) === null || _b === void 0 ? void 0 : _b.id))
82
+ if (options?.channel !== undefined && options.channel.id !== data.channel?.id)
84
83
  return false;
85
- if ((options === null || options === void 0 ? void 0 : options.command) && options.command !== data.command)
84
+ if (options?.command !== undefined && options.command !== data.command)
86
85
  return false;
87
- if ((options === null || options === void 0 ? void 0 : options.type) && options.type !== data.type)
86
+ if (options?.type !== undefined && options.type !== data.type)
88
87
  return false;
89
88
  return true;
90
89
  }
@@ -11,16 +11,15 @@ class MessageCommandOptionManager extends Array {
11
11
  }
12
12
  get(name, required) {
13
13
  const option = this.find(o => o.name == name);
14
- if (!(option === null || option === void 0 ? void 0 : option.value) == undefined && required)
14
+ if (!option?.value == undefined && required)
15
15
  throw new TypeError(`Can't find option named ${name}`);
16
- return option !== null && option !== void 0 ? option : null;
16
+ return option ?? null;
17
17
  }
18
18
  getValue(name, requied) {
19
- var _a;
20
19
  const option = this.get(name, requied);
21
- if (!(option === null || option === void 0 ? void 0 : option.value) && requied)
20
+ if (!option?.value && requied)
22
21
  throw new TypeError(`Value of option named ${name} is undefined`);
23
- return (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : null;
22
+ return option?.value ?? null;
24
23
  }
25
24
  }
26
25
  exports.MessageCommandOptionManager = MessageCommandOptionManager;
@@ -39,13 +39,13 @@ export interface RecipleClientEvents extends ClientEvents {
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;
42
- on<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
42
+ on<E extends string | symbol>(event: E, listener: (...args: any) => Awaitable<void>): this;
43
43
  once<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
44
- once<E extends keyof string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
44
+ once<E extends keyof string | symbol>(event: E, listener: (...args: any) => Awaitable<void>): this;
45
45
  emit<E extends keyof RecipleClientEvents>(event: E, ...args: RecipleClientEvents[E]): boolean;
46
- emit<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, ...args: any): boolean;
46
+ emit<E extends string | symbol>(event: E, ...args: any): boolean;
47
47
  off<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
48
- off<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
48
+ off<E extends string | symbol>(event: E, listener: (...args: any) => Awaitable<void>): this;
49
49
  removeAllListeners<E extends keyof RecipleClientEvents>(event?: E): this;
50
50
  removeAllListeners(event?: string | symbol): this;
51
51
  isReady(): this is RecipleClient<true>;