reciple 1.0.89 → 1.1.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 +4 -1
- package/bin/bin.d.ts +1 -1
- package/bin/bin.js +3 -1
- package/bin/index.d.ts +2 -1
- package/bin/index.js +2 -1
- package/bin/reciple/classes/Client.js +21 -11
- package/bin/reciple/classes/Config.d.ts +2 -0
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +4 -2
- package/bin/reciple/classes/builders/InteractionCommandBuilder.js +8 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +6 -3
- package/bin/reciple/classes/builders/MessageCommandBuilder.js +9 -2
- package/bin/reciple/commandPermissions.d.ts +3 -1
- package/bin/reciple/commandPermissions.js +3 -4
- package/bin/reciple/flags.js +1 -0
- package/bin/reciple/logger.d.ts +1 -1
- package/bin/reciple/logger.js +3 -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 +10 -9
- package/resource/reciple.yml +3 -1
package/README.md
CHANGED
|
@@ -58,4 +58,7 @@ reciple
|
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
> ## Fun Fact
|
|
61
|
-
> The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [Mojang Reciple](https://bugs.mojang.com/browse/MC-225837)
|
|
61
|
+
> The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [Mojang Reciple](https://bugs.mojang.com/browse/MC-225837)
|
|
62
|
+
|
|
63
|
+
# Save the Earth
|
|
64
|
+
[](https://rebellion.global/)
|
package/bin/bin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import 'dotenv/config';
|
package/bin/bin.js
CHANGED
|
@@ -14,7 +14,9 @@ const Config_1 = require("./reciple/classes/Config");
|
|
|
14
14
|
const Client_1 = require("./reciple/classes/Client");
|
|
15
15
|
const fs_1 = require("fs");
|
|
16
16
|
const fallout_utility_1 = require("fallout-utility");
|
|
17
|
-
|
|
17
|
+
require("dotenv/config");
|
|
18
|
+
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json'];
|
|
19
|
+
if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
|
|
18
20
|
const ask = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ');
|
|
19
21
|
if (ask !== 'y')
|
|
20
22
|
process.exit(0);
|
package/bin/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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
|
+
export * from './reciple/isIgnoredChannel';
|
|
7
8
|
export * from './reciple/logger';
|
|
8
9
|
export * from './reciple/modules';
|
|
9
10
|
export * from './reciple/registerInteractionCommands';
|
package/bin/index.js
CHANGED
|
@@ -16,10 +16,11 @@ 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
|
+
__exportStar(require("./reciple/isIgnoredChannel"), exports);
|
|
23
24
|
__exportStar(require("./reciple/logger"), exports);
|
|
24
25
|
__exportStar(require("./reciple/modules"), exports);
|
|
25
26
|
__exportStar(require("./reciple/registerInteractionCommands"), exports);
|
|
@@ -23,8 +23,8 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
23
23
|
super(options);
|
|
24
24
|
this.commands = { MESSAGE_COMMANDS: {}, INTERACTION_COMMANDS: {} };
|
|
25
25
|
this.modules = [];
|
|
26
|
-
this.logger = (0, logger_1.logger)(false);
|
|
27
26
|
this.version = version_1.version;
|
|
27
|
+
this.logger = (0, logger_1.logger)(!!options.config.fileLogging.stringifyLoggedJSON, !!options.config.fileLogging.debugmode);
|
|
28
28
|
if (!options.config)
|
|
29
29
|
throw new Error('Config is not defined.');
|
|
30
30
|
this.config = options.config;
|
|
@@ -42,10 +42,10 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
42
42
|
for (const command of modules.commands) {
|
|
43
43
|
if (!command.name)
|
|
44
44
|
continue;
|
|
45
|
-
if (command.
|
|
45
|
+
if (command.builder === 'MESSAGE_COMMAND') {
|
|
46
46
|
this.commands.MESSAGE_COMMANDS[command.name] = command;
|
|
47
47
|
}
|
|
48
|
-
else if (command.
|
|
48
|
+
else if (command.builder === 'INTERACTION_COMMAND') {
|
|
49
49
|
this.commands.INTERACTION_COMMANDS[command.name] = command;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -76,14 +76,16 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
78
|
messageCommandExecute(message) {
|
|
79
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
79
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
81
|
if (!message.content || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled))
|
|
82
82
|
return this;
|
|
83
83
|
const parseCommand = (0, fallout_utility_1.getCommand)(message.content, ((_b = this.config) === null || _b === void 0 ? void 0 : _b.prefix) || '!', ((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.messageCommand.commandArgumentSeparator) || ' ');
|
|
84
84
|
if (parseCommand && parseCommand.command) {
|
|
85
85
|
const command = this.commands.MESSAGE_COMMANDS[parseCommand.command];
|
|
86
|
-
if (command
|
|
86
|
+
if (!command)
|
|
87
|
+
return this;
|
|
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)) {
|
|
87
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))
|
|
88
90
|
return this;
|
|
89
91
|
if (command.validateOptions && !command.getCommandOptionValues(parseCommand)) {
|
|
@@ -99,18 +101,23 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
99
101
|
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
100
102
|
this.emit('recipleMessageCommandCreate', options);
|
|
101
103
|
}
|
|
104
|
+
else {
|
|
105
|
+
yield message.reply(((_h = this.config) === null || _h === void 0 ? void 0 : _h.messages.noPermissions) || 'You do not have permission to use this command.').catch((err) => this.logger.error(err));
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
108
|
return this;
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
interactionCommandExecute(interaction) {
|
|
107
|
-
var _a, _b, _c;
|
|
112
|
+
var _a, _b, _c, _d, _e;
|
|
108
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
114
|
if (!interaction || !interaction.isCommand() || !((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.enabled))
|
|
110
115
|
return this;
|
|
111
116
|
const command = this.commands.INTERACTION_COMMANDS[interaction.commandName];
|
|
112
|
-
if (
|
|
113
|
-
if (!command.allowExecuteInDM && interaction.member === null || (0, isIgnoredChannel_1.isIgnoredChannel)(interaction.channelId, (
|
|
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
|
+
return this;
|
|
120
|
+
if (!command)
|
|
114
121
|
return this;
|
|
115
122
|
const options = {
|
|
116
123
|
interaction: interaction,
|
|
@@ -121,13 +128,16 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
121
128
|
yield Promise.resolve(command.execute(options)).catch(err => this._commandExecuteError(err, options));
|
|
122
129
|
this.emit('recipleInteractionCommandCreate', options);
|
|
123
130
|
}
|
|
131
|
+
else {
|
|
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
|
+
}
|
|
124
134
|
return this;
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
137
|
_commandExecuteError(err, command) {
|
|
128
138
|
var _a, _b, _c, _d, _e;
|
|
129
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
this.logger.error(`An error occured executing ${command.builder.
|
|
140
|
+
this.logger.error(`An error occured executing ${command.builder.builder == 'MESSAGE_COMMAND' ? 'message' : 'interaction'} command "${command.builder.name}"`);
|
|
131
141
|
this.logger.error(err);
|
|
132
142
|
if (!err || !command)
|
|
133
143
|
return;
|
|
@@ -139,11 +149,11 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
139
149
|
else if (command === null || command === void 0 ? void 0 : command.interaction) {
|
|
140
150
|
if (!((_c = this.config) === null || _c === void 0 ? void 0 : _c.commands.interactionCommand.replyOnError))
|
|
141
151
|
return;
|
|
142
|
-
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)) {
|
|
143
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));
|
|
144
154
|
}
|
|
145
155
|
else {
|
|
146
|
-
yield command.interaction.
|
|
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));
|
|
147
157
|
}
|
|
148
158
|
}
|
|
149
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;
|
|
@@ -8,9 +8,11 @@ export interface RecipleInteractionCommandExecute {
|
|
|
8
8
|
client: RecipleClient;
|
|
9
9
|
}
|
|
10
10
|
export declare class InteractionCommandBuilder extends SlashCommandBuilder {
|
|
11
|
-
readonly
|
|
11
|
+
readonly builder: 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
|
}
|
|
@@ -5,10 +5,17 @@ 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
|
+
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,6 +1,7 @@
|
|
|
1
|
-
import { Message } from 'discord.js';
|
|
1
|
+
import { Message, PermissionFlags } from 'discord.js';
|
|
2
|
+
import { Command } from 'fallout-utility';
|
|
2
3
|
import { RecipleClient } from '../Client';
|
|
3
|
-
export interface CommandMessage {
|
|
4
|
+
export interface CommandMessage extends Command {
|
|
4
5
|
command?: string;
|
|
5
6
|
args?: string[];
|
|
6
7
|
raw?: string;
|
|
@@ -29,15 +30,17 @@ export declare class MessageOption {
|
|
|
29
30
|
setValidator(validator: (value: string) => boolean): MessageOption;
|
|
30
31
|
}
|
|
31
32
|
export declare class MessageCommandBuilder {
|
|
32
|
-
readonly
|
|
33
|
+
readonly builder: string;
|
|
33
34
|
name: string;
|
|
34
35
|
description: string;
|
|
35
36
|
options: MessageOption[];
|
|
36
37
|
validateOptions: boolean;
|
|
38
|
+
requiredPermissions: (keyof PermissionFlags)[];
|
|
37
39
|
allowExecuteInDM: boolean;
|
|
38
40
|
allowExecuteByBots: boolean;
|
|
39
41
|
execute: (options: RecipleMessageCommandExecute) => void;
|
|
40
42
|
setName(name: string): MessageCommandBuilder;
|
|
43
|
+
setRequiredPermissions(permissions: (keyof PermissionFlags)[]): MessageCommandBuilder;
|
|
41
44
|
setAllowExecuteInDM(allowExecuteInDM: boolean): MessageCommandBuilder;
|
|
42
45
|
setAllowExecuteByBots(allowExecuteByBots: boolean): MessageCommandBuilder;
|
|
43
46
|
setDescription(description: string): MessageCommandBuilder;
|
|
@@ -36,11 +36,12 @@ class MessageOption {
|
|
|
36
36
|
exports.MessageOption = MessageOption;
|
|
37
37
|
class MessageCommandBuilder {
|
|
38
38
|
constructor() {
|
|
39
|
-
this.
|
|
39
|
+
this.builder = 'MESSAGE_COMMAND';
|
|
40
40
|
this.name = '';
|
|
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.');
|
|
@@ -104,7 +111,7 @@ class MessageCommandBuilder {
|
|
|
104
111
|
const arg = args[i];
|
|
105
112
|
if (!arg && option.required)
|
|
106
113
|
return;
|
|
107
|
-
if (!option.validate(arg))
|
|
114
|
+
if (typeof arg !== 'undefined' && !option.validate(arg))
|
|
108
115
|
return;
|
|
109
116
|
result = [...result, { name: option.name, value: arg, required: option.required }];
|
|
110
117
|
i++;
|
|
@@ -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
|
|
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;
|
package/bin/reciple/flags.js
CHANGED
|
@@ -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;
|
package/bin/reciple/logger.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Logger } from 'fallout-utility';
|
|
2
|
-
export declare function logger(stringifyJSON: boolean): Logger;
|
|
2
|
+
export declare function logger(stringifyJSON: boolean, debugmode?: boolean): Logger;
|
package/bin/reciple/logger.js
CHANGED
|
@@ -2,10 +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
|
-
|
|
5
|
+
const flags_1 = require("./flags");
|
|
6
|
+
function logger(stringifyJSON, debugmode = false) {
|
|
6
7
|
return new fallout_utility_1.Logger("Main", {
|
|
7
8
|
addPrefixToEveryJsonNewLines: stringifyJSON,
|
|
8
9
|
stringifyJSON: stringifyJSON,
|
|
10
|
+
setDebugging: flags_1.flags.debugmode || debugmode
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
exports.logger = logger;
|
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.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Discord.js bot",
|
|
5
5
|
"author": "FalloutStudios",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -17,20 +17,21 @@
|
|
|
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
|
-
"commander": "^9.
|
|
27
|
+
"commander": "^9.2.0",
|
|
28
28
|
"discord.js": "^13.6.0",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"dotenv": "^16.0.0",
|
|
30
|
+
"fallout-utility": "^1.3.13",
|
|
31
|
+
"yaml": "^2.0.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^17.0.
|
|
34
|
+
"@types/node": "^17.0.24",
|
|
34
35
|
"typescript": "^4.6.3"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/resource/reciple.yml
CHANGED
|
@@ -32,6 +32,8 @@ ignoredChannels:
|
|
|
32
32
|
|
|
33
33
|
fileLogging:
|
|
34
34
|
enabled: true
|
|
35
|
+
debugmode: false
|
|
36
|
+
stringifyLoggedJSON: false
|
|
35
37
|
logFilePath: './logs/latest.log'
|
|
36
38
|
|
|
37
39
|
client:
|
|
@@ -45,7 +47,7 @@ client:
|
|
|
45
47
|
|
|
46
48
|
messages:
|
|
47
49
|
notEnoughArguments: 'Not enough arguments.'
|
|
48
|
-
|
|
50
|
+
noPermissions:
|
|
49
51
|
content: 'You do not have permission to use this command.'
|
|
50
52
|
ephemeral: true
|
|
51
53
|
error:
|