reciple 1.3.1 → 1.4.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.
package/README.md CHANGED
@@ -61,4 +61,4 @@ reciple
61
61
  > The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [Mojang Reciple](https://bugs.mojang.com/browse/MC-225837)
62
62
 
63
63
  # Save the Earth
64
- [![](https://i.imgur.com/GbB1ZuH.png)](https://rebellion.global/)
64
+ [#letTheEarthBreathe](https://rebellion.global/)
package/bin/bin.js CHANGED
@@ -9,25 +9,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
+ var _a;
12
13
  Object.defineProperty(exports, "__esModule", { value: true });
13
14
  const Config_1 = require("./reciple/classes/Config");
14
15
  const Client_1 = require("./reciple/classes/Client");
15
16
  const fs_1 = require("fs");
16
17
  const fallout_utility_1 = require("fallout-utility");
17
18
  require("dotenv/config");
19
+ const flags_1 = require("./reciple/flags");
20
+ const version_1 = require("./reciple/version");
21
+ if (flags_1.flags.version) {
22
+ console.log(`v${version_1.version}`);
23
+ process.exit(0);
24
+ }
18
25
  const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json', 'modules.yml', '.rmmcache'];
19
26
  if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
20
27
  const ask = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ');
21
28
  if (ask !== 'y')
22
29
  process.exit(0);
23
30
  }
24
- const config = new Config_1.RecipleConfig('./reciple.yml').parseConfig().getConfig();
31
+ const config = new Config_1.RecipleConfig((_a = flags_1.flags.config) !== null && _a !== void 0 ? _a : './reciple.yml').parseConfig().getConfig();
25
32
  const client = new Client_1.RecipleClient(Object.assign({ config: config }, config.client));
26
33
  (() => __awaiter(void 0, void 0, void 0, function* () {
27
34
  yield client.startModules();
28
35
  client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
29
- var _a;
30
- client.logger.warn(`Logged in as ${((_a = client.user) === null || _a === void 0 ? void 0 : _a.tag) || 'Unknown'}!`);
36
+ var _b;
37
+ client.logger.warn(`Logged in as ${((_b = client.user) === null || _b === void 0 ? void 0 : _b.tag) || 'Unknown'}!`);
31
38
  yield client.loadModules();
32
39
  client.addCommandListeners();
33
40
  }));
package/bin/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
+ import discord from 'discord.js';
2
+ export declare const discordjs: typeof discord;
1
3
  export * from './reciple/classes/Client';
2
4
  export * from './reciple/classes/Config';
3
5
  export * from './reciple/classes/builders/InteractionCommandBuilder';
4
6
  export * from './reciple/classes/builders/MessageCommandBuilder';
7
+ export * from './reciple/classes/builders/MessageCommandOptionBuilder';
5
8
  export * from './reciple/commandPermissions';
6
9
  export * from './reciple/flags';
7
10
  export * from './reciple/isIgnoredChannel';
package/bin/index.js CHANGED
@@ -13,11 +13,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.discordjs = void 0;
21
+ const discord_js_1 = __importDefault(require("discord.js"));
22
+ exports.discordjs = discord_js_1.default;
17
23
  __exportStar(require("./reciple/classes/Client"), exports);
18
24
  __exportStar(require("./reciple/classes/Config"), exports);
19
25
  __exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
20
26
  __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
27
+ __exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
21
28
  __exportStar(require("./reciple/commandPermissions"), exports);
22
29
  __exportStar(require("./reciple/flags"), exports);
23
30
  __exportStar(require("./reciple/isIgnoredChannel"), exports);
@@ -1,19 +1,19 @@
1
1
  import { ApplicationCommandDataResolvable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
2
- import { Logger as LoggerConstructor } from 'fallout-utility';
3
- import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
4
2
  import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './builders/InteractionCommandBuilder';
5
- import { commandBuilders } from '../registerInteractionCommands';
6
- import { RecipleScript } from '../modules';
3
+ import { recipleCommandBuilders, RecipleScript } from '../modules';
4
+ import { interactionCommandBuilders } from '../registerInteractionCommands';
5
+ import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
6
+ import { Logger as LoggerConstructor } from 'fallout-utility';
7
7
  import { Config } from './Config';
8
8
  export interface RecipleClientOptions extends ClientOptions {
9
9
  config: Config;
10
10
  }
11
11
  export interface RecipleClientCommands {
12
12
  MESSAGE_COMMANDS: {
13
- [key: string]: MessageCommandBuilder;
13
+ [commandName: string]: MessageCommandBuilder;
14
14
  };
15
15
  INTERACTION_COMMANDS: {
16
- [key: string]: InteractionCommandBuilder;
16
+ [commandName: string]: InteractionCommandBuilder;
17
17
  };
18
18
  }
19
19
  export interface RecipleClientEvents extends ClientEvents {
@@ -23,13 +23,15 @@ export interface RecipleClientEvents extends ClientEvents {
23
23
  export declare class RecipleClient extends Client {
24
24
  config?: Config;
25
25
  commands: RecipleClientCommands;
26
- otherApplicationCommandData: (commandBuilders | ApplicationCommandDataResolvable)[];
26
+ otherApplicationCommandData: (interactionCommandBuilders | ApplicationCommandDataResolvable)[];
27
27
  modules: RecipleScript[];
28
28
  logger: LoggerConstructor;
29
29
  version: string;
30
30
  constructor(options: RecipleClientOptions);
31
31
  startModules(): Promise<RecipleClient>;
32
32
  loadModules(): Promise<RecipleClient>;
33
+ addModule(script: RecipleScript, registerCommands?: boolean): Promise<void>;
34
+ addCommand(command: recipleCommandBuilders): RecipleClient;
33
35
  addCommandListeners(): RecipleClient;
34
36
  messageCommandExecute(message: Message): Promise<RecipleClient>;
35
37
  interactionCommandExecute(interaction: Interaction): Promise<RecipleClient>;
@@ -17,13 +17,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.RecipleClient = void 0;
19
19
  const discord_js_1 = require("discord.js");
20
- const fallout_utility_1 = require("fallout-utility");
21
- const registerInteractionCommands_1 = require("../registerInteractionCommands");
22
- const logger_1 = require("../logger");
23
20
  const modules_1 = require("../modules");
24
- const version_1 = require("../version");
21
+ const registerInteractionCommands_1 = require("../registerInteractionCommands");
22
+ const fallout_utility_1 = require("fallout-utility");
25
23
  const commandPermissions_1 = require("../commandPermissions");
26
24
  const isIgnoredChannel_1 = require("../isIgnoredChannel");
25
+ const version_1 = require("../version");
26
+ const logger_1 = require("../logger");
27
27
  class RecipleClient extends discord_js_1.Client {
28
28
  constructor(options) {
29
29
  super(options);
@@ -49,12 +49,7 @@ class RecipleClient extends discord_js_1.Client {
49
49
  for (const command of modules.commands) {
50
50
  if (!command.name)
51
51
  continue;
52
- if (command.builder === 'MESSAGE_COMMAND') {
53
- this.commands.MESSAGE_COMMANDS[command.name] = command;
54
- }
55
- else if (command.builder === 'INTERACTION_COMMAND') {
56
- this.commands.INTERACTION_COMMANDS[command.name] = command;
57
- }
52
+ this.addCommand(command);
58
53
  }
59
54
  this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
60
55
  this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
@@ -69,11 +64,42 @@ class RecipleClient extends discord_js_1.Client {
69
64
  yield Promise.resolve(module_.onLoad(this));
70
65
  }
71
66
  this.logger.info(`${this.modules.length} modules loaded.`);
72
- if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands)
73
- yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
67
+ if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands))
68
+ return this;
69
+ yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
74
70
  return this;
75
71
  });
76
72
  }
73
+ addModule(script, registerCommands = true) {
74
+ var _a, _b;
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ this.modules.push(script);
77
+ if (typeof (script === null || script === void 0 ? void 0 : script.onLoad) === 'function')
78
+ yield Promise.resolve(script.onLoad(this));
79
+ this.logger.info(`${this.modules.length} modules loaded.`);
80
+ for (const command of (_a = script.commands) !== null && _a !== void 0 ? _a : []) {
81
+ if (!command.name)
82
+ continue;
83
+ this.addCommand(command);
84
+ }
85
+ if (!registerCommands || !((_b = this.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.registerCommands))
86
+ return;
87
+ yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
88
+ });
89
+ }
90
+ addCommand(command) {
91
+ var _a;
92
+ if (command.builder === 'MESSAGE_COMMAND') {
93
+ this.commands.MESSAGE_COMMANDS[command.name] = command;
94
+ }
95
+ else if (command.builder === 'INTERACTION_COMMAND') {
96
+ this.commands.INTERACTION_COMMANDS[command.name] = command;
97
+ }
98
+ else {
99
+ this.logger.error(`Command "${(_a = command.name) !== null && _a !== void 0 ? _a : 'unknown'}" has an invalid builder.`);
100
+ }
101
+ return this;
102
+ }
77
103
  addCommandListeners() {
78
104
  var _a, _b;
79
105
  if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled)
@@ -90,7 +116,7 @@ class RecipleClient extends discord_js_1.Client {
90
116
  const parseCommand = (0, fallout_utility_1.getCommand)(message.content, ((_b = this.config) === null || _b === void 0 ? void 0 : _b.prefix) || '!', ((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.messageCommand.commandArgumentSeparator) || ' ');
91
117
  if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command) || !parseCommand)
92
118
  return this;
93
- const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
119
+ const command = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()];
94
120
  if (!command)
95
121
  return this;
96
122
  if ((0, commandPermissions_1.commandPermissions)(command.name, (_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands, command)) {
@@ -144,7 +170,7 @@ class RecipleClient extends discord_js_1.Client {
144
170
  });
145
171
  }
146
172
  _commandExecuteError(err, command) {
147
- var _a, _b, _c, _d, _e;
173
+ var _a, _b, _c, _d;
148
174
  return __awaiter(this, void 0, void 0, function* () {
149
175
  this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
150
176
  this.logger.error(err);
@@ -158,12 +184,7 @@ class RecipleClient extends discord_js_1.Client {
158
184
  else if (command === null || command === void 0 ? void 0 : command.interaction) {
159
185
  if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
160
186
  return;
161
- if (!(command === null || command === void 0 ? void 0 : command.interaction.deferred) && !(command === null || command === void 0 ? void 0 : command.interaction.replied)) {
162
- yield command.interaction.reply(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
163
- }
164
- else {
165
- yield command.interaction.followUp(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
166
- }
187
+ yield command.interaction.followUp(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
167
188
  }
168
189
  });
169
190
  }
@@ -49,20 +49,19 @@ class RecipleConfig {
49
49
  return this.config;
50
50
  }
51
51
  parseToken(askIfNull = true) {
52
+ var _a, _b;
52
53
  let token = flags_1.token || null;
53
- if (token)
54
+ if (!this.config && !token)
54
55
  return token;
55
- if (!this.config)
56
- return token;
57
- if (!this.config.token)
56
+ if (this.config && !((_a = this.config) === null || _a === void 0 ? void 0 : _a.token) && !token)
58
57
  return token || (askIfNull ? this.askToken() : null);
59
- const envToken = this.config.token.toString().split(':');
58
+ token = token || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.token) || null;
59
+ if (!token)
60
+ return token;
61
+ const envToken = token.toString().split(':');
60
62
  if (envToken.length === 2 && envToken[0].toLocaleLowerCase() === 'env' && envToken[1]) {
61
63
  token = process.env[envToken[1]] || null;
62
64
  }
63
- else {
64
- token = this.config.token;
65
- }
66
65
  return token || (askIfNull ? this.askToken() : null);
67
66
  }
68
67
  isSupportedConfig() {
@@ -1,6 +1,7 @@
1
1
  import { Message, PermissionFlags, PermissionString } from 'discord.js';
2
2
  import { Command } from 'fallout-utility';
3
3
  import { RecipleClient } from '../Client';
4
+ import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
4
5
  export declare type CommandMessage = Command;
5
6
  export interface RecipleMessageCommandExecute {
6
7
  message: Message;
@@ -13,21 +14,11 @@ export interface MessageCommandValidatedOption {
13
14
  value: string;
14
15
  required: boolean;
15
16
  }
16
- export declare class MessageOption {
17
- name: string;
18
- description: string;
19
- required: boolean;
20
- validate: (value: string) => boolean;
21
- setName(name: string): MessageOption;
22
- setDescription(description: string): MessageOption;
23
- setRequired(required: boolean): MessageOption;
24
- setValidator(validator: (value: string) => boolean): MessageOption;
25
- }
26
17
  export declare class MessageCommandBuilder {
27
18
  readonly builder: string;
28
19
  name: string;
29
20
  description: string;
30
- options: MessageOption[];
21
+ options: MessageCommandOptionBuilder[];
31
22
  validateOptions: boolean;
32
23
  requiredPermissions: (PermissionFlags | PermissionString)[];
33
24
  allowExecuteInDM: boolean;
@@ -39,7 +30,7 @@ export declare class MessageCommandBuilder {
39
30
  setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
40
31
  setDescription(description: string): MessageCommandBuilder;
41
32
  setExecute(execute: (options: RecipleMessageCommandExecute) => void): MessageCommandBuilder;
42
- addOption(option: MessageOption | ((constructor: MessageOption) => MessageOption)): MessageCommandBuilder;
33
+ addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
43
34
  setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
44
35
  getCommandOptionValues(options: CommandMessage): undefined | MessageCommandValidatedOption[];
45
36
  }
@@ -1,39 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageCommandBuilder = exports.MessageOption = void 0;
4
- class MessageOption {
5
- constructor() {
6
- this.name = '';
7
- this.description = '';
8
- this.required = true;
9
- this.validate = () => true;
10
- }
11
- setName(name) {
12
- if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
13
- throw new Error('name must be a string and match the regex /^[\\w-]{1,32}$/.');
14
- this.name = name;
15
- return this;
16
- }
17
- setDescription(description) {
18
- if (!description || typeof description !== 'string')
19
- throw new Error('description must be a string.');
20
- this.description = description;
21
- return this;
22
- }
23
- setRequired(required) {
24
- if (typeof required !== 'boolean')
25
- throw new Error('required must be a boolean.');
26
- this.required = required;
27
- return this;
28
- }
29
- setValidator(validator) {
30
- if (!validator || typeof validator !== 'function')
31
- throw new Error('validator must be a function.');
32
- this.validate = validator;
33
- return this;
34
- }
35
- }
36
- exports.MessageOption = MessageOption;
3
+ exports.MessageCommandBuilder = void 0;
4
+ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
37
5
  class MessageCommandBuilder {
38
6
  constructor() {
39
7
  this.builder = 'MESSAGE_COMMAND';
@@ -48,54 +16,54 @@ class MessageCommandBuilder {
48
16
  }
49
17
  setName(name) {
50
18
  if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
51
- throw new Error('name must be a string and match the regex /^[\\w-]{1,32}$/');
19
+ throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/');
52
20
  this.name = name;
53
21
  return this;
54
22
  }
55
23
  setRequiredPermissions(permissions) {
56
24
  if (!permissions || !Array.isArray(permissions))
57
- throw new Error('permissions must be an array.');
25
+ throw new TypeError('permissions must be an array.');
58
26
  this.requiredPermissions = permissions;
59
27
  return this;
60
28
  }
61
29
  setAllowExecuteInDM(allowExecuteInDM) {
62
30
  if (typeof allowExecuteInDM !== 'boolean')
63
- throw new Error('allowExecuteInDM must be a boolean.');
31
+ throw new TypeError('allowExecuteInDM must be a boolean.');
64
32
  this.allowExecuteInDM = allowExecuteInDM;
65
33
  return this;
66
34
  }
67
35
  setAllowExecuteByBots(allowExecuteByBots) {
68
36
  if (typeof allowExecuteByBots !== 'boolean')
69
- throw new Error('allowExecuteByBots must be a boolean.');
37
+ throw new TypeError('allowExecuteByBots must be a boolean.');
70
38
  this.allowExecuteByBots = allowExecuteByBots;
71
39
  return this;
72
40
  }
73
41
  setDescription(description) {
74
42
  if (!description || typeof description !== 'string')
75
- throw new Error('description must be a string.');
43
+ throw new TypeError('description must be a string.');
76
44
  this.description = description;
77
45
  return this;
78
46
  }
79
47
  setExecute(execute) {
80
48
  if (!execute || typeof execute !== 'function')
81
- throw new Error('execute must be a function.');
49
+ throw new TypeError('execute must be a function.');
82
50
  this.execute = execute;
83
51
  return this;
84
52
  }
85
53
  addOption(option) {
86
54
  if (!option)
87
- throw new Error('option must be a MessageOption.');
88
- option = typeof option === 'function' ? option(new MessageOption()) : option;
55
+ throw new TypeError('option must be a MessageOption.');
56
+ option = typeof option === 'function' ? option(new MessageCommandOptionBuilder_1.MessageCommandOptionBuilder()) : option;
89
57
  if (this.options.find(o => o.name === option.name))
90
- throw new Error('option with name "' + option.name + '" already exists.');
58
+ throw new TypeError('option with name "' + option.name + '" already exists.');
91
59
  if (this.options.length > 0 && !this.options[this.options.length - 1 < 0 ? 0 : this.options.length - 1].required && option.required)
92
- throw new Error('All required options must be before optional options.');
60
+ throw new TypeError('All required options must be before optional options.');
93
61
  this.options = [...this.options, option];
94
62
  return this;
95
63
  }
96
64
  setValidateOptions(validateOptions) {
97
65
  if (typeof validateOptions !== 'boolean')
98
- throw new Error('validateOptions must be a boolean.');
66
+ throw new TypeError('validateOptions must be a boolean.');
99
67
  this.validateOptions = validateOptions;
100
68
  return this;
101
69
  }
@@ -0,0 +1,10 @@
1
+ export declare class MessageCommandOptionBuilder {
2
+ name: string;
3
+ description: string;
4
+ required: boolean;
5
+ validate: (value: string) => boolean;
6
+ setName(name: string): MessageCommandOptionBuilder;
7
+ setDescription(description: string): MessageCommandOptionBuilder;
8
+ setRequired(required: boolean): MessageCommandOptionBuilder;
9
+ setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
10
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageCommandOptionBuilder = void 0;
4
+ class MessageCommandOptionBuilder {
5
+ constructor() {
6
+ this.name = '';
7
+ this.description = '';
8
+ this.required = true;
9
+ this.validate = () => true;
10
+ }
11
+ setName(name) {
12
+ if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
13
+ throw new TypeError('name must be a string and match the regex /^[\\w-]{1,32}$/.');
14
+ this.name = name;
15
+ return this;
16
+ }
17
+ setDescription(description) {
18
+ if (!description || typeof description !== 'string')
19
+ throw new TypeError('description must be a string.');
20
+ this.description = description;
21
+ return this;
22
+ }
23
+ setRequired(required) {
24
+ if (typeof required !== 'boolean')
25
+ throw new TypeError('required must be a boolean.');
26
+ this.required = required;
27
+ return this;
28
+ }
29
+ setValidator(validator) {
30
+ if (!validator || typeof validator !== 'function')
31
+ throw new TypeError('validator must be a function.');
32
+ this.validate = validator;
33
+ return this;
34
+ }
35
+ }
36
+ exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
@@ -1,5 +1,4 @@
1
1
  import { Permissions } from "discord.js";
2
- import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
3
- import { MessageCommandBuilder } from './classes/builders/MessageCommandBuilder';
4
2
  import { Config } from "./classes/Config";
5
- export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: InteractionCommandBuilder | MessageCommandBuilder): boolean;
3
+ import { recipleCommandBuilders } from './modules';
4
+ export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: recipleCommandBuilders): boolean;
@@ -4,6 +4,8 @@ exports.token = exports.flags = void 0;
4
4
  const commander_1 = require("commander");
5
5
  exports.flags = commander_1.program
6
6
  .option('-t, --token <token>', 'Replace used bot token')
7
+ .option('-c, --config <config>', 'Change path to config file')
7
8
  .option('-D, --debugmode', 'Enabled debug mode')
9
+ .option('-v, --version', 'Display version')
8
10
  .parse().opts();
9
11
  exports.token = exports.flags.token;
@@ -1,16 +1,17 @@
1
1
  import { RecipleClient } from './classes/Client';
2
- import { MessageCommandBuilder } from './classes/builders/MessageCommandBuilder';
3
- import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
4
- export declare type recipleCommands = (MessageCommandBuilder | InteractionCommandBuilder)[];
2
+ import { MessageCommandBuilder, RecipleMessageCommandExecute } from './classes/builders/MessageCommandBuilder';
3
+ import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './classes/builders/InteractionCommandBuilder';
4
+ export declare type recipleCommandBuilders = MessageCommandBuilder | InteractionCommandBuilder;
5
+ export declare type recipleCommandBuildersExecute = RecipleInteractionCommandExecute | RecipleMessageCommandExecute;
5
6
  export declare type loadedModules = {
6
- commands: recipleCommands;
7
+ commands: recipleCommandBuilders[];
7
8
  modules: RecipleModule[];
8
9
  };
9
- export interface RecipleScript {
10
+ export declare class RecipleScript {
10
11
  versions: string | string[];
11
- commands?: (MessageCommandBuilder | InteractionCommandBuilder)[];
12
- onLoad?: (reciple: RecipleClient) => (void | Promise<void>);
13
- onStart: (reciple: RecipleClient) => (boolean | Promise<boolean>);
12
+ commands?: recipleCommandBuilders[];
13
+ onLoad?(reciple: RecipleClient): void | Promise<void>;
14
+ onStart(reciple: RecipleClient): boolean | Promise<boolean>;
14
15
  }
15
16
  export interface RecipleModule {
16
17
  script: RecipleScript;
@@ -1,6 +1,6 @@
1
1
  import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
2
2
  import { RecipleClient } from "./classes/Client";
3
- import { ApplicationCommandDataResolvable, GuildResolvable } from 'discord.js';
3
+ import { ApplicationCommandDataResolvable } from 'discord.js';
4
4
  import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder } from '@discordjs/builders';
5
- export declare type commandBuilders = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
6
- export declare function registerInteractionCommands(client: RecipleClient, cmds?: (commandBuilders | ApplicationCommandDataResolvable)[], overwriteGuilds?: GuildResolvable | GuildResolvable[]): Promise<void>;
5
+ export declare type interactionCommandBuilders = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
6
+ export declare function registerInteractionCommands(client: RecipleClient, cmds?: (interactionCommandBuilders | ApplicationCommandDataResolvable)[], overwriteGuilds?: string | string[]): Promise<void>;
@@ -11,24 +11,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerInteractionCommands = void 0;
13
13
  function registerInteractionCommands(client, cmds, overwriteGuilds) {
14
- var _a, _b, _c, _d, _e, _f;
14
+ var _a, _b, _c, _d;
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
16
  let commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
17
17
  var _a, _b, _c, _d, _e, _f, _g;
18
- if (typeof c.toJSON !== 'undefined') {
19
- const cmd = c;
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
- 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(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())) === null || _f === void 0 ? void 0 : _f.permissions :
23
- undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
24
- cmd.setRequiredPermissions(permissions);
25
- client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
26
- client.logger.debug(`Set required permissions for ${cmd.name} to ${permissions.join(', ')}`);
27
- return cmd.toJSON();
28
- }
29
- return c.toJSON();
18
+ if (typeof c.toJSON == 'undefined')
19
+ return c;
20
+ const cmd = c;
21
+ 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)) {
22
+ const permissions = (_g = (((_c = (_b = client.config) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.interactionCommands.enabled) ?
23
+ (_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 :
24
+ undefined)) !== null && _g !== void 0 ? _g : cmd.requiredPermissions;
25
+ cmd.setRequiredPermissions(permissions);
26
+ client.commands.INTERACTION_COMMANDS[cmd.name] = cmd;
27
+ client.logger.debug(`Set required permissions for ${cmd.name} to ${permissions.join(', ')}`);
28
+ return cmd.toJSON();
30
29
  }
31
- return c;
30
+ return c.toJSON();
32
31
  })) !== null && _a !== void 0 ? _a : [];
33
32
  if (!commands || !commands.length) {
34
33
  client.logger.warn('No interaction commands found.');
@@ -37,16 +36,18 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
37
36
  const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : (_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds;
38
37
  const guilds = typeof configGuilds === 'object' ? configGuilds : [configGuilds];
39
38
  if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
40
- 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)));
41
- client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
39
+ (_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).then(() => {
40
+ client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
41
+ }).catch(e => client.logger.error(e));
42
42
  }
43
43
  else {
44
44
  client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
45
45
  for (const guild of guilds) {
46
46
  if (!guild)
47
47
  continue;
48
- 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)));
49
- client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
48
+ (_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).then(() => {
49
+ client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
50
+ }).catch(e => client.logger.error(e));
50
51
  }
51
52
  }
52
53
  });
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
1
  {
2
- "name": "reciple",
3
- "version": "1.3.1",
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": "yarn clean && tsc",
21
- "build": "yarn compile && npm un reciple -g && npm i ./ -g",
22
- "build:publish": "yarn run build && yarn run changelog && yarn publish",
23
- "test": "cd test && reciple",
24
- "test:build": "yarn run build && yarn test:run"
25
- },
26
- "dependencies": {
27
- "commander": "^9.3.0",
28
- "discord.js": "^13.7.0",
29
- "dotenv": "^16.0.1",
30
- "fallout-utility": "^1.3.14",
31
- "semver": "^7.3.7",
32
- "yaml": "^2.1.1"
33
- },
34
- "devDependencies": {
35
- "@types/node": "^17.0.40",
36
- "@types/semver": "^7.3.9",
37
- "typescript": "^4.7.3"
38
- }
2
+ "name": "reciple",
3
+ "version": "1.4.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": "yarn clean && tsc",
21
+ "build": "yarn compile && npm un reciple -g && npm i ./ -g",
22
+ "build:publish": "yarn run build && yarn run changelog && yarn publish",
23
+ "test": "cd test && reciple",
24
+ "test:build": "yarn run build && yarn test:run"
25
+ },
26
+ "dependencies": {
27
+ "commander": "^9.3.0",
28
+ "discord.js": "^13.8.0",
29
+ "dotenv": "^16.0.1",
30
+ "fallout-utility": "^1.3.14",
31
+ "semver": "^7.3.7",
32
+ "yaml": "^2.1.1"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^17.0.41",
36
+ "@types/semver": "^7.3.9",
37
+ "typescript": "^4.7.3"
38
+ }
39
39
  }
@@ -86,8 +86,7 @@ messages:
86
86
  ephemeral: true
87
87
 
88
88
  # Ignored Files
89
- ignoredFiles:
90
- - 'test.js'
89
+ ignoredFiles: []
91
90
 
92
91
 
93
92
  ###################################################