reciple 5.0.0-pre.6 → 5.0.0-pre.7

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.
@@ -1,7 +1,7 @@
1
- import { Guild, TextBasedChannel, User } from 'discord.js';
1
+ import { Guild, RestOrArray, TextBasedChannel, User } from 'discord.js';
2
2
  import { CommandBuilderType } from '../types/builders';
3
3
  /**
4
- * Object interface for cooled-down user
4
+ * cooled-down user object interface
5
5
  */
6
6
  export interface CooledDownUser {
7
7
  user: User;
@@ -12,9 +12,10 @@ export interface CooledDownUser {
12
12
  expireTime: number;
13
13
  }
14
14
  /**
15
- * Stores cooled-down users
15
+ * cooled-down users manager
16
16
  */
17
17
  export declare class CommandCooldownManager extends Array<CooledDownUser> {
18
+ constructor(...data: RestOrArray<CooledDownUser>);
18
19
  /**
19
20
  * Alias for `CommandCooldownManager#push()`
20
21
  * @param options Cooled-down user data
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandCooldownManager = void 0;
4
+ const discord_js_1 = require("discord.js");
4
5
  /**
5
- * Stores cooled-down users
6
+ * cooled-down users manager
6
7
  */
7
8
  class CommandCooldownManager extends Array {
9
+ constructor(...data) {
10
+ super(...(0, discord_js_1.normalizeArray)(data));
11
+ }
8
12
  /**
9
13
  * Alias for `CommandCooldownManager#push()`
10
14
  * @param options Cooled-down user data
@@ -1,12 +1,10 @@
1
1
  import { MessageCommandValidatedOption } from './builders/MessageCommandBuilder';
2
+ import { RestOrArray } from 'discord.js';
2
3
  /**
3
4
  * Validated message options manager
4
5
  */
5
6
  export declare class MessageCommandOptionManager extends Array<MessageCommandValidatedOption> {
6
- /**
7
- * @param options Validated options
8
- */
9
- constructor(...options: MessageCommandValidatedOption[]);
7
+ constructor(...data: RestOrArray<MessageCommandValidatedOption>);
10
8
  /**
11
9
  * Get the option info
12
10
  * @param name Option name
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageCommandOptionManager = void 0;
4
+ const discord_js_1 = require("discord.js");
4
5
  /**
5
6
  * Validated message options manager
6
7
  */
7
8
  class MessageCommandOptionManager extends Array {
8
- /**
9
- * @param options Validated options
10
- */
11
- constructor(...options) {
12
- super(...(options !== null && options !== void 0 ? options : []));
9
+ constructor(...data) {
10
+ super(...(0, discord_js_1.normalizeArray)(data));
13
11
  }
14
12
  get(name, required) {
15
13
  const option = this.find(o => o.name == name);
@@ -10,13 +10,13 @@ import { Config } from './RecipleConfig';
10
10
  import { RecipleModule } from '../modules';
11
11
  import { ApplicationCommandData, Awaitable, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, Interaction, Message, RestOrArray } from 'discord.js';
12
12
  /**
13
- * options for Reciple client
13
+ * Options for Reciple client
14
14
  */
15
15
  export interface RecipleClientOptions extends ClientOptions {
16
16
  config?: Config;
17
17
  }
18
18
  /**
19
- * Reciple client commands object interface
19
+ * Reciple client commands
20
20
  */
21
21
  export interface RecipleClientCommands {
22
22
  slashCommands: {
@@ -35,7 +35,7 @@ export interface RecipleClientEvents extends ClientEvents {
35
35
  recipleReplyError: [error: unknown];
36
36
  }
37
37
  /**
38
- * Create new Reciple client
38
+ * Reciple client
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;
@@ -47,7 +47,7 @@ class RecipleClient extends discord_js_1.Client {
47
47
  throw new Error('Config is not defined.');
48
48
  this.config = Object.assign(Object.assign({}, this.config), ((_c = options.config) !== null && _c !== void 0 ? _c : {}));
49
49
  if (this.config.fileLogging.enabled)
50
- this.logger.logFile((_d = this.config.fileLogging.logFilePath) !== null && _d !== void 0 ? _d : path_1.default.join(flags_1.cwd, 'logs/latest.log'), false);
50
+ this.logger.logFile(path_1.default.join(flags_1.cwd, (_d = this.config.fileLogging.logFilePath) !== null && _d !== void 0 ? _d : 'logs/latest.log'), false);
51
51
  }
52
52
  /**
53
53
  * Load modules from modules folder
@@ -1,8 +1,8 @@
1
1
  import { CommandBuilderType, AnyCommandExecuteData, CommandHaltFunction, CommandExecuteFunction, SharedCommandBuilderProperties } from '../../types/builders';
2
+ import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
2
3
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
3
4
  import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
4
5
  import { Command as CommandMessage } from 'fallout-utility';
5
- import { Message, PermissionResolvable, RestOrArray } from 'discord.js';
6
6
  import { CommandHaltData } from '../../types/commands';
7
7
  import { RecipleClient } from '../RecipleClient';
8
8
  /**
@@ -26,7 +26,7 @@ export interface MessageCommandValidatedOption {
26
26
  missing: boolean;
27
27
  }
28
28
  /**
29
- * Message command halt data
29
+ * Halt data for message command
30
30
  */
31
31
  export declare type MessageCommandHaltData = CommandHaltData<CommandBuilderType.MessageCommand>;
32
32
  /**
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
13
13
  const builders_1 = require("../../types/builders");
14
+ const discord_js_1 = require("discord.js");
14
15
  const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
15
16
  const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
16
- const discord_js_1 = require("discord.js");
17
17
  /**
18
18
  * Reciple builder for message command
19
19
  */
@@ -3,7 +3,7 @@ import { CommandHaltData } from '../../types/commands';
3
3
  import { RecipleClient } from '../RecipleClient';
4
4
  import { ChatInputCommandInteraction, PermissionResolvable, RestOrArray, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder as DiscordJsSlashCommandSubcommandsOnlyBuilder } from 'discord.js';
5
5
  /**
6
- * Execute data for interaction command
6
+ * Execute data for slash command
7
7
  */
8
8
  export interface SlashCommandExecuteData {
9
9
  interaction: ChatInputCommandInteraction;
@@ -29,9 +29,9 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder {
29
29
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
30
30
  }
31
31
  /**
32
- * Reciple builder for interaction/slash command
32
+ * Reciple builder for slash command
33
33
  */
34
- export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties {
34
+ export declare class SlashCommandBuilder extends DiscordJsSlashCommandBuilder implements SharedCommandBuilderProperties, SlashCommandBuilder {
35
35
  readonly type = CommandBuilderType.SlashCommand;
36
36
  cooldown: number;
37
37
  requiredBotPermissions: PermissionResolvable[];
@@ -4,7 +4,7 @@ exports.SlashCommandBuilder = void 0;
4
4
  const builders_1 = require("../../types/builders");
5
5
  const discord_js_1 = require("discord.js");
6
6
  /**
7
- * Reciple builder for interaction/slash command
7
+ * Reciple builder for slash command
8
8
  */
9
9
  class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
10
10
  constructor() {
@@ -8,7 +8,7 @@ export declare const commander: Command;
8
8
  */
9
9
  export declare const flags: import("commander").OptionValues;
10
10
  /**
11
- * Temporary token flag
11
+ * Token flag
12
12
  */
13
13
  export declare const token: string | undefined;
14
14
  /**
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.cwd = exports.token = exports.flags = exports.commander = void 0;
7
4
  const version_1 = require("./version");
8
5
  const commander_1 = require("commander");
9
- const path_1 = __importDefault(require("path"));
10
6
  /**
11
7
  * Commander
12
8
  */
@@ -17,7 +13,7 @@ exports.commander = new commander_1.Command()
17
13
  .argument('[current-working-directory]', 'Change the current working directory')
18
14
  .option('-t, --token <token>', 'Replace used bot token')
19
15
  .option('-c, --config <config>', 'Change path to config file')
20
- .option('-D, --debugmode', 'Enabled debug mode')
16
+ .option('-D, --debugmode', 'Enable debug mode')
21
17
  .option('-y, --yes', 'Automatically agree to Reciple confirmation prompts')
22
18
  .option('-v, --version', 'Display version')
23
19
  .parse();
@@ -26,10 +22,10 @@ exports.commander = new commander_1.Command()
26
22
  */
27
23
  exports.flags = exports.commander.opts();
28
24
  /**
29
- * Temporary token flag
25
+ * Token flag
30
26
  */
31
27
  exports.token = exports.flags.token;
32
28
  /**
33
29
  * Current working directory
34
30
  */
35
- exports.cwd = path_1.default.join(process.cwd(), exports.commander.args[0] || '.');
31
+ exports.cwd = exports.commander.args[0] || process.cwd();
@@ -5,7 +5,7 @@ export declare type LoadedModules = {
5
5
  modules: RecipleModule[];
6
6
  };
7
7
  /**
8
- * Reciple script object interface
8
+ * Reciple script object
9
9
  */
10
10
  export interface RecipleScript {
11
11
  versions: string | string[];
@@ -14,7 +14,7 @@ export interface RecipleScript {
14
14
  onStart(reciple: RecipleClient): boolean | Promise<boolean>;
15
15
  }
16
16
  /**
17
- * Reciple module object interface
17
+ * Reciple module object
18
18
  */
19
19
  export interface RecipleModule {
20
20
  script: RecipleScript;
@@ -14,11 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getModules = void 0;
16
16
  const builders_1 = require("./types/builders");
17
+ const discord_js_1 = require("discord.js");
17
18
  const version_1 = require("./version");
18
19
  const fs_1 = require("fs");
19
20
  const wildcard_match_1 = __importDefault(require("wildcard-match"));
20
21
  const path_1 = __importDefault(require("path"));
21
- const discord_js_1 = require("discord.js");
22
+ const flags_1 = require("./flags");
22
23
  /**
23
24
  * Load modules from folder
24
25
  * @param client Reciple client
@@ -28,7 +29,7 @@ function getModules(client, folder) {
28
29
  var _a;
29
30
  return __awaiter(this, void 0, void 0, function* () {
30
31
  const response = { commands: [], modules: [] };
31
- const modulesDir = folder || 'modules';
32
+ const modulesDir = folder || path_1.default.join(flags_1.cwd, 'modules');
32
33
  if (!(0, fs_1.existsSync)(modulesDir))
33
34
  (0, fs_1.mkdirSync)(modulesDir, { recursive: true });
34
35
  const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerApplicationCommands = void 0;
13
+ const discord_js_1 = require("discord.js");
13
14
  const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
14
15
  /**
15
16
  * Register application commands
@@ -19,7 +20,7 @@ function registerApplicationCommands(options) {
19
20
  var _a, _b, _c, _d;
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  const client = options.client;
22
- const guilds = typeof options.guilds == 'string' ? [options.guilds] : options.guilds;
23
+ const guilds = (0, discord_js_1.normalizeArray)(options.guilds);
23
24
  const commands = (_b = Object.values((_a = options.commands) !== null && _a !== void 0 ? _a : client.commands.slashCommands).map(cmd => {
24
25
  var _a;
25
26
  if (typeof (cmd === null || cmd === void 0 ? void 0 : cmd.toJSON) == 'undefined')
@@ -2,31 +2,31 @@ import { MessageCommandBuilder, MessageCommandExecuteData, MessageCommandExecute
2
2
  import { SlashCommandBuilder, SlashCommandExecuteData, SlashCommandExecuteFunction, SlashCommandHaltData, SlashCommandHaltFunction } from '../classes/builders/SlashCommandBuilder';
3
3
  import { Awaitable, PermissionResolvable, RestOrArray } from 'discord.js';
4
4
  /**
5
- * Any Reciple command builders
5
+ * Any command builders
6
6
  */
7
7
  export declare type AnyCommandBuilder = SlashCommandBuilder | MessageCommandBuilder;
8
8
  /**
9
- * Any Reciple command execute data
9
+ * Any command execute data
10
10
  */
11
11
  export declare type AnyCommandExecuteData = SlashCommandExecuteData | MessageCommandExecuteData;
12
12
  /**
13
- * Any Reciple command halt functions
13
+ * Any command halt functions
14
14
  */
15
15
  export declare type AnyCommandHaltFunction = SlashCommandHaltFunction | MessageCommandHaltFunction;
16
16
  /**
17
- * Any reciple command execute function
17
+ * Any command execute function
18
18
  */
19
19
  export declare type AnyCommandExecuteFunction = SlashCommandExecuteFunction | MessageCommandExecuteFunction;
20
20
  /**
21
- * Reciple command halt function
21
+ * command halt function
22
22
  */
23
23
  export declare type CommandHaltFunction<T extends CommandBuilderType> = (haltData: T extends CommandBuilderType.SlashCommand ? SlashCommandHaltData : MessageCommandHaltData) => Awaitable<boolean | null | undefined | void>;
24
24
  /**
25
- * Reciple command execute function
25
+ * command execute function
26
26
  */
27
27
  export declare type CommandExecuteFunction<T extends CommandBuilderType> = (executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : MessageCommandExecuteData) => Awaitable<void>;
28
28
  /**
29
- * Types of Reciple command builders
29
+ * Types of command builders
30
30
  */
31
31
  export declare enum CommandBuilderType {
32
32
  MessageCommand = 0,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandBuilderType = void 0;
4
4
  /**
5
- * Types of Reciple command builders
5
+ * Types of command builders
6
6
  */
7
7
  var CommandBuilderType;
8
8
  (function (CommandBuilderType) {
@@ -4,15 +4,15 @@ import { MessageCommandOptionManager } from '../classes/MessageCommandOptionMana
4
4
  import { CommandBuilderType, AnyCommandExecuteData } from '../types/builders';
5
5
  import { CooledDownUser } from '../classes/CommandCooldownManager';
6
6
  /**
7
- * Any reciple halted command data
7
+ * Any command halt data
8
8
  */
9
9
  export declare type AnyCommandHaltData = SlashCommandHaltData | MessageCommandHaltData;
10
10
  /**
11
- * Halted command data
11
+ * command halt data
12
12
  */
13
13
  export declare type CommandHaltData<T extends CommandBuilderType> = CommandErrorData<T> | CommandCooldownData<T> | (T extends CommandBuilderType.SlashCommand ? never : CommandInvalidArguments<T> | CommandMissingArguments<T>) | CommandMissingMemberPermissions<T> | CommandMissingBotPermissions<T>;
14
14
  /**
15
- * Command halt reason base interface
15
+ * Command halt reason base
16
16
  */
17
17
  export interface CommandHaltReasonBase<T extends CommandBuilderType> {
18
18
  executeData: T extends CommandBuilderType.SlashCommand ? SlashCommandExecuteData : T extends CommandBuilderType.MessageCommand ? MessageCommandExecuteData : AnyCommandExecuteData;
@@ -6,7 +6,7 @@ import { Config } from '../classes/RecipleConfig';
6
6
  import { AnyCommandBuilder } from './builders';
7
7
  export interface RecipleClientAddModuleOptions {
8
8
  /**
9
- * The Module script
9
+ * The module script
10
10
  */
11
11
  script: RecipleScript;
12
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "5.0.0-pre.6",
3
+ "version": "5.0.0-pre.7",
4
4
  "bin": "bin/bin.js",
5
5
  "license": "GPL-3.0",
6
6
  "main": "bin/index.js",
@@ -23,8 +23,9 @@ commands:
23
23
  # enable overwriten command permissions
24
24
  enabled: false
25
25
  commands:
26
- - command: 'example-command'
27
- permissions: ['Administrator']
26
+ - command: example-command
27
+ permissions:
28
+ - Administrator
28
29
 
29
30
  # Interaction command options
30
31
  slashCommand:
@@ -45,8 +46,9 @@ commands:
45
46
  # enable overwriten command permissions
46
47
  enabled: false
47
48
  commands:
48
- - command: 'example-command'
49
- permissions: ['Administrator']
49
+ - command: example-command
50
+ permissions:
51
+ - Administrator
50
52
 
51
53
 
52
54
  # Logger options
@@ -60,32 +62,32 @@ fileLogging:
60
62
  # stringify logged JSONs
61
63
  stringifyLoggedJSON: false
62
64
  # log file path
63
- logFilePath:
65
+ logFilePath: logs/latest.log
64
66
 
65
67
  # Client options
66
68
  # Learn more about client options at https://discord.js.org/#/docs/discord.js/main/typedef/ClientOptions
67
69
  client:
68
70
  intents:
69
- - 'Guilds'
70
- - 'GuildMembers'
71
- - 'GuildMessages'
72
- - 'MessageContent'
71
+ - Guilds
72
+ - GuildMembers
73
+ - GuildMessages
74
+ - MessageContent
73
75
 
74
76
  # Bot messages
75
77
  messages:
76
- missingArguments: 'Not enough arguments.'
77
- invalidArguments: 'Invalid argument(s) given.'
78
+ missingArguments: Not enough arguments.
79
+ invalidArguments: Invalid argument(s) given.
78
80
  insufficientBotPerms:
79
- content: 'Insufficient bot permissions.'
81
+ content: Insufficient bot permissions.
80
82
  ephemeral: true
81
83
  noPermissions:
82
- content: 'You do not have permission to use this command.'
84
+ content: You do not have permission to use this command.
83
85
  ephemeral: true
84
86
  cooldown:
85
- content: 'You cannot execute this command right now due to the cooldown.'
87
+ content: You cannot execute this command right now due to the cooldown.
86
88
  ephemeral: true
87
89
  error:
88
- content: 'An error occurred.'
90
+ content: An error occurred.
89
91
  ephemeral: true
90
92
 
91
93
  # Ignored Files