reciple 3.0.1 → 3.1.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.
Files changed (35) hide show
  1. package/README.md +22 -6
  2. package/bin/bin.js +3 -3
  3. package/bin/index.d.ts +3 -3
  4. package/bin/index.js +3 -3
  5. package/bin/reciple/classes/CommandCooldownManager.d.ts +15 -1
  6. package/bin/reciple/classes/CommandCooldownManager.js +12 -1
  7. package/bin/reciple/classes/MessageCommandOptionManager.d.ts +10 -0
  8. package/bin/reciple/classes/MessageCommandOptionManager.js +6 -0
  9. package/bin/reciple/classes/RecipleClient.d.ts +49 -15
  10. package/bin/reciple/classes/RecipleClient.js +66 -24
  11. package/bin/reciple/classes/RecipleConfig.d.ts +14 -1
  12. package/bin/reciple/classes/RecipleConfig.js +10 -2
  13. package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +24 -9
  14. package/bin/reciple/classes/builders/InteractionCommandBuilder.js +22 -7
  15. package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +36 -12
  16. package/bin/reciple/classes/builders/MessageCommandBuilder.js +60 -37
  17. package/bin/reciple/classes/builders/MessageCommandOptionBuilder.d.ts +7 -0
  18. package/bin/reciple/classes/builders/MessageCommandOptionBuilder.js +7 -0
  19. package/bin/reciple/logger.d.ts +11 -0
  20. package/bin/reciple/logger.js +19 -3
  21. package/bin/reciple/modules.d.ts +11 -3
  22. package/bin/reciple/modules.js +4 -2
  23. package/bin/reciple/permissions.d.ts +8 -3
  24. package/bin/reciple/permissions.js +12 -8
  25. package/bin/reciple/registerInteractionCommands.d.ts +4 -3
  26. package/bin/reciple/registerInteractionCommands.js +7 -5
  27. package/bin/reciple/types/builders.d.ts +13 -4
  28. package/bin/reciple/types/builders.js +3 -0
  29. package/bin/reciple/types/commands.d.ts +20 -14
  30. package/bin/reciple/types/commands.js +3 -0
  31. package/bin/reciple/types/paramOptions.d.ts +14 -7
  32. package/bin/reciple/version.d.ts +6 -5
  33. package/bin/reciple/version.js +5 -3
  34. package/package.json +26 -21
  35. package/resource/reciple.yml +20 -17
@@ -1,8 +1,14 @@
1
1
  import { ClientOptions, PermissionResolvable } from 'discord.js';
2
+ /**
3
+ * Command permissions config object interface
4
+ */
2
5
  export interface ConfigCommandPermissions {
3
6
  command: string;
4
7
  permissions: PermissionResolvable[];
5
8
  }
