reciple 1.0.17 → 1.0.19

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/bin/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './reciple/classes/Client';
2
2
  export * from './reciple/classes/Config';
3
- export * from './reciple/classes/builders/MessageCommandBuilder';
4
3
  export * from './reciple/classes/builders/InteractionCommandBuilder';
4
+ export * from './reciple/classes/builders/MessageCommandBuilder';
5
5
  export * from './reciple/commandPermissions';
6
6
  export * from './reciple/flags';
7
7
  export * from './reciple/isIgnoredChannel';
package/bin/index.js CHANGED
@@ -16,8 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./reciple/classes/Client"), exports);
18
18
  __exportStar(require("./reciple/classes/Config"), exports);
19
- __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
20
19
  __exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
20
+ __exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
21
21
  __exportStar(require("./reciple/commandPermissions"), exports);
22
22
  __exportStar(require("./reciple/flags"), exports);
23
23
  __exportStar(require("./reciple/isIgnoredChannel"), exports);
@@ -85,7 +85,7 @@ class RecipleClient extends discord_js_1.Client {
85
85
  const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
86
86
  if (!command)
87
87
  return this;
88
- if ((0, commandPermissions_1.commandPermissions)(command.name, ((_d = message.member) === null || _d === void 0 ? void 0 : _d.permissions) || null, (_e = this.config) === null || _e === void 0 ? void 0 : _e.permissions.messageCommands)) {
88
+ 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)) {
89
89
  if (!command.allowExecuteInDM && message.channel.type === 'DM' || !command.allowExecuteByBots && (message.author.bot || message.author.system) || (0, isIgnoredChannel_1.isIgnoredChannel)(message.channelId, (_f = this.config) === null || _f === void 0 ? void 0 : _f.ignoredChannels))
90
90
  return this;
91
91
  if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
@@ -109,13 +109,13 @@ class RecipleClient extends discord_js_1.Client {
109
109
  });
110
110
  }
111
111
  interactionCommandExecute(interaction) {
112
- var _a, _b, _c, _d;
112
+ var _a, _b, _c, _d, _e;
113
113
  return __awaiter(this, void 0, void 0, function* () {
114
114
  if (!interaction || !interaction.isCommand() || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.enabled))
115
115
  return this;
116
116
  const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
117
- if ((0, commandPermissions_1.commandPermissions)(command.name, interaction.memberPermissions, (_b = this.config) === null || _b === void 0 ? void 0 : _b.permissions.interactionCommands)) {
118
- if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (_c = this.config) === null || _c === void 0 ? void 0 : _c.ignoredChannels))
117
+ if ((0, commandPermissions_1.commandPermissions)(command.name, (_b = interaction.memberPermissions) !== null && _b !== void 0 ? _b : undefined, (_c = this.config) === null || _c === void 0 ? void 0 : _c.permissions.interactionCommands, command)) {
118
+ if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (_d = this.config) === null || _d === void 0 ? void 0 : _d.ignoredChannels))
119
119
  return this;
120
120
  if (!command)
121
121
  return this;
@@ -129,7 +129,7 @@ class RecipleClient extends discord_js_1.Client {
129
129
  this.emit('recipleInteractionCommandCreate', options);
130
130
  }
131
131
  else {
132
- yield interaction.reply(((_d = this.config) === null || _d === void 0 ? void 0 : _d.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
132
+ yield interaction.reply(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
133
133
  }
134
134
  return this;
135
135
  });
@@ -149,11 +149,11 @@ class RecipleClient extends discord_js_1.Client {
149
149
  else if (command === null || command === void 0 ? void 0 : command.interaction) {
150
150
  if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
151
151
  return;
152
- if (!(command === null || command === void 0 ? void 0 : command.interaction.deferred)) {
152
+ if (!(command === null || command === void 0 ? void 0 : command.interaction.deferred) && !(command === null || command === void 0 ? void 0 : command.interaction.replied)) {
153
153
  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));
154
154
  }
155
155
  else {
156
- yield command.interaction.editReply(((_e = this.config) === null || _e === void 0 ? void 0 : _e.messages.error) || 'An error occured.').catch((e) => this.logger.error(e));
156
+ 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));
157
157
  }
158
158
  }
159
159
  });
@@ -1,5 +1,5 @@
1
1
  import { SlashCommandBuilder } from '@discordjs/builders';
2
- import { CommandInteraction } from 'discord.js';
2
+ import { CommandInteraction, PermissionFlags } from 'discord.js';
3
3
  import { RecipleClient } from '../Client';
4
4
  export interface RecipleInteractionCommandExecute {
5
5
  interaction: CommandInteraction;
@@ -9,8 +9,10 @@ export interface RecipleInteractionCommandExecute {
9
9
  }
10
10
  export declare class InteractionCommandBuilder extends SlashCommandBuilder {
11
11
  readonly type: string;
12
+ requiredPermissions: (keyof PermissionFlags)[];
12
13
  allowExecuteInDM: boolean;
13
14
  execute: (options: RecipleInteractionCommandExecute) => void;
15
+ setRequiredPermissions(requiredPermissions: (keyof PermissionFlags)[]): InteractionCommandBuilder;
14
16
  setAllowExecuteInDM(allowExecuteInDM: boolean): InteractionCommandBuilder;
15
17
  setExecute(execute: (options: RecipleInteractionCommandExecute) => void): InteractionCommandBuilder;
16
18
  }
@@ -6,9 +6,16 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
  this.type = 'INTERACTION_COMMAND';
9
+ this.requiredPermissions = [];
9
10
  this.allowExecuteInDM = true;
10
11
  this.execute = (options) => { };
11
12
  }
