reciple 1.1.2 → 1.1.5

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/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ #### 1.1.4 (2022-05-21)
2
+
3
+ ##### New Features
4
+
5
+ * **version.ts:** Version checking functions (491b97b2)
6
+ * **registerinteractions:** You can now overwrite guilds in register interactions (422fe8ad)
7
+
8
+ ##### Bug Fixes
9
+
10
+ * **modules:** fix module loading version check (c3c2ad94)
11
+ * **versions:** Fixed checking supported version (4220ea96)
12
+ * **scripts:** Fixed changelog when deleting non existing file (cafdfe47)
13
+
14
+ ##### Other Changes
15
+
16
+ * **changelog:** Don't delete current changelog (29c49362)
17
+ * **dependencies:** Updated dev dependency (8b4a131c)
18
+
19
+ ##### Refactors
20
+
21
+ * **versions:** supported versions made backwards compatible (addf514a)
22
+ * **modules:** Check if module is supported (d79fbd49)
23
+ * **Config.ts:** Checks if version is supported (83bae35b)
24
+ * **modules.ts:** import default when available (cdad52e9)
25
+ * **ignoredfiles:** Ignore rmm files (55760c0e)
26
+
27
+ #### 1.1.4 (2022-05-21)
28
+
29
+ ##### New Features
30
+
31
+ * **version.ts:** Version checking functions (491b97b2)
32
+ * **registerinteractions:** You can now overwrite guilds in register interactions (422fe8ad)
33
+
34
+ ##### Bug Fixes
35
+
36
+ * **modules:** fix module loading version check (c3c2ad94)
37
+ * **versions:** Fixed checking supported version (4220ea96)
38
+ * **scripts:** Fixed changelog when deleting non existing file (cafdfe47)
39
+
40
+ ##### Other Changes
41
+
42
+ * **changelog:** Don't delete current changelog (29c49362)
43
+ * **dependencies:** Updated dev dependency (8b4a131c)
44
+
45
+ ##### Refactors
46
+
47
+ * **modules:** Check if module is supported (d79fbd49)
48
+ * **Config.ts:** Checks if version is supported (83bae35b)
49
+ * **modules.ts:** import default when available (cdad52e9)
50
+ * **ignoredfiles:** Ignore rmm files (55760c0e)
51
+
52
+ #### 1.1.4 (2022-05-20)
53
+
54
+ ##### New Features
55
+
56
+ * **version.ts:** Version checking functions (491b97b2)
57
+ * **registerinteractions:** You can now overwrite guilds in register interactions (422fe8ad)
58
+
59
+ ##### Bug Fixes
60
+
61
+ * **scripts:** Fixed changelog when deleting non existing file (cafdfe47)
62
+
63
+ ##### Other Changes
64
+
65
+ * **dependencies:** Updated dev dependency (8b4a131c)
66
+
67
+ ##### Refactors
68
+
69
+ * **modules.ts:** import default when available (cdad52e9)
70
+ * **ignoredfiles:** Ignore rmm files (55760c0e)
71
+
package/bin/bin.js CHANGED
@@ -15,7 +15,7 @@ const Client_1 = require("./reciple/classes/Client");
15
15
  const fs_1 = require("fs");
16
16
  const fallout_utility_1 = require("fallout-utility");
17
17
  require("dotenv/config");
18
- const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json'];
18
+ const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json', 'modules.yml', '.rmmcache'];
19
19
  if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
20
20
  const ask = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ');