9
+ /**
10
+ * Reciple config object interface
11
+ */
6
12
  export interface Config {
7
13
  token: string;
8
14
  commands: {
@@ -51,10 +57,16 @@ export interface Config {
51
57
  modulesFolder: string;
52
58
  version: string;
53
59
  }
60
+ /**
61
+ * Create/parse reciple config
62
+ */
54
63
  export declare class RecipleConfig {
55
- config?: Config;
64
+ config: Config;
56
65
  configPath: string;
57
66
  static defaultConfigPath: string;
67
+ /**
68
+ * @param configPath Path to config
69
+ */
58
70
  constructor(configPath: string);
59
71
  /**
60
72
  * Parse the config file
@@ -66,6 +78,7 @@ export declare class RecipleConfig {
66
78
  getConfig(): Config;
67
79
  /**
68
80
  * Parse token from config
81
+ * @param askIfNull Ask for token if the token is null/undefined
69
82
  */
70
83
  parseToken(askIfNull?: boolean): string | null;
71
84
  /**
@@ -4,14 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RecipleConfig = void 0;
7
- const fs_1 = require("fs");
7
+ const flags_1 = require("../flags");
8
8
  const version_1 = require("../version");
9
9
  const fallout_utility_1 = require("fallout-utility");
10
- const flags_1 = require("../flags");
10
+ const fs_1 = require("fs");
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const yaml_1 = __importDefault(require("yaml"));
13
+ /**
14
+ * Create/parse reciple config
15
+ */
13
16
  class RecipleConfig {
17
+ /**
18
+ * @param configPath Path to config
19
+ */
14
20
  constructor(configPath) {
21
+ this.config = RecipleConfig.getDefaultConfig();
15
22
  this.configPath = './reciple.yml';
16
23
  if (!configPath)
17
24
  throw new Error('Config path is not defined');
@@ -56,6 +63,7 @@ class RecipleConfig {
56
63
  }
57
64
  /**
58
65
  * Parse token from config
66
+ * @param askIfNull Ask for token if the token is null/undefined
59
67
  */
60
68
  parseToken(askIfNull = true) {
61
69
  var _a, _b;
@@ -1,36 +1,51 @@
1
- import { Awaitable, CommandInteraction, PermissionResolvable } from 'discord.js';
1
+ import { RecipleCommandBuilderType } from '../../types/builders';
2
2
  import { RecipleHaltedCommandData } from '../../types/commands';
3
- import { SlashCommandBuilder } from '@discordjs/builders';
4
3
  import { RecipleClient } from '../RecipleClient';
5
- import { RecipleCommandBuilderType } from '../../types/builders';
6
- export interface RecipleInteractionCommandExecuteData {
7
- interaction: CommandInteraction;
4
+ import { SlashCommandBuilder } from '@discordjs/builders';
5
+ import { Awaitable, ChatInputCommandInteraction, PermissionResolvable } from 'discord.js';
6
+ /**
7
+ * Execute data for interaction command
8
+ */
9
+ export interface InteractionCommandExecuteData {
10
+ interaction: ChatInputCommandInteraction;
8
11
  builder: InteractionCommandBuilder;
9
12
  client: RecipleClient<true>;
10
13
  }
14
+ /**
15
+ * Reciple builder for interaction/slash command
16
+ */
11
17
  export declare class InteractionCommandBuilder extends SlashCommandBuilder {
12
18
  readonly builder = RecipleCommandBuilderType.InteractionCommand;
13
19
  cooldown: number;
14
20
  requiredBotPermissions: PermissionResolvable[];
15
- RequiredUserPermissions: PermissionResolvable[];
21
+ requiredMemberPermissions: PermissionResolvable[];
16
22
  allowExecuteInDM: boolean;
17
23
  halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>;
18
- execute: (executeData: RecipleInteractionCommandExecuteData) => Awaitable<void>;
24
+ execute: (executeData: InteractionCommandExecuteData) => Awaitable<void>;
19
25
  /**
20
26
  * Sets the execute cooldown for this command.
21
27
  * - `0` means no cooldown
28
+ * @param cooldown Command cooldown in milliseconds
22
29
  */
23
30
  setCooldown(cooldown: number): InteractionCommandBuilder;
31
+ /**
32
+ * Set required bot permissions to execute the command
33
+ * @param permissions Bot's required permissions
34
+ */
35
+ setRequiredBotPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
24
36
  /**
25
37
  * Set required permissions to execute the command
38
+ * @param permissions User's return permissions
26
39
  */
27
40
  setRequiredMemberPermissions(...permissions: PermissionResolvable[]): InteractionCommandBuilder;
28
41
  /**
29
- * Function when the command is interupted before execution
42
+ * Function when the command is interupted
43
+ * @param halt Function to execute when command is halted
30
44
  */
31
45
  setHalt(halt?: (haltData: RecipleHaltedCommandData<InteractionCommandBuilder>) => Awaitable<boolean | void>): InteractionCommandBuilder;
32
46
  /**
33
47
  * Function when the command is executed
48
+ * @param execute Function to execute when the command is called
34
49
  */
35
- setExecute(execute: (executeData: RecipleInteractionCommandExecuteData) => void): InteractionCommandBuilder;
50
+ setExecute(execute: (executeData: InteractionCommandExecuteData) => void): InteractionCommandBuilder;
36
51
  }
@@ -1,35 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InteractionCommandBuilder = void 0;
4
- const builders_1 = require("@discordjs/builders");
5
- const builders_2 = require("../../types/builders");
6
- class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
4
+ const builders_1 = require("../../types/builders");
5
+ const builders_2 = require("@discordjs/builders");
6
+ /**
7
+ * Reciple builder for interaction/slash command
8
+ */
9
+ class InteractionCommandBuilder extends builders_2.SlashCommandBuilder {
7
10
  constructor() {
8
11
  super(...arguments);
9
- this.builder = builders_2.RecipleCommandBuilderType.InteractionCommand;
12
+ this.builder = builders_1.RecipleCommandBuilderType.InteractionCommand;
10
13
  this.cooldown = 0;
11
14
  this.requiredBotPermissions = [];
12
- this.RequiredUserPermissions = [];
15
+ this.requiredMemberPermissions = [];
13
16
  this.allowExecuteInDM = true;
14
17
  this.execute = () => { };
15
18
  }
16
19
  /**
17
20
  * Sets the execute cooldown for this command.
18
21
  * - `0` means no cooldown
22
+ * @param cooldown Command cooldown in milliseconds
19
23
  */
20
24
  setCooldown(cooldown) {
21
25
  this.cooldown = cooldown;
22
26
  return this;
23
27
  }
28
+ /**
29
+ * Set required bot permissions to execute the command
30
+ * @param permissions Bot's required permissions
31
+ */
32
+ setRequiredBotPermissions(...permissions) {
33
+ this.requiredBotPermissions = permissions;
34
+ return this;
35
+ }
24
36
  /**
25
37
  * Set required permissions to execute the command
38
+ * @param permissions User's return permissions
26
39
  */
27
40
  setRequiredMemberPermissions(...permissions) {
28
- this.RequiredUserPermissions = permissions;
41
+ this.requiredMemberPermissions = permissions;
29
42
  return this;
30
43
  }
31
44
  /**
32
- * Function when the command is interupted before execution
45
+ * Function when the command is interupted
46
+ * @param halt Function to execute when command is halted
33
47
  */
34
48
  setHalt(halt) {
35
49
  this.halt = halt ? halt : undefined;
@@ -37,6 +51,7 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
37
51
  }
38
52
  /**
39
53
  * Function when the command is executed
54
+ * @param execute Function to execute when the command is called
40
55
  */
41
56
  setExecute(execute) {
42
57
  if (!execute || typeof execute !== 'function')
@@ -1,17 +1,23 @@
1
- import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
1
+ import { RecipleCommandBuilderType } from '../../types/builders';
2
+ import { RecipleHaltedCommandData } from '../../types/commands';
2
3
  import { MessageCommandOptionManager } from '../MessageCommandOptionManager';
4
+ import { RecipleClient } from '../RecipleClient';
5
+ import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
3
6
  import { Awaitable, Message, PermissionResolvable } from 'discord.js';
4
- import { RecipleHaltedCommandData } from '../../types/commands';
5
7
  import { Command as CommandMessage } from 'fallout-utility';
6
- import { RecipleClient } from '../RecipleClient';
7
- import { RecipleCommandBuilderType } from '../../types/builders';
8
- export interface RecipleMessageCommandExecuteData {
8
+ /**
9
+ * Execute data for message command
10
+ */
11
+ export interface MessageCommandExecuteData {
9
12
  message: Message;
10
13
  options: MessageCommandOptionManager;
11
14
  command: CommandMessage;
12
15
  builder: MessageCommandBuilder;
13
16
  client: RecipleClient<true>;
14
17
  }
18
+ /**
19
+ * Validated message command option
20
+ */
15
21
  export interface MessageCommandValidatedOption {
16
22
  name: string;
17
23
  value: string | undefined;
@@ -19,6 +25,9 @@ export interface MessageCommandValidatedOption {
19
25
  invalid: boolean;
20
26
  missing: boolean;
21
27
  }
28
+ /**
29
+ * Reciple builder for message command
30
+ */
22
31
  export declare class MessageCommandBuilder {
23
32
  readonly builder = RecipleCommandBuilderType.MessageCommand;
24
33
  name: string;
@@ -28,62 +37,77 @@ export declare class MessageCommandBuilder {
28
37
  options: MessageCommandOptionBuilder[];
29
38
  validateOptions: boolean;
30
39
  requiredBotPermissions: PermissionResolvable[];
31
- RequiredUserPermissions: PermissionResolvable[];
40
+ requiredMemberPermissions: PermissionResolvable[];
32
41
  allowExecuteInDM: boolean;
33
42
  allowExecuteByBots: boolean;
34
43
  halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>;
35
- execute: (executeData: RecipleMessageCommandExecuteData) => void;
44
+ execute: (executeData: MessageCommandExecuteData) => void;
36
45
  /**
37
46
  * Sets the command name
47
+ * @param name Command name
38
48
  */
39
49
  setName(name: string): MessageCommandBuilder;
40
50
  /**
41
51
  * Sets the command description
52
+ * @param description Command description
42
53
  */
43
54
  setDescription(description: string): MessageCommandBuilder;
44
55
  /**
45
56
  * Sets the execute cooldown for this command.
46
57
  * - `0` means no cooldown
58
+ * @param cooldown Command cooldown in milliseconds
47
59
  */
48
60
  setCooldown(cooldown: number): MessageCommandBuilder;
49
61
  /**
50
62
  * Add aliases to the command
63
+ * @param aliases Command aliases
51
64
  */
52
65
  addAliases(...aliases: string[]): MessageCommandBuilder;
53
66
  /**
54
- * Set required per
67
+ * Set required bot permissions to execute the command
68
+ * @param permissions Bot's required permissions
55
69
  */
56
70
  setRequiredBotPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
57
71
  /**
58
- * Set required user permissions to execute the command
72
+ * Set required permissions to execute the command
73
+ * @param permissions User's return permissions
59
74
  */
60
75
  setRequiredMemberPermissions(...permissions: PermissionResolvable[]): MessageCommandBuilder;
61
76
  /**
62
77
  * Set if command can be executed in dms
78
+ * @param allowExecuteInDM `true` if the command can execute in DMs
63
79
  */
64
80
  setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
65
81
  /**
66
82
  * Allow command to be executed by bots
83
+ * @param allowExecuteByBots `true` if the command can be executed by bots
67
84
  */
68
85
  setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
69
86
  /**
70
- * Function when the command is interupted before execution
87
+ * Function when the command is interupted
88
+ * @param halt Function to execute when command is halted
71
89
  */
72
90
  setHalt(halt?: (haltData: RecipleHaltedCommandData<MessageCommandBuilder>) => Awaitable<boolean | void>): MessageCommandBuilder;
73
91
  /**
74
92
  * Function when the command is executed
93
+ * @param execute Function to execute when the command is called
75
94
  */
76
- setExecute(execute: (executeData: RecipleMessageCommandExecuteData) => void): MessageCommandBuilder;
95
+ setExecute(execute: (executeData: MessageCommandExecuteData) => void): MessageCommandBuilder;
77
96
  /**
78
97
  * Add option to the command
98
+ * @param option Message option builder
79
99
  */
80
100
  addOption(option: MessageCommandOptionBuilder | ((constructor: MessageCommandOptionBuilder) => MessageCommandOptionBuilder)): MessageCommandBuilder;
81
101
  /**
82
102
  * Validate options before executing
103
+ * @param validateOptions `true` if the command options needs to be validated before executing
83
104
  */
84
105
  setValidateOptions(validateOptions: boolean): MessageCommandBuilder;
85
106
  /**
86
107
  * validate given command options
108
+ * @deprecated use `validateMessageCommandOptions()` instead
109
+ * @param options Parsed message command data
87
110
  */
88
- getCommandOptionValues(options: CommandMessage): MessageCommandValidatedOption[];
111
+ getCommandOptionValues(options: CommandMessage): MessageCommandOptionManager;
89
112
  }
113
+ export declare function validateMessageCommandOptions(builder: MessageCommandBuilder, options: CommandMessage): MessageCommandOptionManager;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageCommandBuilder = void 0;
4
- const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
3
+ exports.validateMessageCommandOptions = exports.MessageCommandBuilder = void 0;
5
4
  const builders_1 = require("../../types/builders");
5
+ const MessageCommandOptionManager_1 = require("../MessageCommandOptionManager");
6
+ const MessageCommandOptionBuilder_1 = require("./MessageCommandOptionBuilder");
7
+ /**
8
+ * Reciple builder for message command
9
+ */
6
10
  class MessageCommandBuilder {
7
11
  constructor() {
8
12
  this.builder = builders_1.RecipleCommandBuilderType.MessageCommand;
@@ -13,13 +17,14 @@ class MessageCommandBuilder {
13
17
  this.options = [];
14
18
  this.validateOptions = false;
15
19
  this.requiredBotPermissions = [];
16
- this.RequiredUserPermissions = [];
20
+ this.requiredMemberPermissions = [];
17
21
  this.allowExecuteInDM = true;
18
22
  this.allowExecuteByBots = false;
19
23
  this.execute = () => { };
20
24
  }
21
25
  /**
22
26
  * Sets the command name
27
+ * @param name Command name
23
28
  */
24
29
  setName(name) {
25
30
  if (!name || typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
@@ -29,6 +34,7 @@ class MessageCommandBuilder {
29
34
  }
30
35
  /**
31
36
  * Sets the command description
37
+ * @param description Command description
32
38
  */
33
39
  setDescription(description) {
34
40
  if (!description || typeof description !== 'string')
@@ -39,6 +45,7 @@ class MessageCommandBuilder {
39
45
  /**
40
46
  * Sets the execute cooldown for this command.
41
47
  * - `0` means no cooldown
48
+ * @param cooldown Command cooldown in milliseconds
42
49
  */
43
50
  setCooldown(cooldown) {
44
51
  this.cooldown = cooldown;
@@ -46,6 +53,7 @@ class MessageCommandBuilder {
46
53
  }
47
54
  /**
48
55
  * Add aliases to the command
56
+ * @param aliases Command aliases
49
57
  */
50
58
  addAliases(...aliases) {
51
59
  if (!aliases.length)
@@ -58,21 +66,24 @@ class MessageCommandBuilder {
58
66
  return this;
59
67
  }
60
68
  /**
61
- * Set required per
69
+ * Set required bot permissions to execute the command
70
+ * @param permissions Bot's required permissions
62
71
  */
63
72
  setRequiredBotPermissions(...permissions) {
64
73
  this.requiredBotPermissions = permissions;
65
74
  return this;
66
75
  }
67
76
  /**
68
- * Set required user permissions to execute the command
77
+ * Set required permissions to execute the command
78
+ * @param permissions User's return permissions
69
79
  */
70
80
  setRequiredMemberPermissions(...permissions) {
71
- this.RequiredUserPermissions = permissions;
81
+ this.requiredMemberPermissions = permissions;
72
82
  return this;
73
83
  }
74
84
  /**
75
85
  * Set if command can be executed in dms
86
+ * @param allowExecuteInDM `true` if the command can execute in DMs
76
87
  */
77
88
  setAllowExecuteInDM(allowExecuteInDM) {
78
89
  if (typeof allowExecuteInDM !== 'boolean')
@@ -82,6 +93,7 @@ class MessageCommandBuilder {
82
93
  }
83
94
  /**
84
95
  * Allow command to be executed by bots
96
+ * @param allowExecuteByBots `true` if the command can be executed by bots
85
97
  */
86
98
  setAllowExecuteByBots(allowExecuteByBots) {
87
99
  if (typeof allowExecuteByBots !== 'boolean')
@@ -90,7 +102,8 @@ class MessageCommandBuilder {
90
102
  return this;
91
103
  }
92
104
  /**
93
- * Function when the command is interupted before execution
105
+ * Function when the command is interupted
106
+ * @param halt Function to execute when command is halted
94
107
  */
95
108
  setHalt(halt) {
96
109
  this.halt = halt ? halt : undefined;
@@ -98,6 +111,7 @@ class MessageCommandBuilder {
98
111
  }
99
112
  /**
100
113
  * Function when the command is executed
114
+ * @param execute Function to execute when the command is called
101
115
  */
102
116
  setExecute(execute) {
103
117
  if (!execute || typeof execute !== 'function')
@@ -107,6 +121,7 @@ class MessageCommandBuilder {
107
121
  }
108
122
  /**
109
123
  * Add option to the command
124
+ * @param option Message option builder
110
125
  */
111
126
  addOption(option) {
112
127
  if (!option)
@@ -121,6 +136,7 @@ class MessageCommandBuilder {
121
136
  }
122
137
  /**
123
138
  * Validate options before executing
139
+ * @param validateOptions `true` if the command options needs to be validated before executing
124
140
  */
125
141
  setValidateOptions(validateOptions) {
126
142
  if (typeof validateOptions !== 'boolean')
@@ -130,39 +146,46 @@ class MessageCommandBuilder {
130
146
  }
131
147
  /**
132
148
  * validate given command options
149
+ * @deprecated use `validateMessageCommandOptions()` instead
150
+ * @param options Parsed message command data
133
151
  */
152
+ // TODO: Remove this on the next major update
134
153
  getCommandOptionValues(options) {
135
- const args = options.args || [];
136
- const required = this.options.filter(o => o.required);
137
- const optional = this.options.filter(o => !o.required);
138
- const allOptions = [...required, ...optional];
139
- const result = [];
140
- let i = 0;
141
- for (const option of allOptions) {
142
- const arg = args[i];
143
- const value = {
144
- name: option.name,
145
- value: arg !== null && arg !== void 0 ? arg : undefined,
146
- required: option.required,
147
- invalid: false,
148
- missing: false
149
- };
150
- if (arg == undefined && option.required) {
151
- value.missing = true;
152
- result.push(value);
153
- continue;
154
- }
155
- if (arg == undefined && !option.required) {
156
- result.push(value);
157
- continue;
158
- }
159
- const validate = option.validator ? option.validator(arg) : true;
160
- if (!validate)
161
- value.invalid = true;
154
+ return validateMessageCommandOptions(this, options);
155
+ }
156
+ }
157
+ exports.MessageCommandBuilder = MessageCommandBuilder;
158
+ function validateMessageCommandOptions(builder, options) {
159
+ const args = options.args || [];
160
+ const required = builder.options.filter(o => o.required);
161
+ const optional = builder.options.filter(o => !o.required);
162
+ const allOptions = [...required, ...optional];
163
+ const result = [];
164
+ let i = 0;
165
+ for (const option of allOptions) {
166
+ const arg = args[i];
167
+ const value = {
168
+ name: option.name,
169
+ value: arg !== null && arg !== void 0 ? arg : undefined,
170
+ required: option.required,
171
+ invalid: false,
172
+ missing: false
173
+ };
174
+ if (arg == undefined && option.required) {
175
+ value.missing = true;
176
+ result.push(value);
177
+ continue;
178
+ }
179
+ if (arg == undefined && !option.required) {
162
180
  result.push(value);
163
- i++;
181
+ continue;
164
182
  }
165
- return result;
183
+ const validate = option.validator ? option.validator(arg) : true;
184
+ if (!validate)
185
+ value.invalid = true;
186
+ result.push(value);
187
+ i++;
166
188
  }
189
+ return new MessageCommandOptionManager_1.MessageCommandOptionManager(result);
167
190
  }
168
- exports.MessageCommandBuilder = MessageCommandBuilder;
191
+ exports.validateMessageCommandOptions = validateMessageCommandOptions;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Option builder for MessageCommandBuilder
3
+ */
1
4
  export declare class MessageCommandOptionBuilder {
2
5
  name: string;
3
6
  description: string;
@@ -5,18 +8,22 @@ export declare class MessageCommandOptionBuilder {
5
8
  validator: (value: string) => boolean;
6
9
  /**
7
10
  * Set command option name
11
+ * @param name Option name
8
12
  */
9
13
  setName(name: string): MessageCommandOptionBuilder;
10
14
  /**
11
15
  * Set command option description
16
+ * @param description Option description
12
17
  */
13
18
  setDescription(description: string): MessageCommandOptionBuilder;
14
19
  /**
15
20
  * Set if this option is required
21
+ * @param required `true` if this option is required
16
22
  */
17
23
  setRequired(required: boolean): MessageCommandOptionBuilder;
18
24
  /**
19
25
  * Set your custom function to validate given value for this option
26
+ * @param validator Custom function to validate value given for this option
20
27
  */
21
28
  setValidator(validator: (value: string) => boolean): MessageCommandOptionBuilder;
22
29
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageCommandOptionBuilder = void 0;
4
+ /**
5
+ * Option builder for MessageCommandBuilder
6
+ */
4
7
  class MessageCommandOptionBuilder {
5
8
  constructor() {
6
9
  this.name = '';
@@ -10,6 +13,7 @@ class MessageCommandOptionBuilder {
10
13
  }
11
14
  /**
12
15
  * Set command option name
16
+ * @param name Option name
13
17
  */
14
18
  setName(name) {
15
19
  if (typeof name !== 'string' || !name.match(/^[\w-]{1,32}$/))
@@ -19,6 +23,7 @@ class MessageCommandOptionBuilder {
19
23
  }
20
24
  /**
21
25
  * Set command option description
26
+ * @param description Option description
22
27
  */
23
28
  setDescription(description) {
24
29
  if (!description || typeof description !== 'string')
@@ -28,6 +33,7 @@ class MessageCommandOptionBuilder {
28
33
  }
29
34
  /**
30
35
  * Set if this option is required
36
+ * @param required `true` if this option is required
31
37
  */
32
38
  setRequired(required) {
33
39
  if (typeof required !== 'boolean')
@@ -37,6 +43,7 @@ class MessageCommandOptionBuilder {
37
43
  }
38
44
  /**
39
45
  * Set your custom function to validate given value for this option
46
+ * @param validator Custom function to validate value given for this option
40
47
  */
41
48
  setValidator(validator) {
42
49
  if (!validator || typeof validator !== 'function')
@@ -1,5 +1,16 @@
1
1
  import { Logger } from 'fallout-utility';
2
2
  /**
3
3
  * Create new logger
4
+ * @param stringifyJSON stringify json objects in console
5
+ * @param debugmode display debug messages
6
+ * @param colorizeMessage add logger colours to messages
7
+ */
8
+ export declare function createLogger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
9
+ /**
10
+ * Create new logger
11
+ * @deprecated Use `createLogger` instead
12
+ * @param stringifyJSON stringify json objects in console
13
+ * @param debugmode display debug messages
14
+ * @param colorizeMessage add logger colours to messages
4
15
  */
5
16
  export declare function logger(stringifyJSON: boolean, debugmode?: boolean, colorizeMessage?: boolean): Logger;
@@ -3,14 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logger = void 0;
7
- const fallout_utility_1 = require("fallout-utility");
6
+ exports.logger = exports.createLogger = void 0;
8
7
  const flags_1 = require("./flags");
9
8
  const chalk_1 = __importDefault(require("chalk"));
9
+ const fallout_utility_1 = require("fallout-utility");
10
10
  /**
11
11
  * Create new logger
12
+ * @param stringifyJSON stringify json objects in console
13
+ * @param debugmode display debug messages
14
+ * @param colorizeMessage add logger colours to messages
12
15
  */
13
- function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
16
+ function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true) {
14
17
  var _a;
15
18
  return new fallout_utility_1.Logger({
16
19
  stringifyJSON: stringifyJSON,
@@ -30,4 +33,17 @@ function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
30
33
  }
31
34
  });
32
35
  }
36
+ exports.createLogger = createLogger;
37
+ /**
38
+ * Create new logger
39
+ * @deprecated Use `createLogger` instead
40
+ * @param stringifyJSON stringify json objects in console
41
+ * @param debugmode display debug messages
42
+ * @param colorizeMessage add logger colours to messages
43
+ */
44
+ // TODO: Remove this on next major release
45
+ function logger(stringifyJSON, debugmode = false, colorizeMessage = true) {
46
+ process.emitWarning('logger() is deprecated use createLogger() instead', 'DeprecationWarning');
47
+ return createLogger(stringifyJSON, debugmode, colorizeMessage);
48
+ }
33
49
  exports.logger = logger;