reciple 1.3.3 → 1.4.2
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 +7 -7
- package/bin/bin.js +12 -5
- package/bin/index.d.ts +3 -0
- package/bin/index.js +7 -0
- package/bin/reciple/classes/Client.d.ts +20 -6
- package/bin/reciple/classes/Client.js +39 -13
- package/bin/reciple/classes/Config.js +9 -10
- package/bin/reciple/classes/builders/InteractionCommandBuilder.d.ts +1 -1
- package/bin/reciple/classes/builders/MessageCommandBuilder.d.ts +1 -1
- package/bin/reciple/commandPermissions.d.ts +4 -5
- package/bin/reciple/flags.js +2 -0
- package/bin/reciple/modules.d.ts +7 -6
- package/bin/reciple/modules.js +2 -1
- package/bin/reciple/registerInteractionCommands.d.ts +4 -4
- package/bin/reciple/registerInteractionCommands.js +7 -5
- package/package.json +38 -37
- package/resource/reciple.yml +1 -5
package/README.md
CHANGED
|
@@ -19,12 +19,12 @@ npm i reciple
|
|
|
19
19
|
You can initialize the bot to the current directory with the following command:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
reciple
|
|
22
|
+
npx reciple
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
It will ask you to continue if the directory is not empty type `y` to continue after the bot has been initialized it will ask you for your
|
|
25
|
+
It will ask you to continue if the directory is not empty type `y` to continue after the bot has been initialized it will ask you for your bot token.
|
|
26
26
|
|
|
27
|
-
> You can always change the token
|
|
27
|
+
> You can always change the token later
|
|
28
28
|
|
|
29
29
|
## Config
|
|
30
30
|
|
|
@@ -47,18 +47,18 @@ token: "env:TOKEN_VARIABLE"
|
|
|
47
47
|
You can override the token on the command line like so:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
reciple --token "YOUR_TOKEN_HERE"
|
|
50
|
+
npx reciple --token "YOUR_TOKEN_HERE"
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
## Running the bot
|
|
54
54
|
To run the bot, run the following command:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
reciple
|
|
57
|
+
npx 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
|
|
61
|
+
> The name reciple is from a minecraft bug. The bug was a misspelling of the word `recipe`. [View Mojang Bug Report](https://bugs.mojang.com/browse/MC-225837)
|
|
62
62
|
|
|
63
63
|
# Save the Earth
|
|
64
|
-
[
|
|
64
|
+
[#letTheEarthBreathe](https://rebellion.global/)
|
package/bin/bin.js
CHANGED
|
@@ -9,25 +9,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
|
+
var _a, _b;
|
|
12
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
14
|
const Config_1 = require("./reciple/classes/Config");
|
|
14
15
|
const Client_1 = require("./reciple/classes/Client");
|
|
15
16
|
const fs_1 = require("fs");
|
|
17
|
+
const version_1 = require("./reciple/version");
|
|
18
|
+
const flags_1 = require("./reciple/flags");
|
|
16
19
|
const fallout_utility_1 = require("fallout-utility");
|
|
17
20
|
require("dotenv/config");
|
|
21
|
+
if (flags_1.flags.version) {
|
|
22
|
+
console.log(`v${version_1.version}`);
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
18
25
|
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json', 'package.lock.json', 'modules.yml', '.rmmcache'];
|
|
19
26
|
if ((0, fs_1.readdirSync)('./').filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !(0, fs_1.existsSync)('./reciple.yml')) {
|
|
20
|
-
const ask = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ');
|
|
21
|
-
if (ask !== 'y')
|
|
27
|
+
const ask = (_a = (0, fallout_utility_1.input)('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ')) !== null && _a !== void 0 ? _a : '';
|
|
28
|
+
if (ask.toString().toLowerCase() !== 'y')
|
|
22
29
|
process.exit(0);
|
|
23
30
|
}
|
|
24
|
-
const config = new Config_1.RecipleConfig('./reciple.yml').parseConfig().getConfig();
|
|
31
|
+
const config = new Config_1.RecipleConfig((_b = flags_1.flags.config) !== null && _b !== void 0 ? _b : './reciple.yml').parseConfig().getConfig();
|
|
25
32
|
const client = new Client_1.RecipleClient(Object.assign({ config: config }, config.client));
|
|
26
33
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
34
|
yield client.startModules();
|
|
28
35
|
client.on('ready', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
var
|
|
30
|
-
client.logger.warn(`Logged in as ${((
|
|
36
|
+
var _c;
|
|
37
|
+
client.logger.warn(`Logged in as ${((_c = client.user) === null || _c === void 0 ? void 0 : _c.tag) || 'Unknown'}!`);
|
|
31
38
|
yield client.loadModules();
|
|
32
39
|
client.addCommandListeners();
|
|
33
40
|
}));
|
package/bin/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import discord from 'discord.js';
|
|
2
|
+
export declare const discordjs: typeof discord;
|
|
1
3
|
export * from './reciple/classes/Client';
|
|
2
4
|
export * from './reciple/classes/Config';
|
|
3
5
|
export * from './reciple/classes/builders/InteractionCommandBuilder';
|
|
4
6
|
export * from './reciple/classes/builders/MessageCommandBuilder';
|
|
7
|
+
export * from './reciple/classes/builders/MessageCommandOptionBuilder';
|
|
5
8
|
export * from './reciple/commandPermissions';
|
|
6
9
|
export * from './reciple/flags';
|
|
7
10
|
export * from './reciple/isIgnoredChannel';
|
package/bin/index.js
CHANGED
|
@@ -13,11 +13,18 @@ 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
|
+
};
|
|
16
19
|
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;
|
|
17
23
|
__exportStar(require("./reciple/classes/Client"), exports);
|
|
18
24
|
__exportStar(require("./reciple/classes/Config"), exports);
|
|
19
25
|
__exportStar(require("./reciple/classes/builders/InteractionCommandBuilder"), exports);
|
|
20
26
|
__exportStar(require("./reciple/classes/builders/MessageCommandBuilder"), exports);
|
|
27
|
+
__exportStar(require("./reciple/classes/builders/MessageCommandOptionBuilder"), exports);
|
|
21
28
|
__exportStar(require("./reciple/commandPermissions"), exports);
|
|
22
29
|
__exportStar(require("./reciple/flags"), exports);
|
|
23
30
|
__exportStar(require("./reciple/isIgnoredChannel"), exports);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ApplicationCommandDataResolvable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
2
|
-
import { Logger as LoggerConstructor } from 'fallout-utility';
|
|
3
|
-
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
|
|
4
1
|
import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './builders/InteractionCommandBuilder';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { interactionCommandBuilders } from '../registerInteractionCommands';
|
|
3
|
+
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './builders/MessageCommandBuilder';
|
|
4
|
+
import { Logger as LoggerConstructor } from 'fallout-utility';
|
|
7
5
|
import { Config } from './Config';
|
|
6
|
+
import { ApplicationCommandDataResolvable, Awaitable, Client, ClientEvents, ClientOptions, Interaction, Message } from 'discord.js';
|
|
7
|
+
import { recipleCommandBuilders, RecipleScript } from '../modules';
|
|
8
8
|
export interface RecipleClientOptions extends ClientOptions {
|
|
9
9
|
config: Config;
|
|
10
10
|
}
|
|
@@ -20,16 +20,30 @@ export interface RecipleClientEvents extends ClientEvents {
|
|
|
20
20
|
recipleMessageCommandCreate: [command: RecipleMessageCommandExecute];
|
|
21
21
|
recipleInteractionCommandCreate: [command: RecipleInteractionCommandExecute];
|
|
22
22
|
}
|
|
23
|
+
export interface RecipleClient extends Client {
|
|
24
|
+
on<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
25
|
+
on<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
|
|
26
|
+
once<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
27
|
+
once<E extends keyof string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
|
|
28
|
+
emit<E extends keyof RecipleClientEvents>(event: E, ...args: RecipleClientEvents[E]): boolean;
|
|
29
|
+
emit<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, ...args: any): boolean;
|
|
30
|
+
off<E extends keyof RecipleClientEvents>(event: E, listener: (...args: RecipleClientEvents[E]) => Awaitable<void>): this;
|
|
31
|
+
off<E extends string | symbol>(event: Exclude<E, keyof RecipleClientEvents>, listener: (...args: any) => Awaitable<void>): this;
|
|
32
|
+
removeAllListeners<E extends keyof RecipleClientEvents>(event?: E): this;
|
|
33
|
+
removeAllListeners(event?: string | symbol): this;
|
|
34
|
+
}
|
|
23
35
|
export declare class RecipleClient extends Client {
|
|
24
36
|
config?: Config;
|
|
25
37
|
commands: RecipleClientCommands;
|
|
26
|
-
otherApplicationCommandData: (
|
|
38
|
+
otherApplicationCommandData: (interactionCommandBuilders | ApplicationCommandDataResolvable)[];
|
|
27
39
|
modules: RecipleScript[];
|
|
28
40
|
logger: LoggerConstructor;
|
|
29
41
|
version: string;
|
|
30
42
|
constructor(options: RecipleClientOptions);
|
|
31
43
|
startModules(): Promise<RecipleClient>;
|
|
32
44
|
loadModules(): Promise<RecipleClient>;
|
|
45
|
+
addModule(script: RecipleScript, registerCommands?: boolean): Promise<void>;
|
|
46
|
+
addCommand(command: recipleCommandBuilders): RecipleClient;
|
|
33
47
|
addCommandListeners(): RecipleClient;
|
|
34
48
|
messageCommandExecute(message: Message): Promise<RecipleClient>;
|
|
35
49
|
interactionCommandExecute(interaction: Interaction): Promise<RecipleClient>;
|
|
@@ -16,14 +16,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.RecipleClient = void 0;
|
|
19
|
-
const discord_js_1 = require("discord.js");
|
|
20
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
21
19
|
const registerInteractionCommands_1 = require("../registerInteractionCommands");
|
|
22
|
-
const
|
|
23
|
-
const modules_1 = require("../modules");
|
|
24
|
-
const version_1 = require("../version");
|
|
20
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
25
21
|
const commandPermissions_1 = require("../commandPermissions");
|
|
26
22
|
const isIgnoredChannel_1 = require("../isIgnoredChannel");
|
|
23
|
+
const version_1 = require("../version");
|
|
24
|
+
const logger_1 = require("../logger");
|
|
25
|
+
const discord_js_1 = require("discord.js");
|
|
26
|
+
const modules_1 = require("../modules");
|
|
27
27
|
class RecipleClient extends discord_js_1.Client {
|
|
28
28
|
constructor(options) {
|
|
29
29
|
super(options);
|
|
@@ -49,12 +49,7 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
49
49
|
for (const command of modules.commands) {
|
|
50
50
|
if (!command.name)
|
|
51
51
|
continue;
|
|
52
|
-
|
|
53
|
-
this.commands.MESSAGE_COMMANDS[command.name] = command;
|
|
54
|
-
}
|
|
55
|
-
else if (command.builder === 'INTERACTION_COMMAND') {
|
|
56
|
-
this.commands.INTERACTION_COMMANDS[command.name] = command;
|
|
57
|
-
}
|
|
52
|
+
this.addCommand(command);
|
|
58
53
|
}
|
|
59
54
|
this.logger.info(`${Object.keys(this.commands.MESSAGE_COMMANDS).length} message commands loaded.`);
|
|
60
55
|
this.logger.info(`${Object.keys(this.commands.INTERACTION_COMMANDS).length} interaction commands loaded.`);
|
|
@@ -69,11 +64,42 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
69
64
|
yield Promise.resolve(module_.onLoad(this));
|
|
70
65
|
}
|
|
71
66
|
this.logger.info(`${this.modules.length} modules loaded.`);
|
|
72
|
-
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands)
|
|
73
|
-
|
|
67
|
+
if (!((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.interactionCommand.registerCommands))
|
|
68
|
+
return this;
|
|
69
|
+
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
|
|
74
70
|
return this;
|
|
75
71
|
});
|
|
76
72
|
}
|
|
73
|
+
addModule(script, registerCommands = true) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
this.modules.push(script);
|
|
77
|
+
if (typeof (script === null || script === void 0 ? void 0 : script.onLoad) === 'function')
|
|
78
|
+
yield Promise.resolve(script.onLoad(this));
|
|
79
|
+
this.logger.info(`${this.modules.length} modules loaded.`);
|
|
80
|
+
for (const command of (_a = script.commands) !== null && _a !== void 0 ? _a : []) {
|
|
81
|
+
if (!command.name)
|
|
82
|
+
continue;
|
|
83
|
+
this.addCommand(command);
|
|
84
|
+
}
|
|
85
|
+
if (!registerCommands || !((_b = this.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.registerCommands))
|
|
86
|
+
return;
|
|
87
|
+
yield (0, registerInteractionCommands_1.registerInteractionCommands)(this, [...Object.values(this.commands.INTERACTION_COMMANDS), ...this.otherApplicationCommandData]);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
addCommand(command) {
|
|
91
|
+
var _a;
|
|
92
|
+
if (command.builder === 'MESSAGE_COMMAND') {
|
|
93
|
+
this.commands.MESSAGE_COMMANDS[command.name] = command;
|
|
94
|
+
}
|
|
95
|
+
else if (command.builder === 'INTERACTION_COMMAND') {
|
|
96
|
+
this.commands.INTERACTION_COMMANDS[command.name] = command;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.logger.error(`Command "${(_a = command.name) !== null && _a !== void 0 ? _a : 'unknown'}" has an invalid builder.`);
|
|
100
|
+
}
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
77
103
|
addCommandListeners() {
|
|
78
104
|
var _a, _b;
|
|
79
105
|
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.commands.messageCommand.enabled)
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RecipleConfig = void 0;
|
|
7
|
-
const fallout_utility_1 = require("fallout-utility");
|
|
8
7
|
const fs_1 = require("fs");
|
|
8
|
+
const version_1 = require("../version");
|
|
9
|
+
const fallout_utility_1 = require("fallout-utility");
|
|
9
10
|
const flags_1 = require("../flags");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const yaml_1 = __importDefault(require("yaml"));
|
|
12
|
-
const version_1 = require("../version");
|
|
13
13
|
class RecipleConfig {
|
|
14
14
|
constructor(configPath) {
|
|
15
15
|
this.configPath = './reciple.yml';
|
|
@@ -49,20 +49,19 @@ class RecipleConfig {
|
|
|
49
49
|
return this.config;
|
|
50
50
|
}
|
|
51
51
|
parseToken(askIfNull = true) {
|
|
52
|
+
var _a, _b;
|
|
52
53
|
let token = flags_1.token || null;
|
|
53
|
-
if (token)
|
|
54
|
+
if (!this.config && !token)
|
|
54
55
|
return token;
|
|
55
|
-
if (!this.config)
|
|
56
|
-
return token;
|
|
57
|
-
if (!this.config.token)
|
|
56
|
+
if (this.config && !((_a = this.config) === null || _a === void 0 ? void 0 : _a.token) && !token)
|
|
58
57
|
return token || (askIfNull ? this.askToken() : null);
|
|
59
|
-
|
|
58
|
+
token = token || ((_b = this.config) === null || _b === void 0 ? void 0 : _b.token) || null;
|
|
59
|
+
if (!token)
|
|
60
|
+
return token;
|
|
61
|
+
const envToken = token.toString().split(':');
|
|
60
62
|
if (envToken.length === 2 && envToken[0].toLocaleLowerCase() === 'env' && envToken[1]) {
|
|
61
63
|
token = process.env[envToken[1]] || null;
|
|
62
64
|
}
|
|
63
|
-
else {
|
|
64
|
-
token = this.config.token;
|
|
65
|
-
}
|
|
66
65
|
return token || (askIfNull ? this.askToken() : null);
|
|
67
66
|
}
|
|
68
67
|
isSupportedConfig() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
2
1
|
import { CommandInteraction, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
|
+
import { SlashCommandBuilder } from '@discordjs/builders';
|
|
3
3
|
import { RecipleClient } from '../Client';
|
|
4
4
|
export interface RecipleInteractionCommandExecute {
|
|
5
5
|
interaction: CommandInteraction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
1
2
|
import { Message, PermissionFlags, PermissionString } from 'discord.js';
|
|
2
3
|
import { Command } from 'fallout-utility';
|
|
3
4
|
import { RecipleClient } from '../Client';
|
|
4
|
-
import { MessageCommandOptionBuilder } from './MessageCommandOptionBuilder';
|
|
5
5
|
export declare type CommandMessage = Command;
|
|
6
6
|
export interface RecipleMessageCommandExecute {
|
|
7
7
|
message: Message;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Permissions } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: InteractionCommandBuilder | MessageCommandBuilder): boolean;
|
|
1
|
+
import { Permissions } from 'discord.js';
|
|
2
|
+
import { recipleCommandBuilders } from './modules';
|
|
3
|
+
import { Config } from './classes/Config';
|
|
4
|
+
export declare function commandPermissions(commandName: string, memberPermissions?: Permissions, configConmmandPermissions?: Config['permissions']['messageCommands'] | Config['permissions']['interactionCommands'], builder?: recipleCommandBuilders): boolean;
|
package/bin/reciple/flags.js
CHANGED
|
@@ -4,6 +4,8 @@ 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('-c, --config <config>', 'Change path to config file')
|
|
7
8
|
.option('-D, --debugmode', 'Enabled debug mode')
|
|
9
|
+
.option('-v, --version', 'Display version')
|
|
8
10
|
.parse().opts();
|
|
9
11
|
exports.token = exports.flags.token;
|
package/bin/reciple/modules.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { InteractionCommandBuilder, RecipleInteractionCommandExecute } from './classes/builders/InteractionCommandBuilder';
|
|
2
|
+
import { MessageCommandBuilder, RecipleMessageCommandExecute } from './classes/builders/MessageCommandBuilder';
|
|
1
3
|
import { RecipleClient } from './classes/Client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare type recipleCommands = (MessageCommandBuilder | InteractionCommandBuilder)[];
|
|
4
|
+
export declare type recipleCommandBuilders = MessageCommandBuilder | InteractionCommandBuilder;
|
|
5
|
+
export declare type recipleCommandBuildersExecute = RecipleInteractionCommandExecute | RecipleMessageCommandExecute;
|
|
5
6
|
export declare type loadedModules = {
|
|
6
|
-
commands:
|
|
7
|
+
commands: recipleCommandBuilders[];
|
|
7
8
|
modules: RecipleModule[];
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
+
export declare class RecipleScript {
|
|
10
11
|
versions: string | string[];
|
|
11
|
-
commands?:
|
|
12
|
+
commands?: recipleCommandBuilders[];
|
|
12
13
|
onLoad?(reciple: RecipleClient): void | Promise<void>;
|
|
13
14
|
onStart(reciple: RecipleClient): boolean | Promise<boolean>;
|
|
14
15
|
}
|
package/bin/reciple/modules.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.loadModules = void 0;
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const version_1 = require("./version");
|
|
18
|
+
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
18
19
|
const path_1 = __importDefault(require("path"));
|
|
19
20
|
function loadModules(client) {
|
|
20
21
|
var _a, _b, _c;
|
|
@@ -26,7 +27,7 @@ function loadModules(client) {
|
|
|
26
27
|
(0, fs_1.mkdirSync)(modulesDir, { recursive: true });
|
|
27
28
|
const ignoredFiles = (((_b = client.config) === null || _b === void 0 ? void 0 : _b.ignoredFiles) || []).map(file => file.endsWith('.js') ? file : `${file}.js`);
|
|
28
29
|
const scripts = (0, fs_1.readdirSync)(modulesDir).filter(file => {
|
|
29
|
-
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.
|
|
30
|
+
return file.endsWith('.js') && (!file.startsWith('_') && !file.startsWith('.')) && !ignoredFiles.some(f => (0, wildcard_match_1.default)(f)(file));
|
|
30
31
|
});
|
|
31
32
|
for (const script of scripts) {
|
|
32
33
|
const modulePath = path_1.default.resolve(modulesDir, script);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InteractionCommandBuilder } from './classes/builders/InteractionCommandBuilder';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ApplicationCommandDataResolvable } from 'discord.js';
|
|
3
|
+
import { RecipleClient } from './classes/Client';
|
|
4
4
|
import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandOptionsOnlyBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder } from '@discordjs/builders';
|
|
5
|
-
export declare type
|
|
6
|
-
export declare function registerInteractionCommands(client: RecipleClient, cmds?: (
|
|
5
|
+
export declare type interactionCommandBuilders = InteractionCommandBuilder | ContextMenuCommandBuilder | SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandGroupBuilder | SlashCommandSubcommandsOnlyBuilder;
|
|
6
|
+
export declare function registerInteractionCommands(client: RecipleClient, cmds?: (interactionCommandBuilders | ApplicationCommandDataResolvable)[], overwriteGuilds?: string | string[]): Promise<void>;
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerInteractionCommands = void 0;
|
|
13
13
|
function registerInteractionCommands(client, cmds, overwriteGuilds) {
|
|
14
|
-
var _a, _b, _c, _d
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
let commands = (_a = Object.values(cmds !== null && cmds !== void 0 ? cmds : client.commands.INTERACTION_COMMANDS).map(c => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -36,16 +36,18 @@ function registerInteractionCommands(client, cmds, overwriteGuilds) {
|
|
|
36
36
|
const configGuilds = overwriteGuilds !== null && overwriteGuilds !== void 0 ? overwriteGuilds : (_b = client.config) === null || _b === void 0 ? void 0 : _b.commands.interactionCommand.guilds;
|
|
37
37
|
const guilds = typeof configGuilds === 'object' ? configGuilds : [configGuilds];
|
|
38
38
|
if (!guilds || !(guilds === null || guilds === void 0 ? void 0 : guilds.length)) {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
(_c = client.application) === null || _c === void 0 ? void 0 : _c.commands.set(commands).then(() => {
|
|
40
|
+
client.logger.warn('No guilds were specified for interaction commands. Registered commands for all guilds.');
|
|
41
|
+
}).catch(e => client.logger.error(e));
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
client.logger.warn(`Registering ${commands.length} interaction commands for ${guilds.length} guild(s).`);
|
|
44
45
|
for (const guild of guilds) {
|
|
45
46
|
if (!guild)
|
|
46
47
|
continue;
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
(_d = client.application) === null || _d === void 0 ? void 0 : _d.commands.set(commands, guild).then(() => {
|
|
49
|
+
client.logger.warn(`Registered ${commands.length} interaction commands for ${guild}.`);
|
|
50
|
+
}).catch(e => client.logger.error(e));
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
});
|
package/package.json
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "reciple",
|
|
3
|
+
"version": "1.4.2",
|
|
4
|
+
"description": "A Discord.js bot",
|
|
5
|
+
"author": "FalloutStudios",
|
|
6
|
+
"license": "GPL-3.0",
|
|
7
|
+
"main": "bin/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"reciple": "bin/bin.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"resource",
|
|
14
|
+
"package.json",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rimraf bin",
|
|
20
|
+
"compile": "yarn clean && npx tsc",
|
|
21
|
+
"build": "yarn compile && npm un reciple -g && npm i ./ -g",
|
|
22
|
+
"build:publish": "yarn run build && yarn run changelog && yarn publish",
|
|
23
|
+
"test": "cd test && npx reciple",
|
|
24
|
+
"test:build": "yarn run build && yarn test:run"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"commander": "^9.3.0",
|
|
28
|
+
"discord.js": "^13.8.1",
|
|
29
|
+
"dotenv": "^16.0.1",
|
|
30
|
+
"fallout-utility": "^1.3.14",
|
|
31
|
+
"semver": "^7.3.7",
|
|
32
|
+
"wildcard-match": "^5.1.2",
|
|
33
|
+
"yaml": "^2.1.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^18.0.0",
|
|
37
|
+
"@types/semver": "^7.3.10",
|
|
38
|
+
"typescript": "^4.7.4"
|
|
39
|
+
}
|
|
39
40
|
}
|
package/resource/reciple.yml
CHANGED
|
@@ -70,10 +70,7 @@ client:
|
|
|
70
70
|
intents:
|
|
71
71
|
- 'GUILDS'
|
|
72
72
|
- 'GUILD_MEMBERS'
|
|
73
|
-
- 'GUILD_INVITES'
|
|
74
|
-
- 'GUILD_VOICE_STATES'
|
|
75
73
|
- 'GUILD_MESSAGES'
|
|
76
|
-
- 'GUILD_MESSAGE_REACTIONS'
|
|
77
74
|
|
|
78
75
|
# Bot replies
|
|
79
76
|
messages:
|
|
@@ -86,8 +83,7 @@ messages:
|
|
|
86
83
|
ephemeral: true
|
|
87
84
|
|
|
88
85
|
# Ignored Files
|
|
89
|
-
ignoredFiles:
|
|
90
|
-
- 'test.js'
|
|
86
|
+
ignoredFiles: []
|
|
91
87
|
|
|
92
88
|
|
|
93
89
|
###################################################
|