21
21
  if (ask !== 'y')
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
+ // Dear precious programmer,
3
+ // If you're trying to understand this code, please, consider that
4
+ // at the time of writing this code, It was written the way humans
5
+ // can understand it but I transformed into a dog at Apr 12th 2022
6
+ // and accidentally made it unreadable for humans. So, if you're
7
+ // trying to understand this code, please, consider being a dog first.
2
8
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
9
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
10
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -1,4 +1,4 @@
1
- import { ClientOptions, InteractionReplyOptions, MessageOptions, PermissionResolvable } from 'discord.js';
1
+ import { ClientOptions, PermissionResolvable } from 'discord.js';
2
2
  export interface Config {
3
3
  token: string;
4
4
  prefix: string;
@@ -44,10 +44,10 @@ export interface Config {
44
44
  };
45
45
  client: ClientOptions;
46
46
  messages: {
47
- [key: string]: MessageOptions | InteractionReplyOptions | string;
47
+ [key: string]: any;
48
48
  };
49
49
  modulesFolder: string;
50
- version?: string;
50
+ version: string;
51
51
  }
52
52
  export declare class RecipleConfig {
53
53
  config?: Config;
@@ -67,7 +67,7 @@ class RecipleConfig {
67
67
  }
68
68
  isSupportedConfig() {
69
69
  var _a;
70
- return (((_a = this.config) === null || _a === void 0 ? void 0 : _a.version) && this.config.version != version_1.version) ? false : true;
70
+ return (0, version_1.isSupportedVersion)(((_a = this.config) === null || _a === void 0 ? void 0 : _a.version) || '0.0.0', version_1.version);
71
71
  }
72
72
  askToken() {
73
73
  return flags_1.token || (0, fallout_utility_1.input)({ 'text': 'Bot Token >>> ', echo: '*', repeatIfEmpty: true, exitStrings: ['exit', 'quit', ''], sigint: true }) || null;
@@ -1,13 +1,7 @@
1
1
  import { Message, PermissionFlags } from 'discord.js';
2
2
  import { Command } from 'fallout-utility';
3
3
  import { RecipleClient } from '../Client';
4
- export interface CommandMessage extends Command {
5
- command?: string;
6
- args?: string[];
7
- raw?: string;
8
- prefix?: string;
9
- separator?: string;
10
- }
4
+ export declare type CommandMessage = Command;
11
5
  export interface RecipleMessageCommandExecute {
12
6
  message: Message;
13
7
  command: CommandMessage;
@@ -14,9 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.loadModules = void 0;
16
16
  const fs_1 = require("fs");
17
+ const version_1 = require("./version");
17
18
  const path_1 = __importDefault(require("path"));
18
19
  function loadModules(client) {
19
- var _a;
20
+ var _a, _b;
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  const response = { commands: [], modules: [] };
22
23
  const modulesDir = ((_a = client.config) === null || _a === void 0 ? void 0 : _a.modulesFolder) || './modules';
@@ -29,8 +30,12 @@ function loadModules(client) {
29
30
  const commands = [];
30
31
  let module_;
31
32
  try {
32
- module_ = require(modulePath);
33
- if (!module_.versions || !(typeof module_.versions === 'object' ? module_.versions : [module_.versions]).includes(client.version))
33
+ const reqMod = require(modulePath);
34
+ 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))
36
+ throw new Error('Module does not have supported versions.');
37
+ const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
38
+ if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
34
39
  throw new Error('Module versions is not defined or unsupported.');
35
40
  if (!(yield Promise.resolve(module_.onStart(client))))
36
41
  throw new Error(script + ' onStart is not defined or returned false.');
@@ -1,6 +1,6 @@
1
1
  import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
2
2
  import { RecipleClient } from "./classes/Client";
3
- import { ApplicationCommandDataResolvable } from 'discord.js';
3
+ import { ApplicationCommandDataResolvable, GuildResolvable } from 'discord.js';
4
4
  import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder } from '@discordjs/builders';
5
5
  export declare type commandBuilders = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
6
- export declare function registerInteractionCommands(client: RecipleClient, cmds?: (commandBuilders | ApplicationCommandDataResolvable)[]): Promise<void>;
6
+ export declare function registerInteractionCommands(client: RecipleClient, cmds?: (commandBuilders | ApplicationCommandDataResolvable)[], overwriteGuilds?: GuildResolvable | GuildResolvable[]): Promise<void>;
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerInteractionCommands = void 0;
13
- function registerInteractionCommands(client, cmds) {
14
- var _a, _b, _c, _d;
13
+ function registerInteractionCommands(client, cmds, overwriteGuilds) {
14
+ var _a, _b, _c, _d, _e, _f;
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
16
  const commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
17
17
  if (typeof c.toJSON !== 'undefined')
@@ -22,15 +22,18 @@ function registerInteractionCommands(client, cmds) {
22
22
  client.logger.warn('No interaction commands found.');
23
23
  return;
24
24
  }
25
- if (!((_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds.length)) {
26
- yield ((_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).catch(e => client.logger.error(e)));
25
+ const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : (_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds;
26
+ const guilds = typeof configGuilds === 'object' ? configGuilds : [configGuilds];
27
+ if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
28
+ yield ((_d = (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands)) === null || _d === void 0 ? void 0 : _d.catch(e => client.logger.error(e)));
27
29
  client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
28
30
  }
29
31
  else {
30
- const guilds = typeof client.config.commands.interactionCommand.guilds === 'string' ? [client.config.commands.interactionCommand.guilds] : client.config.commands.interactionCommand.guilds;
31
32
  client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
32
33
  for (const guild of guilds) {
33
- yield ((_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).catch(e => client.logger.error(e)));
34
+ if (!guild)
35
+ continue;
36
+ yield ((_f = (_e = client.application) === null || _e === void 0 ? void 0 : _e.commands.set(commands, guild)) === null || _f === void 0 ? void 0 : _f.catch(e => client.logger.error(e)));
34
37
  client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
35
38
  }
36
39
  }
@@ -1 +1,8 @@
1
- export declare const version: any;
1
+ export declare const version: string;
2
+ export declare function validVersion(ver: string): boolean;
3
+ export declare function parseVersion(ver: string): {
4
+ major: number;
5
+ minor: number;
6
+ patch: number;
7
+ };
8
+ export declare function isSupportedVersion(ver: string, supportedVersion?: string): boolean;
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = void 0;
3
+ exports.isSupportedVersion = exports.parseVersion = exports.validVersion = exports.version = void 0;
4
+ const fallout_utility_1 = require("fallout-utility");
4
5
  exports.version = require('../../package.json').version;
6
+ 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;
13
+ }
14
+ exports.validVersion = validVersion;
15
+ function parseVersion(ver) {
16
+ if (!validVersion(ver))
17
+ throw new TypeError(`Invalid version: ${ver}`);
18
+ const [major, minor, patch] = ver.split('.');
19
+ return { major: parseInt(major), minor: parseInt(minor), patch: parseInt(patch) };
20
+ }
21
+ exports.parseVersion = parseVersion;
22
+ function isSupportedVersion(ver, supportedVersion) {
23
+ supportedVersion = supportedVersion || exports.version;
24
+ if (!validVersion(ver))
25
+ throw new TypeError(`Invalid version: ${ver}`);
26
+ if (!validVersion(supportedVersion))
27
+ 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;
37
+ }
38
+ exports.isSupportedVersion = isSupportedVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "1.1.2",
3
+ "version": "1.1.5",
4
4
  "description": "A Discord.js bot",
5
5
  "author": "FalloutStudios",
6
6
  "license": "GPL-3.0",
@@ -13,25 +13,28 @@
13
13
  "resource",
14
14
  "package.json",
15
15
  "LICENSE",
16
- "README.md"
16
+ "README.md",
17
+ "CHANGELOG.md"
17
18
  ],
18
19
  "scripts": {
19
20
  "clean": "rimraf bin",
20
21
  "compile": "yarn clean && tsc",
21
22
  "build": "yarn compile && npm un reciple -g && npm i ./ -g",
22
- "build:publish": "yarn run build && npm publish",
23
+ "build:publish": "yarn run build && yarn run changelog && yarn publish",
24
+ "changelog": "changelog generate",
23
25
  "test": "cd test && reciple",
24
26
  "test:compile": "yarn run build && yarn test:run"
25
27
  },
26
28
  "dependencies": {
27
29
  "commander": "^9.2.0",
28
- "discord.js": "^13.6.0",
29
- "dotenv": "^16.0.0",
30
- "fallout-utility": "^1.3.13",
31
- "yaml": "^2.0.1"
30
+ "discord.js": "^13.7.0",
31
+ "dotenv": "^16.0.1",
32
+ "fallout-utility": "^1.3.14",
33
+ "yaml": "^2.1.0"
32
34
  },
33
35
  "devDependencies": {
34
- "@types/node": "^17.0.31",
36
+ "@types/node": "^17.0.35",
37
+ "generate-changelog": "^1.8.0",
35
38
  "typescript": "^4.6.4"
36
39
  }
37
40
  }
@@ -1,41 +1,69 @@
1
+ # Your bot token here
2
+ # To use env variable as a token just do it like this env:TOKEN_ENV
1
3
  token: TOKEN
4
+
5
+ # Message command prefix
2
6
  prefix: '!'
3
7
 
8
+
9
+ # Commands options
4
10
  commands:
5
11
  messageCommand:
12
+ # enable message commands
6
13
  enabled: true
14
+ # reply when an error occured
7
15
  replyOnError: false
16
+ # command argument separator
8
17
  commandArgumentSeparator: ' '
9
18
  interactionCommand:
19
+ # enable interaction commands
10
20
  enabled: true
21
+ # reply when an error occured
11
22
  replyOnError: false
23
+ # register interaction commands on bot ready
12
24
  registerCommands: true
25
+ # register commands to specific guild(s) empty to make it global
13
26
  guilds: []
14
27
 
28
+
29
+ # Commands permissions
15
30
  permissions:
16
31
  messageCommands:
32
+ # enable command permissions
17
33
  enabled: true
18
34
  commands:
19
35
  - command: 'stop'
20
36
  permissions: ['ADMINISTRATOR']
21
37
  interactionCommands:
38
+ # enable command permissions
22
39
  enabled: true
23
40
  commands:
24
41
  - command: 'stop'
25
42
  permissions: ['ADMINISTRATOR']
26
43
 
27
44
 
45
+ # Ignored channel IDs
28
46
  ignoredChannels:
47
+ # enable ignored channels
29
48
  enabled: false
49
+ # convert to only allowed channels
30
50
  convertToAllowList: false
51
+ # channel IDs
31
52
  channels: []
32
53
 
54
+
55
+ # Logger options
33
56
  fileLogging:
57
+ # enable console output to file
34
58
  enabled: true
59
+ # enable debug mode
35
60
  debugmode: false
61
+ # stringify logged JSONs
36
62
  stringifyLoggedJSON: false
63
+ # log file path
37
64
  logFilePath: './logs/latest.log'
38
65
 
66
+ # Client options
39
67
  client:
40
68
  intents:
41
69
  - 'GUILDS'
@@ -45,6 +73,7 @@ client:
45
73
  - 'GUILD_MESSAGES'
46
74
  - 'GUILD_MESSAGE_REACTIONS'
47
75
 
76
+ # Bot replies
48
77
  messages:
49
78
  notEnoughArguments: 'Not enough arguments.'
50
79
  noPermissions:
@@ -54,6 +83,20 @@ messages:
54
83
  content: 'An error occurred.'
55
84
  ephemeral: true
56
85
 
86
+
87
+ ###################################################
88
+ # #
89
+ # ##### ##### # # ### ##### #### #
90
+ # # # # # # # # # # # # #
91
+ # # # ##### # # # # ### ### #### #
92
+ # # # # # # # # # # # # #
93
+ # ### # # # # ### ##### # # #
94
+ # #
95
+ ###################################################
96
+ ## Modifying these values below can cause errors ##
97
+
98
+ # Modules folder
57
99
  modulesFolder: 'modules'
58
100
 
59
- version: VERSION
101
+ # Current version
102
+ version: VERSION