reciple 1.7.0 → 1.7.1-pre.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 +1 -1
- package/bin/index.d.ts +0 -2
- package/bin/index.js +0 -6
- package/bin/reciple/classes/RecipleClient.d.ts +10 -2
- package/bin/reciple/classes/RecipleClient.js +31 -17
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="https://i.imgur.com/
|
|
2
|
+
<img src="https://i.imgur.com/DWM0tJL.png" width="50%">
|
|
3
3
|
<br>
|
|
4
4
|
<img alt="Lines of code" src="https://img.shields.io/tokei/lines/github/FalloutStudios/Reciple">
|
|
5
5
|
<img alt="GitHub" src="https://img.shields.io/github/license/FalloutStudios/Reciple">
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -13,13 +13,7 @@ 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
|
-
};
|
|
19
16
|
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;
|
|
23
17
|
__exportStar(require("./reciple/classes/RecipleClient"), exports);
|
|
24
18
|
__exportStar(require("./reciple/classes/RecipleConfig"), exports);
|
|
25
19
|
__exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
|
|
@@ -19,7 +19,7 @@ export interface RecipleClientCommands {
|
|
|
19
19
|
export interface RecipleClientEvents extends ClientEvents {
|
|
20
20
|
recipleMessageCommandCreate: [command: RecipleMessageCommandExecute];
|
|
21
21
|
recipleInteractionCommandCreate: [command: RecipleInteractionCommandExecute];
|
|
22
|
-
recipleReplyError: [error:
|
|
22
|
+
recipleReplyError: [error: unknown];
|
|
23
23
|
}
|
|
24
24
|
export interface RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
25
25
|
on<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
@@ -74,11 +74,19 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
74
74
|
* Get a message from config
|
|
75
75
|
*/
|
|
76
76
|
getMessage<T = unknown>(messageKey: string, defaultMessage?: T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Get command builder by name or alias if it's a message command
|
|
79
|
+
*/
|
|
80
|
+
findCommand(command: string, type: MessageCommandBuilder["builder"]): MessageCommandBuilder | undefined;
|
|
81
|
+
findCommand(command: string, type: InteractionCommandBuilder["builder"]): InteractionCommandBuilder | undefined;
|
|
77
82
|
/**
|
|
78
83
|
* Returns true if client logs is enabled
|
|
79
84
|
*/
|
|
80
85
|
isClientLogsEnabled(): boolean;
|
|
81
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Emits the "recipleReplyError" event
|
|
88
|
+
*/
|
|
89
|
+
private replyError;
|
|
82
90
|
/**
|
|
83
91
|
* Error message when a command fails to execute
|
|
84
92
|
*/
|
|
@@ -62,7 +62,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
62
62
|
loadModules() {
|
|
63
63
|
var _a, _b;
|
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
for (
|
|
65
|
+
for (const m in this.modules) {
|
|
66
66
|
const module_ = this.modules[m];
|
|
67
67
|
if (typeof ((_a = module_.script) === null || _a === void 0 ? void 0 : _a.onLoad) === 'function') {
|
|
68
68
|
yield Promise.resolve(module_.script.onLoad(this)).catch(err => {
|
|
@@ -85,9 +85,9 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
85
85
|
this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
|
|
86
86
|
this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
|
|
87
87
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
if (this.config.commands.interactionCommand.registerCommands) {
|
|
89
|
+
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
|
|
90
|
+
}
|
|
91
91
|
return this;
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -145,19 +145,17 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
145
145
|
* Execute a Message command
|
|
146
146
|
*/
|
|
147
147
|
messageCommandExecute(message, prefix) {
|
|
148
|
-
var _a
|
|
148
|
+
var _a;
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
150
|
if (!message.content || !this.isReady())
|
|
151
151
|
return;
|
|
152
152
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
153
153
|
if (!parseCommand || !(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command))
|
|
154
154
|
return;
|
|
155
|
-
const command =
|
|
156
|
-
? Object.values(this.commands.MESSAGE_COMMANDS).find(c => c.aliases.some(a => { var _a; return a == ((_a = parseCommand.command) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }))
|
|
157
|
-
: undefined);
|
|
155
|
+
const command = this.findCommand(parseCommand.command, 'MESSAGE_COMMAND');
|
|
158
156
|
if (!command)
|
|
159
157
|
return;
|
|
160
|
-
if ((0, hasPermissions_1.hasPermissions)(command.name, (
|
|
158
|
+
if ((0, hasPermissions_1.hasPermissions)(command.name, (_a = message.member) === null || _a === void 0 ? void 0 : _a.permissions, this.config.permissions.messageCommands, command)) {
|
|
161
159
|
if (!command.allowExecuteInDM && message.channel.type === 'DM'
|
|
162
160
|
|| !command.allowExecuteByBots
|
|
163
161
|
&& (message.author.bot || message.author.system)
|
|
@@ -166,11 +164,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
166
164
|
const commandOptions = command.getCommandOptionValues(parseCommand);
|
|
167
165
|
if (command.validateOptions) {
|
|
168
166
|
if (commandOptions.some(o => o.invalid)) {
|
|
169
|
-
yield message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this.
|
|
167
|
+
yield message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(er => this.replyError(er));
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
170
|
if (commandOptions.some(o => o.missing)) {
|
|
173
|
-
yield message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.')).catch(er => this.
|
|
171
|
+
yield message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.')).catch(er => this.replyError(er));
|
|
174
172
|
return;
|
|
175
173
|
}
|
|
176
174
|
}
|
|
@@ -186,7 +184,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
186
184
|
return options;
|
|
187
185
|
}
|
|
188
186
|
else {
|
|
189
|
-
yield message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this.
|
|
187
|
+
yield message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this.replyError(er));
|
|
190
188
|
}
|
|
191
189
|
});
|
|
192
190
|
}
|
|
@@ -198,7 +196,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
198
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
197
|
if (!interaction || !interaction.isCommand() || !this.isReady())
|
|
200
198
|
return;
|
|
201
|
-
const command = this.
|
|
199
|
+
const command = this.findCommand(interaction.commandName, 'INTERACTION_COMMAND');
|
|
202
200
|
if (!command)
|
|
203
201
|
return;
|
|
204
202
|
if ((0, hasPermissions_1.hasPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.permissions.interactionCommands, command)) {
|
|
@@ -215,7 +213,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
215
213
|
return options;
|
|
216
214
|
}
|
|
217
215
|
else {
|
|
218
|
-
yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this.
|
|
216
|
+
yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(er => this.replyError(er));
|
|
219
217
|
}
|
|
220
218
|
});
|
|
221
219
|
}
|
|
@@ -226,13 +224,29 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
226
224
|
var _a, _b;
|
|
227
225
|
return (_b = (_a = this.config.messages[messageKey]) !== null && _a !== void 0 ? _a : defaultMessage) !== null && _b !== void 0 ? _b : messageKey;
|
|
228
226
|
}
|
|
227
|
+
findCommand(command, type) {
|
|
228
|
+
var _a;
|
|
229
|
+
switch (type) {
|
|
230
|
+
case 'INTERACTION_COMMAND':
|
|
231
|
+
return this.commands.INTERACTION_COMMANDS[command];
|
|
232
|
+
case 'MESSAGE_COMMAND':
|
|
233
|
+
return (_a = this.commands.MESSAGE_COMMANDS[command.toLowerCase()]) !== null && _a !== void 0 ? _a : (this.config.commands.messageCommand.allowCommandAlias
|
|
234
|
+
? Object.values(this.commands.MESSAGE_COMMANDS).find(c => c.aliases.some(a => a == (command === null || command === void 0 ? void 0 : command.toLowerCase())))
|
|
235
|
+
: undefined);
|
|
236
|
+
default:
|
|
237
|
+
throw new TypeError('Unknown command type');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
229
240
|
/**
|
|
230
241
|
* Returns true if client logs is enabled
|
|
231
242
|
*/
|
|
232
243
|
isClientLogsEnabled() {
|
|
233
244
|
return !!this.config.fileLogging.clientLogs;
|
|
234
245
|
}
|
|
235
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Emits the "recipleReplyError" event
|
|
248
|
+
*/
|
|
249
|
+
replyError(error) {
|
|
236
250
|
this.emit('recipleReplyError', error);
|
|
237
251
|
}
|
|
238
252
|
/**
|
|
@@ -249,12 +263,12 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
249
263
|
if (command === null || command === void 0 ? void 0 : command.message) {
|
|
250
264
|
if (!this.config.commands.messageCommand.replyOnError)
|
|
251
265
|
return;
|
|
252
|
-
yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch(er => this.
|
|
266
|
+
yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch(er => this.replyError(er));
|
|
253
267
|
}
|
|
254
268
|
else if (command === null || command === void 0 ? void 0 : command.interaction) {
|
|
255
269
|
if (!this.config.commands.interactionCommand.replyOnError)
|
|
256
270
|
return;
|
|
257
|
-
yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch(er => this.
|
|
271
|
+
yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch(er => this.replyError(er));
|
|
258
272
|
}
|
|
259
273
|
});
|
|
260
274
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "1.7.0",
|
|
3
|
+
"version": "1.7.1-pre.0",
|
|
4
4
|
"description": "A Discord.js bot",
|
|
5
5
|
"author": "FalloutStudios",
|
|
6
6
|
"homepage": "https://falloutstudios.github.io/Reciple",
|
|
@@ -21,13 +21,15 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"clean": "rm -rf bin",
|
|
24
|
-
"build": "yarn clean && npx tsc &&
|
|
24
|
+
"build": "yarn run clean && npx tsc && yarn run reinstall && yarn run build:docs",
|
|
25
25
|
"build:publish": "yarn run build && yarn publish",
|
|
26
|
-
"
|
|
26
|
+
"build:pub-prerelease": "yarn run build && yarn publish --tag beta",
|
|
27
|
+
"reinstall": "npm un reciple -g && npm i ./ -g",
|
|
28
|
+
"postpublish": "yarn run build:docs && yarn run update:docs",
|
|
29
|
+
"test": "yarn run build && yarn run test:start",
|
|
27
30
|
"test:start": "cd test && npx reciple",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"update:docs": "cd docs && yarn update"
|
|
31
|
+
"build:docs": "cd docs && yarn run build",
|
|
32
|
+
"update:docs": "cd docs && yarn run update"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
35
|
"chalk": "4.1.2",
|
|
@@ -39,7 +41,7 @@
|
|
|
39
41
|
"yaml": "^2.1.1"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@types/node": "^18.0.
|
|
44
|
+
"@types/node": "^18.0.3",
|
|
43
45
|
"@types/semver": "^7.3.10",
|
|
44
46
|
"discord.js": "^13.8.1",
|
|
45
47
|
"typescript": "^4.7.4"
|