13
+ setRequiredPermissions(requiredPermissions) {
14
+ if (!requiredPermissions || !Array.isArray(requiredPermissions))
15
+ throw new Error('requiredPermissions must be an array.');
16
+ this.requiredPermissions = requiredPermissions;
17
+ return this;
18
+ }
12
19
  setAllowExecuteInDM(allowExecuteInDM) {
13
20
  if (typeof allowExecuteInDM !== 'boolean')
14
21
  throw new Error('allowExecuteInDM must be a boolean.');
@@ -1,4 +1,4 @@
1
- import { Message } from 'discord.js';
1
+ import { Message, PermissionFlags } from 'discord.js';
2
2
  import { Command } from 'fallout-utility';
3
3
  import { RecipleClient } from '../Client';
4
4
  export interface CommandMessage extends Command {
@@ -35,10 +35,12 @@ export declare class MessageCommandBuilder {
35
35
  description: string;
36
36
  options: MessageOption[];
37
37
  validateOptions: boolean;
38
+ requiredPermissions: (keyof PermissionFlags)[];
38
39
  allowExecuteInDM: boolean;
39
40
  allowExecuteByBots: boolean;
40
41
  execute: (options: RecipleMessageCommandExecute) => void;
41
42
  setName(name: string): MessageCommandBuilder;
43
+ setRequiredPermissions(permissions: (keyof PermissionFlags)[]): MessageCommandBuilder;
42
44
  setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
43
45
  setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
44
46
  setDescription(description: string): MessageCommandBuilder;
@@ -41,6 +41,7 @@ class MessageCommandBuilder {
41
41
  this.description = '';
42
42
  this.options = [];
43
43
  this.validateOptions = false;
44
+ this.requiredPermissions = [];
44
45
  this.allowExecuteInDM = true;
45
46
  this.allowExecuteByBots = false;
46
47
  this.execute = (options) => { };
@@ -51,6 +52,12 @@ class MessageCommandBuilder {
51
52
  this.name = name;
52
53
  return this;
53
54
  }
55
+ setRequiredPermissions(permissions) {
56
+ if (!permissions || !Array.isArray(permissions))
57
+ throw new Error('permissions must be an array.');
58
+ this.requiredPermissions = permissions;
59
+ return this;
60
+ }
54
61
  setAllowExecuteInDM(allowExecuteInDM) {
55
62
  if (typeof allowExecuteInDM !== 'boolean')
56
63
  throw new Error('allowExecuteInDM must be a boolean.');
@@ -1,3 +1,5 @@
1
1
  import { Permissions } from "discord.js";
2
+ import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
3
+ import { MessageCommandBuilder } from './classes/builders/MessageCommandBuilder';
2
4
  import { Config } from "./classes/Config";
3
- export declare function commandPermissions(commandName: string, memberPermissions: Permissions | null, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands']): boolean;
5
+ export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: InteractionCommandBuilder | MessageCommandBuilder): boolean;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commandPermissions = void 0;
4
- function commandPermissions(commandName, memberPermissions, configConmmandPermissions) {
4
+ function commandPermissions(commandName, memberPermissions, configConmmandPermissions, builder) {
5
+ var _a, _b;
5
6
  if (!(configConmmandPermissions === null || configConmmandPermissions === void 0 ? void 0 : configConmmandPermissions.enabled))
6
7
  return true;
7
- const command = configConmmandPermissions.commands.find(c => c.command.toLowerCase() === commandName.toLowerCase());
8
- if (!command)
9
- return true;
8
+ const command = (_a = configConmmandPermissions.commands.find(c => c.command.toLowerCase() === commandName.toLowerCase())) !== null && _a !== void 0 ? _a : { permissions: (_b = builder === null || builder === void 0 ? void 0 : builder.requiredPermissions) !== null && _b !== void 0 ? _b : [] };
10
9
  if (!command.permissions.length)
11
10
  return true;
12
11
  return memberPermissions ? memberPermissions.has(command.permissions) : false;
@@ -4,5 +4,6 @@ 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('-D, --debugmode', 'Enabled debug mode')
7
8
  .parse().opts();
8
9
  exports.token = exports.flags.token;
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logger = void 0;
4
4
  const fallout_utility_1 = require("fallout-utility");
5
+ const flags_1 = require("./flags");
5
6
  function logger(stringifyJSON, debugmode = false) {
6
7
  return new fallout_utility_1.Logger("Main", {
7
8
  addPrefixToEveryJsonNewLines: stringifyJSON,
8
9
  stringifyJSON: stringifyJSON,
9
- setDebugging: debugmode
10
+ setDebugging: flags_1.flags.debugmode || debugmode
10
11
  });
11
12
  }
12
13
  exports.logger = logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reciple",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "A Discord.js bot",
5
5
  "author": "FalloutStudios",
6
6
  "license": "GPL-3.0",