What's new in 4.3
What 4.3 adds to a 4.2 bot, area by area, the options that bring 5.0's defaults early, and what a working bot may notice.
4.3 adds to 4.2 without breaking a bot that only calls MeoCord's functions: a 4.2 bot and its tests build and run
without edits. A few warnings are new, the help reply splits more carefully, and code that writes a Route object by
hand needs a match method. Upgrading from 4.2 to 4.3 lists each, with what
to check. Every release's notes are in the changelog.
Formatting
commandMentiongives a clickable mention of one of your slash commands, its ID looked up where the reader can run it. See Formatting.formatDurationandpermissionNameswrite a length of time and a list of permissions in the reader's language, through your app's translator. See Writing a duration and Naming permissions.splitMessage,truncateandDiscordLimitsfit text to what Discord accepts, closing and reopening code cut across messages. See Splitting a long message.- discord.js's formatters, such as
userMentionandtime, are exported frommeocord/commontoo, so a bot imports its formatting from one place. See discord.js's formatters.
Guards
OwnerGuardlets only the user whose ID a component's customId carries use it, and tells anyone else why in their language. See Letting only its owner use a component.answerDenied: trueanswers a guard'sfalseon an interaction as aGuardDeniedError, privately, where a command was left unanswered. See Refusing a call.globalStagesOnEvents: falsekeeps global guards and interceptors withouttypesoff@Onand@Oncehandlers. See Where guards apply.
Lifecycle hooks
waitForReady: trueholds each call until theonReadyhooks of the classes it uses have settled, so a handler can rely on a cache anonReadywarms. See Waiting for the hooks.warnSlownames slow work: anonReadystill running after 10 seconds, with how many hooks wait behind it, and an autocomplete that takes 2 of its 3 seconds.warnSlow: falsesilences them. See onReady.- An autocomplete left unanswered has its menu closed with no choices, where the member saw it fail to load, and its handler is named once a run. See Autocomplete.
- A stop while the bot starts shuts down what the start made before
start()rejects, and anonShutdownhook may stop its own app. See onShutdown.
Components, themes and text
route().match(customId)reads a customId back into the params its handler would receive, andRouteMatchtypes them. See Reading a customId back.bindThemeanswers each call it wraps in the theme of the member and server it answers, so every member who clicks a collected button sees their own. See Collectors and listeners.t.localizations(key, params)fills params into each locale's translation of a command's name or description. See Choosing the language.ValidationIssue.rawkeeps what the schema reported, such as zod'scodeandminimum, for refusals in your own words. See Validation.
CLI and builds
generateadds a controller or observer tosrc/app.ts, or says why it can't. See Scaffolding.register --pruneremoves your commands from servers the configuration no longer names. See Removing commands left in other servers.- A stale build is named when
start --prodorregisterruns it. See Development and production. - A self-contained build packs every installed copy of a native addon, and each importer loads its own. See Native addons and platforms.
- Under Bun, an uncaught error and
console.error(error)name your source, as under Node. See Stack traces.
Testing
- Strict mocks answer what discord.js answers: an interaction's answers resolve to its response, a mock client's
emitter works, and collectors made on a mock collect what
dispatchdelivers. See Collectors. eventFallback: truehasemitanswer an event handler's refusals as the bot does. See Invoke and dispatch.inspectHandler()reports a handler's@Defer, andoverrideCommandIdsets the IDcommandMentiongives. See Testing.- jest loads
meocord/testingwithout Node's VM modules. See Running tests.
Getting ready for 5.0
Five options bring a 5.0 default into 4.3, so a bot can move to it one change at a time: allowedMentions set to
{ parse: [] } in clientOptions, globalStagesOnEvents: false, and in tests eventFallback: true, typedValues
and useStrictMocks(). A bot or a test that leaves allowedMentions, globalStagesOnEvents or eventFallback unset
gets a warning naming it, where 5.0 would change what happens.
More options that bring 5.0's defaults early lists the
new ones.