reciple 1.2.0 → 1.3.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.
@@ -47,6 +47,7 @@ export interface Config {
47
47
  messages: {
48
48
  [key: string]: any;
49
49
  };
50
+ ignoredFiles: string[];
50
51
  modulesFolder: string;
51
52
  version: string;
52
53
  }
@@ -1,5 +1,5 @@
1
1
  import { SlashCommandBuilder } from '@discordjs/builders';
2
- import { CommandInteraction, PermissionFlags } from 'discord.js';
2
+ import { CommandInteraction, PermissionFlags, PermissionString } from 'discord.js';
3
3
  import { RecipleClient } from '../Client';
4
4
  export interface RecipleInteractionCommandExecute {
5
5
  interaction: CommandInteraction;
@@ -9,7 +9,7 @@ export interface RecipleInteractionCommandExecute {
9
9
  }
10
10
  export declare class InteractionCommandBuilder extends SlashCommandBuilder {
11
11
  readonly builder: string;
12
- requiredPermissions: (keyof PermissionFlags)[];
12
+ requiredPermissions: (PermissionFlags | PermissionString)[];
13
13
  allowExecuteInDM: boolean;
14
14
  execute: (options: RecipleInteractionCommandExecute) => void;
15
15
  setRequiredPermissions(requiredPermissions: (keyof PermissionFlags)[]): InteractionCommandBuilder;
@@ -8,7 +8,7 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
8
8
  this.builder = 'INTERACTION_COMMAND';
9
9
  this.requiredPermissions = [];
10
10
  this.allowExecuteInDM = true;
11
- this.execute = (options) => { };
11
+ this.execute = () => { };
12
12
  }
13
13
  setRequiredPermissions(requiredPermissions) {
14
14
  if (!requiredPermissions || !Array.isArray(requiredPermissions))
@@ -44,7 +44,7 @@ class MessageCommandBuilder {
44
44
  this.requiredPermissions = [];
45
45
  this.allowExecuteInDM = true;
46
46
  this.allowExecuteByBots = false;
47
- this.execute = (options) => { };
47
+ this.execute = () => { };
48
48
  }
49
49
  setName(name) {
50
50
  if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
@@ -9,8 +9,8 @@ export declare type loadedModules = {
9
9
  export interface RecipleScript {
10
10
  versions: string | string[];
11
11
  commands?: (MessageCommandBuilder | InteractionCommandBuilder)[];
12
- onLoad?: (reciple: RecipleClient) => void | Promise<void>;
13
- onStart: (reciple: RecipleClient) => boolean | Promise<boolean>;
12
+ onLoad?: (reciple: RecipleClient) => (void | Promise<void>);
13
+ onStart: (reciple: RecipleClient) => (boolean | Promise<boolean>);
14
14
  }
15
15
  export interface RecipleModule {
16
16
  script: RecipleScript;
@@ -17,14 +17,17 @@ const fs_1 = require("fs");
17
17
  const version_1 = require("./version");
18
18
  const path_1 = __importDefault(require("path"));
19
19
  function loadModules(client) {
20
- var _a, _b;
20
+ var _a, _b, _c;
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  const response = { commands: [], modules: [] };
23
23
  const modulesDir = ((_a = client.config) === null || _a === void 0 ? void 0 : _a.modulesFolder) || './modules';
24
24
  const logger = client.logger;
25
25
  if (!(0, fs_1.existsSync)(modulesDir))
26
26
  (0, fs_1.mkdirSync)(modulesDir, { recursive: true });
27
- const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')));
27
+ const ignoredFiles = (((_b = client.config) === null || _b === void 0 ? void 0 : _b.ignoredFiles) || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
28
+ const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
29
+ return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.includes(file);
30
+ });
28
31
  for (const script of scripts) {
29
32
  const modulePath = path_1.default.resolve(modulesDir, script);
30
33
  const commands = [];
@@ -32,7 +35,7 @@ function loadModules(client) {
32
35
  try {
33
36
  const reqMod = require(modulePath);
34
37
  module_ = !!(reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) ? reqMod.default : reqMod;
35
- if (!((_b = module_.versions) === null || _b === void 0 ? void 0 : _b.length))
38
+ if (!((_c = module_.versions) === null || _c === void 0 ? void 0 : _c.length))
36
39
  throw new Error('Module does not have supported versions.');
37
40
  const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
38
41
  if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
@@ -19,7 +19,7 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
19
19
  const cmd = c;
20
20
  if ((cmd === null || cmd === void 0 ? void 0 : cmd.builder) === 'INTERACTION_COMMAND' && ((_a = client.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.setRequiredPermissions)) {
21
21
  const permissions = (_g = (((_c = (_b = client.config) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.interactionCommands.enabled) ?
22
- (_f = (_e = (_d = client.config) === null || _d === void 0 ? void 0 : _d.permissions) === null || _e === void 0 ? void 0 : _e.interactionCommands.commands.find(c => c.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
22
+ (_f = (_e = (_d = client.config) === null || _d === void 0 ? void 0 : _d.permissions) === null || _e === void 0 ? void 0 : _e.interactionCommands.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
23
23
  undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
24
24
  cmd.setRequiredPermissions(permissions);
25
25
  client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
@@ -5,4 +5,4 @@ export declare function parseVersion(ver: string): {
5
5
  minor: number;
6
6
  patch: number;
7
7
  };
8
- export declare function isSupportedVersion(ver: string, supportedVersion?: string): boolean;
8
+ export declare function isSupportedVersion(versionRange: string, supportedVersion?: string): boolean;
@@ -1,38 +1,29 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.isSupportedVersion = exports.parseVersion = exports.validVersion = exports.version = void 0;
4
- const fallout_utility_1 = require("fallout-utility");
7
+ const semver_1 = __importDefault(require("semver"));
5
8
  exports.version = require('../../package.json').version;
6
9
  function validVersion(ver) {
7
- if (!ver || typeof ver !== 'string' || ver.split('.').length < 3)
8
- return false;
9
- const [major, minor, patch] = ver.split('.');
10
- if (!(0, fallout_utility_1.isNumber)(major) || !(0, fallout_utility_1.isNumber)(minor) || !(0, fallout_utility_1.isNumber)(patch))
11
- return false;
12
- return true;
10
+ return semver_1.default.valid(semver_1.default.coerce(ver)) !== null;
13
11
  }
14
12
  exports.validVersion = validVersion;
15
13
  function parseVersion(ver) {
14
+ var _a, _b;
16
15
  if (!validVersion(ver))
17
16
  throw new TypeError(`Invalid version: ${ver}`);
18
- const [major, minor, patch] = ver.split('.');
17
+ const [major, minor, patch] = (_b = (_a = `${semver_1.default.coerce(ver)}`) === null || _a === void 0 ? void 0 : _a.split('.')) !== null && _b !== void 0 ? _b : [];
19
18
  return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
20
19
  }
21
20
  exports.parseVersion = parseVersion;
22
- function isSupportedVersion(ver, supportedVersion) {
21
+ function isSupportedVersion(versionRange, supportedVersion) {
23
22
  supportedVersion = supportedVersion || exports.version;
24
- if (!validVersion(ver))
25
- throw new TypeError(`Invalid version: ${ver}`);
23
+ if (!validVersion(versionRange))
24
+ throw new TypeError(`Invalid version: ${versionRange}`);
26
25
  if (!validVersion(supportedVersion))
27
26
  throw new TypeError(`Invalid supported version: ${supportedVersion}`);
28
- const { major, minor, patch } = parseVersion(ver);
29
- const { major: supportedMajor, minor: supportedMinor, patch: supportedPatch } = parseVersion(supportedVersion);
30
- if (major !== supportedMajor)
31
- return false;
32
- if (minor !== supportedMinor)
33
- return false;
34
- if (patch > supportedPatch)
35
- return false;
36
- return true;
27
+ return semver_1.default.satisfies(supportedVersion, versionRange);
37
28
  }
38
29
  exports.isSupportedVersion = isSupportedVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A Discord.js bot",
5
5
  "author": "FalloutStudios",
6
6
  "license": "GPL-3.0",
@@ -21,20 +21,20 @@
21
21
  "compile": "yarn clean && tsc",
22
22
  "build": "yarn compile && npm un reciple -g && npm i ./ -g",
23
23
  "build:publish": "yarn run build && yarn run changelog && yarn publish",
24
- "changelog": "changelog generate",
25
24
  "test": "cd test && reciple",
26
- "test:compile": "yarn run build && yarn test:run"
25
+ "test:build": "yarn run build && yarn test:run"
27
26
  },
28
27
  "dependencies": {
29
28
  "commander": "^9.2.0",
30
29
  "discord.js": "^13.7.0",
31
30
  "dotenv": "^16.0.1",
32
31
  "fallout-utility": "^1.3.14",
32
+ "semver": "^7.3.7",
33
33
  "yaml": "^2.1.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^17.0.35",
37
- "generate-changelog": "^1.8.0",
37
+ "@types/semver": "^7.3.9",
38
38
  "typescript": "^4.6.4"
39
39
  }
40
40
  }
@@ -85,6 +85,10 @@ messages:
85
85
  content: 'An error occurred.'
86
86
  ephemeral: true
87
87
 
88
+ # Ignored Files
89
+ ignoredFiles:
90
+ - 'test.js'
91
+
88
92
 
89
93
  ###################################################
90
94
  # #
package/CHANGELOG.md DELETED
@@ -1,28 +0,0 @@
1
- #### 1.2.0 (2022-05-21)
2
-
3
- ##### New Features
4
-
5
- * **permissions:** you can now set required permissions for interaction command (3a80154f)
6
-
7
- ##### Refactors
8
-
9
- * **permissions:** some changes to message command required permissions (22a01ae3)
10
-
11
- #### 1.2.0 (2022-05-21)
12
-
13
- ##### New Features
14
-
15
- * **permissions:** you can now set required permissions for interaction command (3a80154f)
16
-
17
- ##### Refactors
18
-
19
- * **permissions:** some changes to message command required permissions (22a01ae3)
20
-
21
- #### 1.1.6 (2022-05-21)
22
-
23
- ##### Bug Fixes
24
-
25
- * **interactionCommands:** Interaction commands error (55a29d74)
26
-
27
- #### 1.1.5 (2022-05-21)
28
-