Migrating from v8
This page is will show the changes made to properly migrade from Reciple v8 to v9. If you are not migrating from v8, you can proceed to the next page.
What’s New
The next generation of Reciple has arrived with new cool features and fixes
Optional module versions
property
The versions
property is now optional! It’s been a long time since we actually used this property, its importance declined from the previous versions of Reciple making it redundant. By making it optional, we’re allowing previous devs to still support multiple Reciple versions if they want to.
export class MyModule {
// ...
+ versions?: string[]; // Optional property
// ...
}
export default new MyModule();
Custom Message Command Option Validation Errors
You can now return a string
or an Error
when the validation of a message command option has failed instead of just returning boolean
. For example:
new MessageCommandBuilder()
.setName('test')
.setDescription('Test command')
.addOption(option => option
.setName('option')
.setDescription('Option description')
.setRequired(true)
.setValidate(({ value }) => value === 'test' ? true : new Error('Invalid value'))
)
These error messages will be defined in MessageCommandOptionValue
’s error
property.
Restructured Command Halt
Command halts are very useful for handling post-command data such as error, cooldown, and precondition results. However, there was no way to handle them with multiple handlers.
Now, we can create command halts like you would with command preconditions. Instead of just one function, command halts can now be added into an array inside your command data.
Global Halts
Setting halt for every single command was a pain by making your own modules and looping through the commands. But now, you can set a global command hal by importing the command halt object into the commandHalts
property in your config.
Breaking Changes
Since this is a major update, we’ve made some breaking changes. Please make sure to update your code accordingly.
Packages Are Now ESM Only
All packages are now ESM only. This means that you’ll need to use import
instead of require
.
The reason behind this decision is because require
is not the standard way of importing packages and Discord.js has converted their type definitions into different types for cjs
and mjs
. This change made our previous TypeScript with ESM template unusable. But, since ESM is the standard for JavaScript uses import
we’ve decided to migrate our code from cjs
to esm
only.
New Way of Setting Command Halts
.setHalt
is now removed in favor of .setHalts
and .addHalts
. This change is made to support the new structure of command halts. Here’s the example of how to use this methods.
import MyCommandHalt from '../halts/mycommandhalt.js';
new SlashCommandBuilder()
.setName('mycommand') // ... other command data ...
.addHalts(MyCommandHalt) // Add command halt to the command.
.setHalts(MyCommandHalt) // Set command halts to the command. This will override any halts added with `addHalts`.
Things That Are Removed or Replaced
-
- CommandManager.removePreconditions() + CommandManager.preconditions.delete() - CommandManager.disablePreconditions() + CommandManager.halts.each(p => p.setDisabled(true)) - CommandManager.enablePreconditions() + CommandManager.halts.each(p => p.setDisabled(false)) - CommandManager.getApplicationCommand() + RecipleClient.application.commands.cache.get() - CommandManager.fetchApplicationCommand() + RecipleClient.application.commands.fetch() - RecipleClient.executeCommandBuilderHalt() + CommandManager.executeHalts() - RecipleClient.executeCommandBuilderExecute() + CommandManager.executeCommandBuilderExecute() - CooldownPrecondition.create() + new CooldownPrecondition() - CommandPermissionsPrecondition.create() + new CommandPermissionsPrecondition()
-
- parseMessageURL() + MessageURLData.parse() - fetchMessageURL() + MessageURLData.fetch()
@reciple/update-checker This package has been removed. The functionalities of these package was moved to
@reciple/utils
under thePackageUpdateChecker
class.