Reciple is a Discord.js command handler framework that just works :3
This application is generated by
create-reciple
.
Configuration file is set to ./reciple.mjs
or ./reciple.cjs
by default on the CLI.
To change the config path, simply add the
-c, --config <path>
flag
With Reciple a module can be a command, event, or anything. Reciple scans the dirs given from the config and loads every valid javascript files in that folder.
// Module config (reciple.mjs)
export const config = {
// other things
modules: {
dirs: ['./modules'], // scans the modules folder
exclude: [],
filter: file => true,
disableModuleVersionCheck: false
},
// other things
};
> Folder structure
reciple.mjs
package.json
node_modules/
modules/
├─ module1.js
├─ module2.js
You can also use a glob pattern for your dir config.
// Module config (reciple.mjs)
export const config = {
// other things
modules: {
dirs: ['./modules/**/*'], // scans the modules folder and every folders in it recursively
exclude: [],
filter: file => true,
disableModuleVersionCheck: false
},
// other things
};
> Folder structure
reciple.mjs
package.json
node_modules/
modules/
├─ module1.js
├─ module2.js
├─anotherFolder/
├─ module1.js
├─ module2.js
Reciple can load CommonJs and ESM modules at the same time.
.js
.cjs
.mjs
// ESM
export default {
versions: ['^8'],
onStart: async ({ client }) => true, // Always return true if the module is loaded
onLoad: async ({ client }) => {},
onUnload: async ({ client }) => {}
};
// CJS
module.exports = {
versions: ['^8'],
onStart: async ({ client }) => true, // Always return true if the module is loaded
onLoad: async ({ client }) => {},
onUnload: async ({ client }) => {}
};
Modules Using Classes
// ESM
export class MyModule {
versions = ['^8'];
async onStart({ client }) {
return true; // Always return true if the module is loaded
}
async onLoad({ client }) {}
async onUnload({ client }) {}
};
export default new MyModule();
// CJS
class MyModule {
versions = ['^8'];
async onStart({ client }) {
return true; // Always return true if the module is loaded
}
async onLoad({ client }) {}
async onUnload({ client }) {}
};
module.exports = new MyModule();
To add commands to your module, simply add commands
propery to your module.
export default {
versions: ['^8'],
commands: [], // Commands goes here
onStart: async ({ client }) => true, // Always return true if the module is loaded
onLoad: async ({ client }) => {},
onUnload: async ({ client }) => {}
};
Instead of importing command builders from Discord.js, use the command builders provided by Reciple.
// ESM
- import { ContextMenuCommandBuilder, SlashCommandBuilder } from 'discord.js';
+ import { ContextMenuCommandBuilder, SlashCommandBuilder } from 'reciple';
// CJS
- const { ContextMenuCommandBuilder, SlashCommandBuilder } = require('discord.js');
+ const { ContextMenuCommandBuilder, SlashCommandBuilder } = require('reciple');
Just create a new instance of a command builder in the commands array to add commands to a module.
import { ContextMenuCommandBuilder, MessageCommandBuilder, SlashCommandBuilder } from 'reciple';
export default {
versions: ['^8'],
commands: [
new ContextMenuCommandBuilder()
.setName('To Lowercase')
.setType('Message')
.setExecute(async ({ interaction }) => interaction.reply(interaction.targetMessage.content.toLowercase())),
new MessageCommandBuilder()
.setName('hi')
.setDescript('Say hello')
.setExecute(async ({ message }) => message.reply('hello')),
new SlashCommandBuilder()
.setName('hello')
.setDescript('Say hi')
.setExecute(async ({ interaction }) => interaction.reply('hi'))
],
onStart: async ({ client }) => true, // Always return true if the module is loaded
onLoad: async ({ client }) => {},
onUnload: async ({ client }) => {}
};