reciple 1.0.19 → 1.1.1
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/reciple/classes/Client.d.ts +2 -1
- package/bin/reciple/classes/Client.js +5 -4
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +1 -1
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +1 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +1 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +1 -1
- package/bin/reciple/modules.js +2 -2
- package/bin/reciple/registerInteractionCommands.d.ts +4 -1
- package/bin/reciple/registerInteractionCommands.js +10 -6
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
1
|
+
import { ApplicationCommandData, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
2
2
|
import { Logger as LoggerConstructor } from 'fallout-utility';
|
|
3
3
|
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
|
|
4
4
|
import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './builders/InteractionCommandBuilder';
|
|
@@ -22,6 +22,7 @@ export interface RecipleClientEvents extends ClientEvents {
|
|
|
22
22
|
export declare class RecipleClient extends Client {
|
|
23
23
|
config?: Config;
|
|
24
24
|
commands: RecipleClientCommands;
|
|
25
|
+
otherApplicationCommandData: ApplicationCommandData[];
|
|
25
26
|
modules: RecipleScript[];
|
|
26
27
|
logger: LoggerConstructor;
|
|
27
28
|
version: string;
|
|
@@ -22,6 +22,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
22
22
|
constructor(options) {
|
|
23
23
|
super(options);
|
|
24
24
|
this.commands = { MESSAGE_COMMANDS: {}, INTERACTION_COMMANDS: {} };
|
|
25
|
+
this.otherApplicationCommandData = [];
|
|
25
26
|
this.modules = [];
|
|
26
27
|
this.version = version_1.version;
|
|
27
28
|
this.logger = (0, logger_1.logger)(!!options.config.fileLogging.stringifyLoggedJSON, !!options.config.fileLogging.debugmode);
|
|
@@ -42,10 +43,10 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
42
43
|
for (const command of modules.commands) {
|
|
43
44
|
if (!command.name)
|
|
44
45
|
continue;
|
|
45
|
-
if (command.
|
|
46
|
+
if (command.builder === 'MESSAGE_COMMAND') {
|
|
46
47
|
this.commands.MESSAGE_COMMANDS[command.name] = command;
|
|
47
48
|
}
|
|
48
|
-
else if (command.
|
|
49
|
+
else if (command.builder === 'INTERACTION_COMMAND') {
|
|
49
50
|
this.commands.INTERACTION_COMMANDS[command.name] = command;
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -63,7 +64,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
63
64
|
}
|
|
64
65
|
this.logger.info(`${this.modules.length} modules loaded.`);
|
|
65
66
|
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands)
|
|
66
|
-
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this);
|
|
67
|
+
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
|
|
67
68
|
return this;
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -137,7 +138,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
137
138
|
_commandExecuteError(err, command) {
|
|
138
139
|
var _a, _b, _c, _d, _e;
|
|
139
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
this.logger.error(`An error occured executing ${command.builder.
|
|
141
|
+
this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
|
|
141
142
|
this.logger.error(err);
|
|
142
143
|
if (!err || !command)
|
|
143
144
|
return;
|
|
@@ -8,7 +8,7 @@ export interface RecipleInteractionCommandExecute {
|
|
|
8
8
|
client: RecipleClient;
|
|
9
9
|
}
|
|
10
10
|
export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
11
|
-
readonly
|
|
11
|
+
readonly builder: string;
|
|
12
12
|
requiredPermissions: (keyof PermissionFlags)[];
|
|
13
13
|
allowExecuteInDM: boolean;
|
|
14
14
|
execute: (options: RecipleInteractionCommandExecute) => void;
|
|
@@ -5,7 +5,7 @@ const builders_1 = require("@discordjs/builders");
|
|
|
5
5
|
class InteractionCommandBuilder extends builders_1.SlashCommandBuilder {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
|
-
this.
|
|
8
|
+
this.builder = 'INTERACTION_COMMAND';
|
|
9
9
|
this.requiredPermissions = [];
|
|
10
10
|
this.allowExecuteInDM = true;
|
|
11
11
|
this.execute = (options) => { };
|
|
@@ -30,7 +30,7 @@ export declare class MessageOption {
|
|
|
30
30
|
setValidator(validator: (value: string) => boolean): MessageOption;
|
|
31
31
|
}
|
|
32
32
|
export declare class MessageCommandBuilder {
|
|
33
|
-
readonly
|
|
33
|
+
readonly builder: string;
|
|
34
34
|
name: string;
|
|
35
35
|
description: string;
|
|
36
36
|
options: MessageOption[];
|
package/bin/reciple/modules.js
CHANGED
|
@@ -36,7 +36,7 @@ function loadModules(client) {
|
|
|
36
36
|
throw new Error(script + ' onStart is not defined or returned false.');
|
|
37
37
|
if (module_.commands) {
|
|
38
38
|
for (const command of module_.commands) {
|
|
39
|
-
if (command.
|
|
39
|
+
if (command.builder === 'MESSAGE_COMMAND' || command.builder === 'INTERACTION_COMMAND')
|
|
40
40
|
commands.push(command);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -51,7 +51,7 @@ function loadModules(client) {
|
|
|
51
51
|
logger.error(`A message command name is not defined in ${script}`);
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
if (c.
|
|
54
|
+
if (c.builder === 'MESSAGE_COMMAND' && c.options.length && c.options.some(o => !o.name)) {
|
|
55
55
|
logger.error(`A message command option name is not defined in ${script}`);
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
|
|
2
|
+
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
1
3
|
import { RecipleClient } from "./classes/Client";
|
|
2
|
-
|
|
4
|
+
import { ApplicationCommandData } from 'discord.js';
|
|
5
|
+
export declare function registerInteractionCommands(client: RecipleClient, cmds?: (InteractionCommandBuilder | SlashCommandBuilder | ApplicationCommandData)[]): Promise<void>;
|
|
@@ -10,23 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerInteractionCommands = void 0;
|
|
13
|
-
function registerInteractionCommands(client) {
|
|
14
|
-
var _a, _b, _c;
|
|
13
|
+
function registerInteractionCommands(client, cmds) {
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const commands = Object.values(client.commands.INTERACTION_COMMANDS).map(c =>
|
|
16
|
+
const commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
|
|
17
|
+
if (typeof c.toJSON !== 'undefined')
|
|
18
|
+
return c.toJSON();
|
|
19
|
+
return c;
|
|
20
|
+
})) !== null && _a !== void 0 ? _a : [];
|
|
17
21
|
if (!commands.length) {
|
|
18
22
|
client.logger.warn('No interaction commands found.');
|
|
19
23
|
return;
|
|
20
24
|
}
|
|
21
|
-
if (!((
|
|
22
|
-
yield ((
|
|
25
|
+
if (!((_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds.length)) {
|
|
26
|
+
yield ((_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).catch(e => client.logger.error(e)));
|
|
23
27
|
client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
30
|
const guilds = typeof client.config.commands.interactionCommand.guilds === 'string' ? [client.config.commands.interactionCommand.guilds] : client.config.commands.interactionCommand.guilds;
|
|
27
31
|
client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
|
|
28
32
|
for (const guild of guilds) {
|
|
29
|
-
yield ((
|
|
33
|
+
yield ((_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).catch(e => client.logger.error(e)));
|
|
30
34
|
client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
|
|
31
35
|
}
|
|
32
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A Discord.js bot",
|
|
5
5
|
"author": "FalloutStudios",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"clean": "rimraf bin",
|
|
20
|
-
"compile": "
|
|
21
|
-
"build": "
|
|
22
|
-
"build:publish": "
|
|
20
|
+
"compile": "yarn clean && tsc",
|
|
21
|
+
"build": "yarn compile && npm un reciple -g && npm i ./ -g",
|
|
22
|
+
"build:publish": "yarn run build && npm publish",
|
|
23
23
|
"test": "cd test && reciple",
|
|
24
|
-
"test:compile": "
|
|
24
|
+
"test:compile": "yarn run build && yarn test:run"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"commander": "^9.2.0",
|