reciple 1.5.3 → 1.6.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/bin/bin.js +2 -2
- package/bin/index.d.ts +2 -1
- package/bin/index.js +2 -1
- package/bin/reciple/classes/{Client.d.ts → RecipleClient.d.ts} +13 -12
- package/bin/reciple/classes/{Client.js → RecipleClient.js} +30 -21
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +6 -2
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +4 -0
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +4 -3
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +1 -1
- package/bin/reciple/classes/builders/MessageCommandOptions.d.ts +8 -0
- package/bin/reciple/classes/builders/MessageCommandOptions.js +23 -0
- package/bin/reciple/modules.d.ts +3 -3
- package/bin/reciple/modules.js +7 -7
- package/bin/reciple/registerInteractionCommands.d.ts +1 -1
- package/package.json +9 -7
package/bin/bin.js
CHANGED
|
@@ -12,7 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
var _a, _b;
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const Config_1 = require("./reciple/classes/Config");
|
|
15
|
-
const
|
|
15
|
+
const RecipleClient_1 = require("./reciple/classes/RecipleClient");
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const version_1 = require("./reciple/version");
|
|
18
18
|
const flags_1 = require("./reciple/flags");
|
|
@@ -29,7 +29,7 @@ if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.i
|
|
|
29
29
|
process.exit(0);
|
|
30
30
|
}
|
|
31
31
|
const config = new Config_1.RecipleConfig((_b = flags_1.flags.config) !== null && _b !== void 0 ? _b : './reciple.yml').parseConfig().getConfig();
|
|
32
|
-
const client = new
|
|
32
|
+
const client = new RecipleClient_1.RecipleClient(Object.assign({ config: config }, config.client));
|
|
33
33
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
yield client.startModules();
|
|
35
35
|
client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/bin/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import discord from 'discord.js';
|
|
2
2
|
export declare const discordjs: typeof discord;
|
|
3
|
-
export * from './reciple/classes/
|
|
3
|
+
export * from './reciple/classes/RecipleClient';
|
|
4
4
|
export * from './reciple/classes/Config';
|
|
5
5
|
export * from './reciple/classes/builders/InteractionCommandBuilder';
|
|
6
6
|
export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
7
7
|
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
8
|
+
export * from './reciple/classes/builders/MessageCommandOptions';
|
|
8
9
|
export * from './reciple/hasPermissions';
|
|
9
10
|
export * from './reciple/flags';
|
|
10
11
|
export * from './reciple/isIgnoredChannel';
|
package/bin/index.js
CHANGED
|
@@ -20,11 +20,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.discordjs = void 0;
|
|
21
21
|
const discord_js_1 = __importDefault(require("discord.js"));
|
|
22
22
|
exports.discordjs = discord_js_1.default;
|
|
23
|
-
__exportStar(require("./reciple/classes/
|
|
23
|
+
__exportStar(require("./reciple/classes/RecipleClient"), exports);
|
|
24
24
|
__exportStar(require("./reciple/classes/Config"), exports);
|
|
25
25
|
__exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
|
|
26
26
|
__exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
|
|
27
27
|
__exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
|
|
28
|
+
__exportStar(require("./reciple/classes/builders/MessageCommandOptions"), exports);
|
|
28
29
|
__exportStar(require("./reciple/hasPermissions"), exports);
|
|
29
30
|
__exportStar(require("./reciple/flags"), exports);
|
|
30
31
|
__exportStar(require("./reciple/isIgnoredChannel"), exports);
|
|
@@ -3,8 +3,8 @@ import { interactionCommandBuilders } from '../registerInteractionCommands';
|
|
|
3
3
|
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
|
|
4
4
|
import { Logger as ILogger } from 'fallout-utility';
|
|
5
5
|
import { Config } from './Config';
|
|
6
|
-
import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
7
|
-
import { recipleCommandBuilders, RecipleScript } from '../modules';
|
|
6
|
+
import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, CommandInteraction, Interaction, Message } from 'discord.js';
|
|
7
|
+
import { recipleCommandBuilders, RecipleModule, RecipleScript } from '../modules';
|
|
8
8
|
export interface RecipleClientOptions extends ClientOptions {
|
|
9
9
|
config: Config;
|
|
10
10
|
}
|
|
@@ -20,7 +20,7 @@ export interface RecipleClientEvents extends ClientEvents {
|
|
|
20
20
|
recipleMessageCommandCreate: [command: RecipleMessageCommandExecute];
|
|
21
21
|
recipleInteractionCommandCreate: [command: RecipleInteractionCommandExecute];
|
|
22
22
|
}
|
|
23
|
-
export interface RecipleClient extends Client {
|
|
23
|
+
export interface RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
24
24
|
on<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
25
25
|
on<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
|
|
26
26
|
once<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
@@ -31,22 +31,23 @@ export interface RecipleClient extends Client {
|
|
|
31
31
|
off<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
|
|
32
32
|
removeAllListeners<E extends keyof RecipleClientEvents>(event?: E): this;
|
|
33
33
|
removeAllListeners(event?: string | symbol): this;
|
|
34
|
+
isReady(): this is RecipleClient<true>;
|
|
34
35
|
}
|
|
35
|
-
export declare class RecipleClient extends Client {
|
|
36
|
+
export declare class RecipleClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
36
37
|
config: Config;
|
|
37
38
|
commands: RecipleClientCommands;
|
|
38
39
|
otherApplicationCommandData: (interactionCommandBuilders | ApplicationCommandDataResolvable)[];
|
|
39
|
-
modules:
|
|
40
|
+
modules: RecipleModule[];
|
|
40
41
|
logger: ILogger;
|
|
41
42
|
version: string;
|
|
42
43
|
constructor(options: RecipleClientOptions);
|
|
43
|
-
startModules(): Promise<RecipleClient
|
|
44
|
-
loadModules(): Promise<RecipleClient
|
|
44
|
+
startModules(): Promise<RecipleClient<Ready>>;
|
|
45
|
+
loadModules(): Promise<RecipleClient<Ready>>;
|
|
45
46
|
addModule(script: RecipleScript, registerCommands?: boolean): Promise<void>;
|
|
46
|
-
addCommand(command: recipleCommandBuilders): RecipleClient
|
|
47
|
-
addCommandListeners(): RecipleClient
|
|
48
|
-
messageCommandExecute(message: Message): Promise<void>;
|
|
49
|
-
interactionCommandExecute(interaction: Interaction): Promise<void>;
|
|
50
|
-
getMessage<T =
|
|
47
|
+
addCommand(command: recipleCommandBuilders): RecipleClient<Ready>;
|
|
48
|
+
addCommandListeners(): RecipleClient<Ready>;
|
|
49
|
+
messageCommandExecute(message: Message, prefix?: string): Promise<void | RecipleMessageCommandExecute>;
|
|
50
|
+
interactionCommandExecute(interaction: Interaction | CommandInteraction): Promise<void | RecipleInteractionCommandExecute>;
|
|
51
|
+
getMessage<T = unknown>(messageKey: string, defaultMessage?: T): T;
|
|
51
52
|
private _commandExecuteError;
|
|
52
53
|
}
|
|
@@ -24,6 +24,7 @@ const version_1 = require("../version");
|
|
|
24
24
|
const logger_1 = require("../logger");
|
|
25
25
|
const discord_js_1 = require("discord.js");
|
|
26
26
|
const modules_1 = require("../modules");
|
|
27
|
+
const MessageCommandOptions_1 = require("./builders/MessageCommandOptions");
|
|
27
28
|
class RecipleClient extends discord_js_1.Client {
|
|
28
29
|
constructor(options) {
|
|
29
30
|
super(options);
|
|
@@ -45,24 +46,22 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
45
46
|
const modules = yield (0, modules_1.loadModules)(this);
|
|
46
47
|
if (!modules)
|
|
47
48
|
throw new Error('Failed to load modules.');
|
|
48
|
-
this.modules = modules.modules
|
|
49
|
-
for (const command of modules.commands) {
|
|
50
|
-
if (!command.name)
|
|
51
|
-
continue;
|
|
52
|
-
this.addCommand(command);
|
|
53
|
-
}
|
|
54
|
-
this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
|
|
55
|
-
this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
|
|
49
|
+
this.modules = modules.modules;
|
|
56
50
|
return this;
|
|
57
51
|
});
|
|
58
52
|
}
|
|
59
53
|
loadModules() {
|
|
60
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
for (const module_ of this.modules) {
|
|
55
|
+
for (const module_ of this.modules.map(m => m.script)) {
|
|
62
56
|
if (typeof (module_ === null || module_ === void 0 ? void 0 : module_.onLoad) === 'function')
|
|
63
57
|
yield Promise.resolve(module_.onLoad(this));
|
|
64
58
|
}
|
|
65
59
|
this.logger.info(`${this.modules.length} modules loaded.`);
|
|
60
|
+
for (const command of this.modules.map(m => { var _a; return (_a = m.script.commands) !== null && _a !== void 0 ? _a : []; })[0]) {
|
|
61
|
+
this.addCommand(command);
|
|
62
|
+
}
|
|
63
|
+
this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
|
|
64
|
+
this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
|
|
66
65
|
if (!this.config.commands.interactionCommand.registerCommands)
|
|
67
66
|
return this;
|
|
68
67
|
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
|
|
@@ -72,7 +71,14 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
72
71
|
addModule(script, registerCommands = true) {
|
|
73
72
|
var _a;
|
|
74
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
this.modules.push(
|
|
74
|
+
this.modules.push({
|
|
75
|
+
script,
|
|
76
|
+
info: {
|
|
77
|
+
filename: undefined,
|
|
78
|
+
versions: typeof script.versions == 'string' ? [script.versions] : script.versions,
|
|
79
|
+
path: undefined
|
|
80
|
+
}
|
|
81
|
+
});
|
|
76
82
|
if (typeof (script === null || script === void 0 ? void 0 : script.onLoad) === 'function')
|
|
77
83
|
yield Promise.resolve(script.onLoad(this));
|
|
78
84
|
this.logger.info(`${this.modules.length} modules loaded.`);
|
|
@@ -106,12 +112,12 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
106
112
|
this.on('interactionCreate', (interaction) => { this.interactionCommandExecute(interaction); });
|
|
107
113
|
return this;
|
|
108
114
|
}
|
|
109
|
-
messageCommandExecute(message) {
|
|
115
|
+
messageCommandExecute(message, prefix) {
|
|
110
116
|
var _a;
|
|
111
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
if (!message.content || !this.
|
|
118
|
+
if (!message.content || !this.isReady())
|
|
113
119
|
return;
|
|
114
|
-
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
120
|
+
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, prefix || this.config.prefix || '!', this.config.commands.messageCommand.commandArgumentSeparator || ' ');
|
|
115
121
|
if (!(parseCommand === null || parseCommand === void 0 ? void 0 : parseCommand.command) || !parseCommand)
|
|
116
122
|
return;
|
|
117
123
|
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command.toLowerCase()];
|
|
@@ -126,38 +132,40 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
126
132
|
const commandOptions = command.getCommandOptionValues(parseCommand);
|
|
127
133
|
if (command.validateOptions) {
|
|
128
134
|
if (commandOptions.some(o => o.invalid)) {
|
|
129
|
-
yield message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(
|
|
135
|
+
yield message.reply(this.getMessage('invalidArguments', 'Invalid argument(s) given.')).catch(err => this.logger.debug(err));
|
|
130
136
|
return;
|
|
131
137
|
}
|
|
132
138
|
if (commandOptions.some(o => o.missing)) {
|
|
133
|
-
yield message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.')).catch(
|
|
139
|
+
yield message.reply(this.getMessage('notEnoughArguments', 'Not enough arguments.')).catch(err => this.logger.debug(err));
|
|
134
140
|
return;
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
143
|
const options = {
|
|
138
144
|
message: message,
|
|
139
|
-
options: commandOptions,
|
|
145
|
+
options: new MessageCommandOptions_1.MessageCommandOptions(commandOptions),
|
|
140
146
|
command: parseCommand,
|
|
141
147
|
builder: command,
|
|
142
148
|
client: this
|
|
143
149
|
};
|
|
144
150
|
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
145
151
|
this.emit('recipleMessageCommandCreate', options);
|
|
152
|
+
return options;
|
|
146
153
|
}
|
|
147
154
|
else {
|
|
148
|
-
yield message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(
|
|
155
|
+
yield message.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(err => this.logger.debug(err));
|
|
149
156
|
}
|
|
150
157
|
});
|
|
151
158
|
}
|
|
152
159
|
interactionCommandExecute(interaction) {
|
|
153
160
|
var _a;
|
|
154
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
if (!interaction || !interaction.isCommand() || !this.
|
|
162
|
+
if (!interaction || !interaction.isCommand() || !this.isReady())
|
|
156
163
|
return;
|
|
157
164
|
const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
|
|
158
165
|
if (!command)
|
|
159
166
|
return;
|
|
160
167
|
if ((0, hasPermissions_1.hasPermissions)(command.name, (_a = interaction.memberPermissions) !== null && _a !== void 0 ? _a : undefined, this.config.permissions.interactionCommands, command)) {
|
|
168
|
+
// TODO: Deprecated allowEcuteInDM
|
|
161
169
|
if (!command.allowExecuteInDM && !interaction.inCachedGuild() || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, this.config.ignoredChannels))
|
|
162
170
|
return;
|
|
163
171
|
if (!command)
|
|
@@ -170,9 +178,10 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
170
178
|
};
|
|
171
179
|
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
172
180
|
this.emit('recipleInteractionCommandCreate', options);
|
|
181
|
+
return options;
|
|
173
182
|
}
|
|
174
183
|
else {
|
|
175
|
-
yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(
|
|
184
|
+
yield interaction.reply(this.getMessage('noPermissions', 'You do not have permission to use this command.')).catch(err => this.logger.debug(err));
|
|
176
185
|
}
|
|
177
186
|
});
|
|
178
187
|
}
|
|
@@ -189,12 +198,12 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
189
198
|
if (command === null || command === void 0 ? void 0 : command.message) {
|
|
190
199
|
if (!this.config.commands.messageCommand.replyOnError)
|
|
191
200
|
return;
|
|
192
|
-
yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch(
|
|
201
|
+
yield command.message.reply(this.getMessage('error', 'An error occurred.')).catch(err => this.logger.debug(err));
|
|
193
202
|
}
|
|
194
203
|
else if (command === null || command === void 0 ? void 0 : command.interaction) {
|
|
195
204
|
if (!this.config.commands.interactionCommand.replyOnError)
|
|
196
205
|
return;
|
|
197
|
-
yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch(
|
|
206
|
+
yield command.interaction.followUp(this.getMessage('error', 'An error occurred.')).catch(err => this.logger.debug(err));
|
|
198
207
|
}
|
|
199
208
|
});
|
|
200
209
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CommandInteraction, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
2
|
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
3
|
-
import { RecipleClient } from '../
|
|
3
|
+
import { RecipleClient } from '../RecipleClient';
|
|
4
4
|
export interface RecipleInteractionCommandExecute {
|
|
5
5
|
interaction: CommandInteraction;
|
|
6
6
|
command: InteractionCommandBuilder;
|
|
7
7
|
builder: InteractionCommandBuilder;
|
|
8
|
-
client: RecipleClient
|
|
8
|
+
client: RecipleClient<true>;
|
|
9
9
|
}
|
|
10
10
|
export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
11
11
|
readonly builder = "INTERACTION_COMMAND";
|
|
@@ -13,6 +13,10 @@ export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
|
13
13
|
allowExecuteInDM: boolean;
|
|
14
14
|
execute: (options: RecipleInteractionCommandExecute) => void;
|
|
15
15
|
setRequiredPermissions(requiredPermissions: (keyof PermissionFlags)[]): InteractionCommandBuilder;
|
|
16
|
+
/**
|
|
17
|
+
* TODO: Deprecated this
|
|
18
|
+
* @deprecated use `InteractionCommandBuilder.setDMPermission()` instead
|
|
19
|
+
*/
|
|
16
20
|
setAllowExecuteInDM(allowExecuteInDM: boolean): InteractionCommandBuilder;
|
|
17
21
|
setExecute(execute: (options: RecipleInteractionCommandExecute) => void): InteractionCommandBuilder;
|
|
18
22
|
}
|
|
@@ -16,6 +16,10 @@ class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
|
|
|
16
16
|
this.requiredPermissions = requiredPermissions;
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* TODO: Deprecated this
|
|
21
|
+
* @deprecated use `InteractionCommandBuilder.setDMPermission()` instead
|
|
22
|
+
*/
|
|
19
23
|
setAllowExecuteInDM(allowExecuteInDM) {
|
|
20
24
|
if (typeof allowExecuteInDM !== 'boolean')
|
|
21
25
|
throw new Error('allowExecuteInDM must be a boolean.');
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
2
2
|
import { Message, PermissionFlags, PermissionString } from 'discord.js';
|
|
3
3
|
import { Command } from 'fallout-utility';
|
|
4
|
-
import { RecipleClient } from '../
|
|
4
|
+
import { RecipleClient } from '../RecipleClient';
|
|
5
|
+
import { MessageCommandOptions } from './MessageCommandOptions';
|
|
5
6
|
export declare type CommandMessage = Command;
|
|
6
7
|
export interface RecipleMessageCommandExecute {
|
|
7
8
|
message: Message;
|
|
8
|
-
options:
|
|
9
|
+
options: MessageCommandOptions;
|
|
9
10
|
command: CommandMessage;
|
|
10
11
|
builder: MessageCommandBuilder;
|
|
11
|
-
client: RecipleClient
|
|
12
|
+
client: RecipleClient<true>;
|
|
12
13
|
}
|
|
13
14
|
export interface MessageCommandValidatedOption {
|
|
14
15
|
name: string;
|
|
@@ -72,7 +72,7 @@ class MessageCommandBuilder {
|
|
|
72
72
|
const required = this.options.filter(o => o.required);
|
|
73
73
|
const optional = this.options.filter(o => !o.required);
|
|
74
74
|
const allOptions = [...required, ...optional];
|
|
75
|
-
|
|
75
|
+
const result = [];
|
|
76
76
|
let i = 0;
|
|
77
77
|
for (const option of allOptions) {
|
|
78
78
|
const arg = args[i];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MessageCommandValidatedOption } from './MessageCommandBuilder';
|
|
2
|
+
export declare class MessageCommandOptions extends Array<MessageCommandValidatedOption> {
|
|
3
|
+
constructor(options: MessageCommandValidatedOption[]);
|
|
4
|
+
get(name: string, requied: true): MessageCommandValidatedOption;
|
|
5
|
+
get(name: string, requied?: boolean): MessageCommandValidatedOption | null;
|
|
6
|
+
getValue(name: string, requied: true): string;
|
|
7
|
+
getValue(name: string, requied?: boolean): string | null;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageCommandOptions = void 0;
|
|
4
|
+
class MessageCommandOptions extends Array {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super();
|
|
7
|
+
this.push(...options);
|
|
8
|
+
}
|
|
9
|
+
get(name, required) {
|
|
10
|
+
const option = this.find(o => o.name == name);
|
|
11
|
+
if (!(option === null || option === void 0 ? void 0 : option.value) == undefined && required)
|
|
12
|
+
throw new TypeError(`Can't find option named ${name}`);
|
|
13
|
+
return option !== null && option !== void 0 ? option : null;
|
|
14
|
+
}
|
|
15
|
+
getValue(name, requied) {
|
|
16
|
+
var _a;
|
|
17
|
+
const option = this.get(name, requied);
|
|
18
|
+
if (!(option === null || option === void 0 ? void 0 : option.value) && requied)
|
|
19
|
+
throw new TypeError(`Value of option named ${name} is undefined`);
|
|
20
|
+
return (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.MessageCommandOptions = MessageCommandOptions;
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './classes/builders/InteractionCommandBuilder';
|
|
2
2
|
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './classes/builders/MessageCommandBuilder';
|
|
3
|
-
import { RecipleClient } from './classes/
|
|
3
|
+
import { RecipleClient } from './classes/RecipleClient';
|
|
4
4
|
export declare type recipleCommandBuilders = MessageCommandBuilder | InteractionCommandBuilder;
|
|
5
5
|
export declare type recipleCommandBuildersExecute = RecipleInteractionCommandExecute | RecipleMessageCommandExecute;
|
|
6
6
|
export declare type loadedModules = {
|
|
@@ -16,9 +16,9 @@ export declare class RecipleScript {
|
|
|
16
16
|
export interface RecipleModule {
|
|
17
17
|
script: RecipleScript;
|
|
18
18
|
info: {
|
|
19
|
-
filename
|
|
19
|
+
filename?: string;
|
|
20
20
|
versions: string[];
|
|
21
|
-
path
|
|
21
|
+
path?: string;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
export declare function loadModules(client: RecipleClient): Promise<loadedModules>;
|
package/bin/reciple/modules.js
CHANGED
|
@@ -18,7 +18,7 @@ const version_1 = require("./version");
|
|
|
18
18
|
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
function loadModules(client) {
|
|
21
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const response = { commands: [], modules: [] };
|
|
24
24
|
const modulesDir = client.config.modulesFolder || './modules';
|
|
@@ -30,17 +30,17 @@ function loadModules(client) {
|
|
|
30
30
|
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
|
|
31
31
|
});
|
|
32
32
|
for (const script of scripts) {
|
|
33
|
-
const modulePath = path_1.default.
|
|
33
|
+
const modulePath = path_1.default.join(process.cwd(), modulesDir, script);
|
|
34
34
|
const commands = [];
|
|
35
35
|
let module_;
|
|
36
36
|
try {
|
|
37
37
|
const reqMod = require(modulePath);
|
|
38
|
-
module_ =
|
|
38
|
+
module_ = typeof (reqMod === null || reqMod === void 0 ? void 0 : reqMod.default) != 'undefined' ? reqMod.default : reqMod;
|
|
39
39
|
if (!((_a = module_.versions) === null || _a === void 0 ? void 0 : _a.length))
|
|
40
40
|
throw new Error('Module does not have supported versions.');
|
|
41
41
|
const versions = typeof module_.versions === 'object' ? module_.versions : [module_.versions];
|
|
42
42
|
if (!versions.some(v => (0, version_1.isSupportedVersion)(v, version_1.version)))
|
|
43
|
-
throw new Error('Module versions is not defined or unsupported.');
|
|
43
|
+
throw new Error((_b = 'Module versions is not defined or unsupported; supported versions: ' + module_.versions) !== null && _b !== void 0 ? _b : 'none' + '; current version: ' + version_1.version);
|
|
44
44
|
if (!(yield Promise.resolve(module_.onStart(client))))
|
|
45
45
|
throw new Error(script + ' onStart is not defined or returned false.');
|
|
46
46
|
if (module_.commands) {
|
|
@@ -55,13 +55,13 @@ function loadModules(client) {
|
|
|
55
55
|
logger.error(error);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
response.commands
|
|
58
|
+
response.commands.push(...commands.filter((c) => {
|
|
59
59
|
if (!c.name) {
|
|
60
|
-
logger.error(`A
|
|
60
|
+
logger.error(`A ${c.builder} command name is not defined in ${script}`);
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
if (c.builder === 'MESSAGE_COMMAND' && c.options.length && c.options.some(o => !o.name)) {
|
|
64
|
-
logger.error(`A
|
|
64
|
+
logger.error(`A ${c.builder} option name is not defined in ${script}`);
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
67
|
return true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
|
|
2
2
|
import { ApplicationCommandDataResolvable } from 'discord.js';
|
|
3
|
-
import { RecipleClient } from './classes/
|
|
3
|
+
import { RecipleClient } from './classes/RecipleClient';
|
|
4
4
|
import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder } from '@discordjs/builders';
|
|
5
5
|
export declare type interactionCommandBuilders = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
|
|
6
6
|
export declare function registerInteractionCommands(client: RecipleClient, cmds?: (interactionCommandBuilders | ApplicationCommandDataResolvable)[], overwriteGuilds?: string | string[]): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A Discord.js bot",
|
|
5
5
|
"author": "FalloutStudios",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"reciple": "bin/bin.js"
|
|
10
10
|
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16.9.0"
|
|
13
|
+
},
|
|
11
14
|
"files": [
|
|
12
15
|
"bin",
|
|
13
16
|
"resource",
|
|
@@ -16,12 +19,11 @@
|
|
|
16
19
|
"README.md"
|
|
17
20
|
],
|
|
18
21
|
"scripts": {
|
|
19
|
-
"clean": "
|
|
20
|
-
"
|
|
21
|
-
"build": "yarn
|
|
22
|
-
"
|
|
23
|
-
"test": "cd test && npx reciple"
|
|
24
|
-
"test:build": "yarn run build && yarn test:run"
|
|
22
|
+
"clean": "rm -rf bin",
|
|
23
|
+
"build": "yarn clean && npx tsc && npm un reciple -g && npm i ./ -g",
|
|
24
|
+
"build:publish": "yarn run build && yarn publish",
|
|
25
|
+
"test": "yarn run build && yarn test:run",
|
|
26
|
+
"test:start": "cd test && npx reciple"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"commander": "^9.3.0",
|