reciple 5.4.1-pre.5 → 5.4.3
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/{types/bin.d.ts → bin.d.ts} +0 -0
- package/bin/{cjs/bin.js → bin.js} +11 -22
- package/bin/{types/index.d.ts → index.d.ts} +0 -0
- package/bin/{cjs/index.js → index.js} +0 -0
- package/bin/{types/reciple → reciple}/classes/CommandCooldownManager.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/CommandCooldownManager.js +12 -8
- package/bin/{types/reciple → reciple}/classes/MessageCommandOptionManager.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/MessageCommandOptionManager.js +4 -5
- package/bin/{types/reciple → reciple}/classes/RecipleClient.d.ts +4 -4
- package/bin/{mjs/reciple → reciple}/classes/RecipleClient.js +68 -61
- package/bin/{types/reciple → reciple}/classes/RecipleConfig.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/RecipleConfig.js +6 -9
- package/bin/{types/reciple → reciple}/classes/builders/MessageCommandBuilder.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/builders/MessageCommandBuilder.js +22 -17
- package/bin/{types/reciple → reciple}/classes/builders/MessageCommandOptionBuilder.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/classes/builders/MessageCommandOptionBuilder.js +5 -1
- package/bin/{types/reciple → reciple}/classes/builders/SlashCommandBuilder.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/classes/builders/SlashCommandBuilder.js +29 -29
- package/bin/{types/reciple → reciple}/flags.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/flags.js +0 -0
- package/bin/{types/reciple → reciple}/logger.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/logger.js +1 -2
- package/bin/{types/reciple → reciple}/modules.d.ts +0 -0
- package/bin/reciple/modules.js +113 -0
- package/bin/{types/reciple → reciple}/permissions.d.ts +6 -2
- package/bin/reciple/permissions.js +34 -0
- package/bin/{types/reciple → reciple}/registerApplicationCommands.d.ts +0 -0
- package/bin/{mjs/reciple → reciple}/registerApplicationCommands.js +9 -5
- package/bin/{types/reciple → reciple}/types/builders.d.ts +1 -1
- package/bin/{cjs/reciple → reciple}/types/builders.js +0 -0
- package/bin/{types/reciple → reciple}/types/commands.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/types/commands.js +0 -0
- package/bin/{types/reciple → reciple}/types/paramOptions.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/types/paramOptions.js +0 -0
- package/bin/{types/reciple → reciple}/util.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/util.js +0 -0
- package/bin/{types/reciple → reciple}/version.d.ts +0 -0
- package/bin/{cjs/reciple → reciple}/version.js +0 -0
- package/package.json +10 -14
- package/bin/cjs/package.json +0 -3
- package/bin/cjs/reciple/classes/CommandCooldownManager.js +0 -92
- package/bin/cjs/reciple/classes/RecipleClient.js +0 -400
- package/bin/cjs/reciple/classes/builders/MessageCommandBuilder.js +0 -233
- package/bin/cjs/reciple/classes/builders/MessageCommandOptionBuilder.js +0 -71
- package/bin/cjs/reciple/modules.js +0 -100
- package/bin/cjs/reciple/permissions.js +0 -28
- package/bin/cjs/reciple/registerApplicationCommands.js +0 -64
- package/bin/mjs/bin.js +0 -46
- package/bin/mjs/index.js +0 -17
- package/bin/mjs/package.json +0 -3
- package/bin/mjs/reciple/classes/MessageCommandOptionManager.js +0 -21
- package/bin/mjs/reciple/classes/RecipleConfig.js +0 -92
- package/bin/mjs/reciple/classes/builders/SlashCommandBuilder.js +0 -204
- package/bin/mjs/reciple/flags.js +0 -28
- package/bin/mjs/reciple/logger.js +0 -28
- package/bin/mjs/reciple/modules.js +0 -81
- package/bin/mjs/reciple/permissions.js +0 -23
- package/bin/mjs/reciple/types/builders.js +0 -8
- package/bin/mjs/reciple/types/commands.js +0 -12
- package/bin/mjs/reciple/types/paramOptions.js +0 -1
- package/bin/mjs/reciple/util.js +0 -7
- package/bin/mjs/reciple/version.js +0 -38
|
File without changes
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommandOptionBuilder = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Option builder for MessageCommandBuilder
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
class MessageCommandOptionBuilder {
|
|
5
8
|
name = '';
|
|
6
9
|
description = '';
|
|
7
10
|
required = false;
|
|
@@ -65,3 +68,4 @@ export class MessageCommandOptionBuilder {
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
}
|
|
71
|
+
exports.MessageCommandOptionBuilder = MessageCommandOptionBuilder;
|
|
File without changes
|
|
@@ -8,38 +8,39 @@ const discord_js_1 = require("discord.js");
|
|
|
8
8
|
* Reciple builder for slash command
|
|
9
9
|
*/
|
|
10
10
|
class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
11
|
+
type = builders_1.CommandBuilderType.SlashCommand;
|
|
12
|
+
cooldown = 0;
|
|
13
|
+
requiredBotPermissions = [];
|
|
14
|
+
requiredMemberPermissions = [];
|
|
15
|
+
halt;
|
|
16
|
+
execute = () => { };
|
|
11
17
|
constructor(data) {
|
|
12
18
|
super();
|
|
13
|
-
|
|
14
|
-
this.cooldown = 0;
|
|
15
|
-
this.requiredBotPermissions = [];
|
|
16
|
-
this.requiredMemberPermissions = [];
|
|
17
|
-
this.execute = () => { };
|
|
18
|
-
if ((data === null || data === void 0 ? void 0 : data.name) !== undefined)
|
|
19
|
+
if (data?.name !== undefined)
|
|
19
20
|
this.setName(data.name);
|
|
20
|
-
if (
|
|
21
|
+
if (data?.description !== undefined)
|
|
21
22
|
this.setDescription(data.description);
|
|
22
|
-
if (
|
|
23
|
-
this.setCooldown(Number(data
|
|
24
|
-
if (
|
|
23
|
+
if (data?.cooldown !== undefined)
|
|
24
|
+
this.setCooldown(Number(data?.cooldown));
|
|
25
|
+
if (data?.requiredBotPermissions !== undefined)
|
|
25
26
|
this.setRequiredBotPermissions(data.requiredBotPermissions);
|
|
26
|
-
if (
|
|
27
|
+
if (data?.requiredMemberPermissions !== undefined)
|
|
27
28
|
this.setRequiredMemberPermissions(data.requiredMemberPermissions);
|
|
28
|
-
if (
|
|
29
|
-
this.setHalt(
|
|
30
|
-
if (
|
|
29
|
+
if (data?.halt !== undefined)
|
|
30
|
+
this.setHalt(data.halt);
|
|
31
|
+
if (data?.execute !== undefined)
|
|
31
32
|
this.setExecute(data.execute);
|
|
32
|
-
if (
|
|
33
|
+
if (data?.nameLocalizations !== undefined)
|
|
33
34
|
this.setNameLocalizations(data.nameLocalizations);
|
|
34
|
-
if (
|
|
35
|
+
if (data?.descriptionLocalizations !== undefined)
|
|
35
36
|
this.setDescriptionLocalizations(data.descriptionLocalizations);
|
|
36
|
-
if (
|
|
37
|
+
if (data?.defaultMemberPermissions !== undefined)
|
|
37
38
|
this.setDefaultMemberPermissions(data.defaultMemberPermissions);
|
|
38
|
-
if (data
|
|
39
|
+
if (data?.dmPermission !== undefined)
|
|
39
40
|
this.setDMPermission(true);
|
|
40
|
-
if (data
|
|
41
|
+
if (data?.defaultPermission !== undefined)
|
|
41
42
|
this.setDefaultPermission(true);
|
|
42
|
-
if (data
|
|
43
|
+
if (data?.options) {
|
|
43
44
|
for (const option of data.options) {
|
|
44
45
|
SlashCommandBuilder.addOption(this, (0, util_1.isClass)(option) ? option : SlashCommandBuilder.resolveOption(option));
|
|
45
46
|
}
|
|
@@ -58,7 +59,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
58
59
|
return this;
|
|
59
60
|
}
|
|
60
61
|
setHalt(halt) {
|
|
61
|
-
this.halt = halt
|
|
62
|
+
this.halt = halt ?? undefined;
|
|
62
63
|
return this;
|
|
63
64
|
}
|
|
64
65
|
setExecute(execute) {
|
|
@@ -112,7 +113,6 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
112
113
|
* Resolve option data
|
|
113
114
|
*/
|
|
114
115
|
static resolveOption(option) {
|
|
115
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
116
116
|
let builder;
|
|
117
117
|
switch (option.type) {
|
|
118
118
|
case discord_js_1.ApplicationCommandOptionType.Attachment:
|
|
@@ -123,11 +123,11 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
123
123
|
break;
|
|
124
124
|
case discord_js_1.ApplicationCommandOptionType.Channel:
|
|
125
125
|
builder = new discord_js_1.SlashCommandChannelOption()
|
|
126
|
-
.addChannelTypes(...(
|
|
126
|
+
.addChannelTypes(...(option.channelTypes ?? []));
|
|
127
127
|
break;
|
|
128
128
|
case discord_js_1.ApplicationCommandOptionType.Integer:
|
|
129
129
|
builder = new discord_js_1.SlashCommandIntegerOption()
|
|
130
|
-
.addChoices(...(
|
|
130
|
+
.addChoices(...(option.choices ?? []))
|
|
131
131
|
.setAutocomplete(!!option.autocomplete);
|
|
132
132
|
if (option.maxValue)
|
|
133
133
|
builder.setMaxValue(option.maxValue);
|
|
@@ -139,7 +139,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
139
139
|
break;
|
|
140
140
|
case discord_js_1.ApplicationCommandOptionType.Number:
|
|
141
141
|
builder = new discord_js_1.SlashCommandNumberOption()
|
|
142
|
-
.addChoices(...(
|
|
142
|
+
.addChoices(...(option.choices ?? []))
|
|
143
143
|
.setAutocomplete(!!option.autocomplete);
|
|
144
144
|
if (option.maxValue)
|
|
145
145
|
builder.setMaxValue(option.maxValue);
|
|
@@ -151,7 +151,7 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
151
151
|
break;
|
|
152
152
|
case discord_js_1.ApplicationCommandOptionType.String:
|
|
153
153
|
builder = new discord_js_1.SlashCommandStringOption()
|
|
154
|
-
.addChoices(...(
|
|
154
|
+
.addChoices(...(option.choices ?? []))
|
|
155
155
|
.setAutocomplete(!!option.autocomplete);
|
|
156
156
|
if (option.maxLength)
|
|
157
157
|
builder.setMaxLength(option.maxLength);
|
|
@@ -181,13 +181,13 @@ class SlashCommandBuilder extends discord_js_1.SlashCommandBuilder {
|
|
|
181
181
|
if (!(builder instanceof discord_js_1.SlashCommandSubcommandBuilder) && !(builder instanceof discord_js_1.SlashCommandSubcommandGroupBuilder)
|
|
182
182
|
&&
|
|
183
183
|
option.type !== discord_js_1.ApplicationCommandOptionType.Subcommand && option.type !== discord_js_1.ApplicationCommandOptionType.SubcommandGroup) {
|
|
184
|
-
builder.setRequired(
|
|
184
|
+
builder.setRequired(option.required ?? false);
|
|
185
185
|
}
|
|
186
186
|
return builder
|
|
187
187
|
.setName(option.name)
|
|
188
188
|
.setDescription(option.description)
|
|
189
|
-
.setNameLocalizations(
|
|
190
|
-
.setDescriptionLocalizations(
|
|
189
|
+
.setNameLocalizations(option.nameLocalizations ?? null)
|
|
190
|
+
.setDescriptionLocalizations(option.descriptionLocalizations ?? null);
|
|
191
191
|
}
|
|
192
192
|
static resolveSlashCommand(commandData) {
|
|
193
193
|
return this.isSlashCommandBuilder(commandData) ? commandData : new SlashCommandBuilder(commandData);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -14,10 +14,9 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
14
14
|
* @param colorizeMessage add logger colours to messages
|
|
15
15
|
*/
|
|
16
16
|
function createLogger(stringifyJSON, debugmode = false, colorizeMessage = true) {
|
|
17
|
-
var _a;
|
|
18
17
|
return new fallout_utility_1.Logger({
|
|
19
18
|
stringifyJSON: stringifyJSON,
|
|
20
|
-
enableDebugMode:
|
|
19
|
+
enableDebugMode: flags_1.flags.debugmode ?? debugmode,
|
|
21
20
|
loggerName: 'Main',
|
|
22
21
|
prefixes: {
|
|
23
22
|
[fallout_utility_1.LogLevels.INFO]: (name) => `[${new Date().toLocaleTimeString(undefined, { hour12: false })}][${(name ? name + "/" : '') + "INFO"}]`,
|
|
File without changes
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getModules = void 0;
|
|
30
|
+
const builders_1 = require("./types/builders");
|
|
31
|
+
const MessageCommandBuilder_1 = require("./classes/builders/MessageCommandBuilder");
|
|
32
|
+
const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
|
|
33
|
+
const discord_js_1 = require("discord.js");
|
|
34
|
+
const version_1 = require("./version");
|
|
35
|
+
const fs_1 = require("fs");
|
|
36
|
+
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
37
|
+
const flags_1 = require("./flags");
|
|
38
|
+
const path_1 = __importDefault(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Load modules from folder
|
|
41
|
+
* @param client Reciple client
|
|
42
|
+
* @param folder Modules folder
|
|
43
|
+
*/
|
|
44
|
+
async function getModules(client, folder) {
|
|
45
|
+
const response = { commands: [], modules: [] };
|
|
46
|
+
const modulesDir = folder || path_1.default.join(flags_1.cwd, 'modules');
|
|
47
|
+
if (!(0, fs_1.existsSync)(modulesDir))
|
|
48
|
+
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
49
|
+
const ignoredFiles = (client.config.ignoredFiles || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
|
|
50
|
+
const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
|
|
51
|
+
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
|
|
52
|
+
});
|
|
53
|
+
for (const script of scripts) {
|
|
54
|
+
const modulePath = path_1.default.join(modulesDir, script);
|
|
55
|
+
const commands = [];
|
|
56
|
+
let module_;
|
|
57
|
+
try {
|
|
58
|
+
const reqMod = await Promise.resolve().then(() => __importStar(require(modulePath)));
|
|
59
|
+
module_ = reqMod?.default !== undefined ? reqMod.default : reqMod;
|
|
60
|
+
if (typeof module_ !== 'object')
|
|
61
|
+
throw new Error(`Module ${modulePath} is not an object`);
|
|
62
|
+
if (!client.config.disableVersionCheck && !module_?.versions.length)
|
|
63
|
+
throw new Error(`${modulePath} does not have supported versions.`);
|
|
64
|
+
const versions = (0, discord_js_1.normalizeArray)([module_.versions]);
|
|
65
|
+
if (!client.config.disableVersionCheck && !versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
|
|
66
|
+
throw new Error(`${modulePath} is unsupported; current version: ${version_1.version}; module supported versions: ` + versions.join(', ') ?? 'none');
|
|
67
|
+
if (!await Promise.resolve(module_.onStart(client)).catch(() => false))
|
|
68
|
+
throw new Error(script + ' onStart returned false or undefined.');
|
|
69
|
+
if (module_.commands) {
|
|
70
|
+
for (const command of module_.commands) {
|
|
71
|
+
if (command.type === builders_1.CommandBuilderType.MessageCommand) {
|
|
72
|
+
commands.push(MessageCommandBuilder_1.MessageCommandBuilder.resolveMessageCommand(command));
|
|
73
|
+
}
|
|
74
|
+
else if (command.type === builders_1.CommandBuilderType.SlashCommand) {
|
|
75
|
+
commands.push(SlashCommandBuilder_1.SlashCommandBuilder.resolveSlashCommand(command));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (client.isClientLogsEnabled()) {
|
|
82
|
+
client.logger.error(`Failed to load module ${script}`);
|
|
83
|
+
client.logger.error(error);
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
response.commands.push(...commands.filter((c) => {
|
|
88
|
+
if (!c.name) {
|
|
89
|
+
if (client.isClientLogsEnabled())
|
|
90
|
+
client.logger.error(`A ${builders_1.CommandBuilderType[c.type]} command name is not defined in ${modulePath}`);
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (c.type === builders_1.CommandBuilderType.MessageCommand && c.options.length && c.options.some(o => !o.name)) {
|
|
94
|
+
if (client.isClientLogsEnabled())
|
|
95
|
+
client.logger.error(`A ${builders_1.CommandBuilderType[c.type]} option name is not defined in ${modulePath}`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}));
|
|
100
|
+
response.modules.push({
|
|
101
|
+
script: module_,
|
|
102
|
+
info: {
|
|
103
|
+
filename: script,
|
|
104
|
+
versions: (0, discord_js_1.normalizeArray)([module_.versions]),
|
|
105
|
+
path: modulePath
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (client.isClientLogsEnabled())
|
|
109
|
+
client.logger.info(`Loaded module ${modulePath}`);
|
|
110
|
+
}
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
113
|
+
exports.getModules = getModules;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UserHasCommandPermissionsOptions } from './types/paramOptions';
|
|
2
|
-
import { Guild, PermissionResolvable } from 'discord.js';
|
|
2
|
+
import { Guild, GuildTextBasedChannel, PermissionResolvable } from 'discord.js';
|
|
3
3
|
/**
|
|
4
4
|
* Check if the user has permissions to execute the given command name
|
|
5
5
|
* @param options options
|
|
@@ -7,7 +7,11 @@ import { Guild, PermissionResolvable } from 'discord.js';
|
|
|
7
7
|
export declare function userHasCommandPermissions(options: UserHasCommandPermissionsOptions): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Check if the bot has the required permissions in a guild
|
|
10
|
-
* @param guild
|
|
10
|
+
* @param guild Check if the bot has the required permissions in a guild
|
|
11
11
|
* @param requiredPermissions Required guild bot permissions
|
|
12
12
|
*/
|
|
13
13
|
export declare function botHasExecutePermissions(guild?: Guild, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @param channel Check if the bot has the required permissions in a channel
|
|
16
|
+
*/
|
|
17
|
+
export declare function botHasExecutePermissions(channel?: GuildTextBasedChannel, requiredPermissions?: PermissionResolvable[]): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.botHasExecutePermissions = exports.userHasCommandPermissions = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
/**
|
|
6
|
+
* Check if the user has permissions to execute the given command name
|
|
7
|
+
* @param options options
|
|
8
|
+
*/
|
|
9
|
+
function userHasCommandPermissions(options) {
|
|
10
|
+
const command = (options.commandPermissions?.enabled
|
|
11
|
+
? options.commandPermissions?.commands.find(c => c.command.toLowerCase() === options.builder.name.toLowerCase())
|
|
12
|
+
: null)
|
|
13
|
+
?? { permissions: options.builder.requiredMemberPermissions };
|
|
14
|
+
if (!command.permissions.length)
|
|
15
|
+
return true;
|
|
16
|
+
return options.memberPermissions ? options.memberPermissions.has(command.permissions) : false;
|
|
17
|
+
}
|
|
18
|
+
exports.userHasCommandPermissions = userHasCommandPermissions;
|
|
19
|
+
/**
|
|
20
|
+
* @param guildOrChannel Check permission in a guild or channel
|
|
21
|
+
*/
|
|
22
|
+
function botHasExecutePermissions(guildOrChannel, requiredPermissions) {
|
|
23
|
+
if (!requiredPermissions?.length)
|
|
24
|
+
return true;
|
|
25
|
+
let permissions = null;
|
|
26
|
+
if (guildOrChannel instanceof discord_js_1.Guild) {
|
|
27
|
+
permissions = guildOrChannel.members.me?.permissions ?? null;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
permissions = guildOrChannel?.permissionsFor(guildOrChannel.client.user.id) ?? null;
|
|
31
|
+
}
|
|
32
|
+
return permissions ? permissions.has(requiredPermissions) : false;
|
|
33
|
+
}
|
|
34
|
+
exports.botHasExecutePermissions = botHasExecutePermissions;
|
|
File without changes
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerApplicationCommands = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const SlashCommandBuilder_1 = require("./classes/builders/SlashCommandBuilder");
|
|
3
6
|
/**
|
|
4
7
|
* Register application commands
|
|
5
8
|
* @param options Register application commands options
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
async function registerApplicationCommands(options) {
|
|
8
11
|
const client = options.client;
|
|
9
|
-
const guilds = normalizeArray(options.guilds);
|
|
12
|
+
const guilds = (0, discord_js_1.normalizeArray)(options.guilds);
|
|
10
13
|
const commands = Object.values(options.commands ?? client.commands.slashCommands).map(cmd => {
|
|
11
14
|
if (typeof cmd?.toJSON == 'undefined')
|
|
12
15
|
return cmd;
|
|
13
16
|
cmd = cmd;
|
|
14
|
-
if (SlashCommandBuilder.isSlashCommandBuilder(cmd) && client.config.commands.slashCommand.setRequiredPermissions) {
|
|
17
|
+
if (SlashCommandBuilder_1.SlashCommandBuilder.isSlashCommandBuilder(cmd) && client.config.commands.slashCommand.setRequiredPermissions) {
|
|
15
18
|
const permissions = client.config.commands.slashCommand.permissions.enabled
|
|
16
19
|
? client.config.commands.slashCommand.permissions.commands.find(cmd_ => cmd_.command.toLowerCase() === cmd.name.toLowerCase())?.permissions
|
|
17
20
|
: undefined;
|
|
@@ -45,3 +48,4 @@ export async function registerApplicationCommands(options) {
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
51
|
+
exports.registerApplicationCommands = registerApplicationCommands;
|
|
@@ -108,7 +108,7 @@ export interface SlashCommandData extends SharedCommandDataProperties, Partial<O
|
|
|
108
108
|
type: CommandBuilderType.SlashCommand;
|
|
109
109
|
nameLocalizations?: LocalizationMap;
|
|
110
110
|
descriptionLocalizations?: LocalizationMap;
|
|
111
|
-
options
|
|
111
|
+
options?: (AnySlashCommandOptionData | AnySlashCommandOptionBuilder)[];
|
|
112
112
|
/**
|
|
113
113
|
* @deprecated This property is deprecated and will be removed in the future.
|
|
114
114
|
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.3",
|
|
4
|
+
"bin": "bin/bin.js",
|
|
4
5
|
"license": "GPL-3.0",
|
|
5
|
-
"
|
|
6
|
+
"main": "bin/index.js",
|
|
7
|
+
"typings": "bin/index.d.ts",
|
|
6
8
|
"author": "FalloutStudios",
|
|
7
9
|
"description": "Handler for Discord.js",
|
|
8
10
|
"homepage": "https://reciple.js.org",
|
|
9
|
-
"main": "./bin/cjs/index.js",
|
|
10
|
-
"module": "./bin/mjs/index.js",
|
|
11
|
-
"bin": "./bin/cjs/bin.js",
|
|
12
|
-
"exports": {
|
|
13
|
-
"import": "./bin/mjs/index.js",
|
|
14
|
-
"require": "./bin/cjs/index.js"
|
|
15
|
-
},
|
|
16
11
|
"keywords": [
|
|
17
12
|
"Discord",
|
|
18
13
|
"Discord.js handler",
|
|
19
14
|
"Reciple"
|
|
20
15
|
],
|
|
21
16
|
"contributors": [
|
|
22
|
-
"GhexterCortes
|
|
17
|
+
"GhexterCortes"
|
|
23
18
|
],
|
|
24
19
|
"bugs": {
|
|
25
20
|
"url": "https://github.com/FalloutStudios/reciple/issues"
|
|
26
21
|
},
|
|
27
22
|
"scripts": {
|
|
28
23
|
"clean": "yarn exec rimraf bin",
|
|
29
|
-
"build": "yarn clean &&
|
|
24
|
+
"build": "yarn clean && yarn exec tsc",
|
|
30
25
|
"build:publish": "yarn build && yarn npm publish && yarn build:docs && yarn publish:docs",
|
|
31
26
|
"build:publish-prerelease": "yarn build && yarn npm publish --tag pre",
|
|
32
27
|
"build:docs": "yarn exec typedoc --tsconfig ./docs/typedoc.json",
|
|
@@ -42,6 +37,7 @@
|
|
|
42
37
|
"type": "git",
|
|
43
38
|
"url": "git+https://github.com/FalloutStudios/reciple.git"
|
|
44
39
|
},
|
|
40
|
+
"engineStrict": true,
|
|
45
41
|
"engines": {
|
|
46
42
|
"node": ">=16.9.0"
|
|
47
43
|
},
|
|
@@ -55,18 +51,18 @@
|
|
|
55
51
|
"dependencies": {
|
|
56
52
|
"chalk": "4.1.2",
|
|
57
53
|
"commander": "^9.4.0",
|
|
58
|
-
"dotenv": "^16.0.
|
|
54
|
+
"dotenv": "^16.0.2",
|
|
59
55
|
"fallout-utility": "^1.4.6",
|
|
60
56
|
"semver": "^7.3.7",
|
|
61
57
|
"wildcard-match": "^5.1.2",
|
|
62
58
|
"yaml": "^2.1.1"
|
|
63
59
|
},
|
|
64
60
|
"devDependencies": {
|
|
65
|
-
"@types/node": "^18.7.
|
|
61
|
+
"@types/node": "^18.7.14",
|
|
66
62
|
"@types/semver": "^7.3.12",
|
|
67
63
|
"discord.js": "^14.3.0",
|
|
68
64
|
"rimraf": "^3.0.2",
|
|
69
|
-
"typedoc": "^0.23.
|
|
65
|
+
"typedoc": "^0.23.14",
|
|
70
66
|
"typedoc-plugin-discord-types": "^1.0.2",
|
|
71
67
|
"typedoc-plugin-djs-links": "^1.2.0",
|
|
72
68
|
"typedoc-plugin-mdn-links": "^2.0.0",
|
package/bin/cjs/package.json
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandCooldownManager = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
/**
|
|
6
|
-
* cooled-down users manager
|
|
7
|
-
*/
|
|
8
|
-
class CommandCooldownManager extends Array {
|
|
9
|
-
constructor(...data) {
|
|
10
|
-
super(...(0, discord_js_1.normalizeArray)(data));
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Alias for `CommandCooldownManager#push()`
|
|
14
|
-
* @param options Cooled-down user data
|
|
15
|
-
*/
|
|
16
|
-
add(...options) {
|
|
17
|
-
return this.push(...options);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Remove cooldown from specific user, channel or guild
|
|
21
|
-
* @param options Remove cooldown data options
|
|
22
|
-
* @param limit Remove cooldown data limit
|
|
23
|
-
*/
|
|
24
|
-
remove(options, limit = 0) {
|
|
25
|
-
if (!Object.keys(options).length)
|
|
26
|
-
throw new TypeError('Provide atleast one option to remove cooldown data.');
|
|
27
|
-
let i = 0;
|
|
28
|
-
for (const index in this) {
|
|
29
|
-
if (!CommandCooldownManager.checkOptions(options, this[index]))
|
|
30
|
-
continue;
|
|
31
|
-
if (options.expireTime && this[index].expireTime > Date.now())
|
|
32
|
-
continue;
|
|
33
|
-
if (limit && i >= limit)
|
|
34
|
-
continue;
|
|
35
|
-
this.splice(Number(index));
|
|
36
|
-
i++;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Check if the given user is cooled-down
|
|
41
|
-
* @param options Options to identify if user is on cooldown
|
|
42
|
-
*/
|
|
43
|
-
isCooledDown(options) {
|
|
44
|
-
const data = this.get(options);
|
|
45
|
-
if (!data)
|
|
46
|
-
return false;
|
|
47
|
-
this.remove(Object.assign(Object.assign({}, data), { channel: undefined, guild: undefined, type: undefined, command: undefined }));
|
|
48
|
-
if (data.expireTime < Date.now())
|
|
49
|
-
return false;
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Purge non cooled-down users from this array
|
|
54
|
-
* @param options Clean cooldown options
|
|
55
|
-
*/
|
|
56
|
-
clean(options) {
|
|
57
|
-
for (const index in this) {
|
|
58
|
-
if (options && !CommandCooldownManager.checkOptions(options, this[index]))
|
|
59
|
-
return;
|
|
60
|
-
if (this[index].expireTime > Date.now())
|
|
61
|
-
return;
|
|
62
|
-
this.slice(Number(index));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get someone's cooldown data
|
|
67
|
-
* @param options Get cooldown data options
|
|
68
|
-
*/
|
|
69
|
-
get(options) {
|
|
70
|
-
return this.find(data => CommandCooldownManager.checkOptions(options, data));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Check if the options are valid
|
|
74
|
-
* @param options Options to validated
|
|
75
|
-
* @param data Cooled-down user data
|
|
76
|
-
*/
|
|
77
|
-
static checkOptions(options, data) {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
if ((options === null || options === void 0 ? void 0 : options.user) && options.user.id !== data.user.id)
|
|
80
|
-
return false;
|
|
81
|
-
if ((options === null || options === void 0 ? void 0 : options.guild) && options.guild.id !== ((_a = data.guild) === null || _a === void 0 ? void 0 : _a.id))
|
|
82
|
-
return false;
|
|
83
|
-
if ((options === null || options === void 0 ? void 0 : options.channel) && options.channel.id !== ((_b = data.channel) === null || _b === void 0 ? void 0 : _b.id))
|
|
84
|
-
return false;
|
|
85
|
-
if ((options === null || options === void 0 ? void 0 : options.command) && options.command !== data.command)
|
|
86
|
-
return false;
|
|
87
|
-
if ((options === null || options === void 0 ? void 0 : options.type) && options.type !== data.type)
|
|
88
|
-
return false;
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.CommandCooldownManager = CommandCooldownManager;
|