reciple 1.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.
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.loadModules = void 0;
16
+ const fs_1 = require("fs");
17
+ const MessageCommandBuilder_1 = require("./classes/builders/MessageCommandBuilder");
18
+ const InteractionCommandBuilder_1 = require("./classes/builders/InteractionCommandBuilder");
19
+ const path_1 = __importDefault(require("path"));
20
+ function loadModules(client) {
21
+ var _a;
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const response = { commands: [], modules: [] };
24
+ const modulesDir = ((_a = client.config) === null || _a === void 0 ? void 0 : _a.modulesFolder) || './modules';
25
+ const logger = client.logger;
26
+ if (!(0, fs_1.existsSync)(modulesDir))
27
+ (0, fs_1.mkdirSync)(modulesDir, { recursive: true });
28
+ const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')));
29
+ for (const script of scripts) {
30
+ const modulePath = path_1.default.resolve(modulesDir, script);
31
+ const commands = [];
32
+ let module_;
33
+ try {
34
+ module_ = require(modulePath);
35
+ if (!module_.versions || !(typeof module_.versions === 'object' ? module_.versions : [module_.versions]).includes(client.version))
36
+ throw new Error('Module versions is not defined or unsupported.');
37
+ if (!module_.onStart(client))
38
+ throw new Error(script + ' onStart is not defined or returned false.');
39
+ if (module_.commands) {
40
+ for (const command of module_.commands) {
41
+ if (!(command instanceof MessageCommandBuilder_1.MessageCommandBuilder) && !(command instanceof InteractionCommandBuilder_1.InteractionCommandBuilder)) {
42
+ continue;
43
+ }
44
+ commands.push(command);
45
+ }
46
+ }
47
+ }
48
+ catch (error) {
49
+ logger.error(`Failed to load module ${script}`);
50
+ logger.error(error);
51
+ continue;
52
+ }
53
+ response.commands = response.commands.concat(commands.filter((c) => {
54
+ if (!c.name) {
55
+ logger.error(`A message command name is not defined in ${script}`);
56
+ return false;
57
+ }
58
+ if (c instanceof MessageCommandBuilder_1.MessageCommandBuilder && c.options.some(o => !o.name)) {
59
+ logger.error(`A message command option name is not defined in ${script}`);
60
+ return false;
61
+ }
62
+ return true;
63
+ }));
64
+ response.modules.push({
65
+ script: module_,
66
+ info: {
67
+ filename: script,
68
+ versions: typeof module_.versions === 'string' ? [module_.versions] : module_.versions,
69
+ path: modulePath
70
+ }
71
+ });
72
+ logger.info(`Loaded module ${script}`);
73
+ }
74
+ return response;
75
+ });
76
+ }
77
+ exports.loadModules = loadModules;
@@ -0,0 +1,2 @@
1
+ import { RecipleClient } from "./classes/Client";
2
+ export declare function registerInteractionCommands(client: RecipleClient): Promise<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.registerInteractionCommands = void 0;
13
+ function registerInteractionCommands(client) {
14
+ var _a, _b, _c;
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const commands = Object.values(client.commands.INTERACTION_COMMANDS).map(c => c.toJSON());
17
+ if (!commands.length) {
18
+ client.logger.warn('No interaction commands found.');
19
+ return;
20
+ }
21
+ if (!((_a = client.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.guilds.length)) {
22
+ yield ((_b = client.application) === null || _b === void 0 ? void 0 : _b.commands.set(commands).catch(e => client.logger.error(e)));
23
+ client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
24
+ }
25
+ else {
26
+ const guilds = typeof client.config.commands.interactionCommand.guilds === 'string' ? [client.config.commands.interactionCommand.guilds] : client.config.commands.interactionCommand.guilds;
27
+ client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
28
+ for (const guild of guilds) {
29
+ yield ((_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands, guild).catch(e => client.logger.error(e)));
30
+ client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
31
+ }
32
+ }
33
+ });
34
+ }
35
+ exports.registerInteractionCommands = registerInteractionCommands;
@@ -0,0 +1 @@
1
+ export declare const version: any;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ exports.version = require('../../package.json').version;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "reciple",
3
+ "version": "1.0.0",
4
+ "description": "A Discord.js bot",
5
+ "author": "FalloutStudios",
6
+ "license": "GPL-3.0",
7
+ "main": "bin/index.js",
8
+ "bin": {
9
+ "reciple": "bin/bin.js"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "resource",
14
+ "package.json",
15
+ "LICENSE",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "clean": "rimraf bin",
20
+ "compile": "npm run clean && tsc",
21
+ "build": "npm run compile && npm un reciple -g && npm i ./ -g",
22
+ "build:publish": "npm run build && npm publish",
23
+ "test": "cd test && reciple",
24
+ "test:compile": "npm run build && npm run test:run"
25
+ },
26
+ "dependencies": {
27
+ "commander": "^9.1.0",
28
+ "discord.js": "^13.6.0",
29
+ "fallout-utility": "^1.3.9",
30
+ "yaml": "^1.10.2"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^17.0.23",
34
+ "typescript": "^4.6.3"
35
+ }
36
+ }
@@ -0,0 +1,48 @@
1
+ token: TOKEN
2
+ prefix: '!'
3
+
4
+ commands:
5
+ messageCommand:
6
+ enabled: true
7
+ commandArgumentSeparator: ' '
8
+ interactionCommand:
9
+ enabled: true
10
+ registerCommands: true
11
+ guilds: []
12
+
13
+ permissions:
14
+ messageCommands:
15
+ enabled: true
16
+ commands:
17
+ - command: 'stop'
18
+ permissions: ['ADMINISTRATOR']
19
+ interactionCommands:
20
+ enabled: true
21
+ commands:
22
+ - command: 'stop'
23
+ permissions: ['ADMINISTRATOR']
24
+
25
+
26
+ ignoredChannels:
27
+ enabled: false
28
+ convertToAllowList: false
29
+ channels: []
30
+
31
+ fileLogging:
32
+ enabled: true
33
+ logFilePath: './logs/latest.log'
34
+
35
+ client:
36
+ intents:
37
+ - 'GUILDS'
38
+ - 'GUILD_MEMBERS'
39
+ - 'GUILD_INVITES'
40
+ - 'GUILD_VOICE_STATES'
41
+ - 'GUILD_MESSAGES'
42
+ - 'GUILD_MESSAGE_REACTIONS'
43
+
44
+ messages:
45
+ noPermission: 'You do not have permission to use this command.'
46
+ notEnoughArguments: 'Not enough arguments.'
47
+
48
+ modulesFolder: 'modules'