Changelog for 4.2
Every release, newest first, each on a page of its own with its notes in full. Entries marked Breaking change a working bot; the migration guide says what to do about them.
4.2.3
· 33 changes
Highlights
Stopping during startup is clean. A Ctrl+C, SIGTERM or
app.stop()before the bot is online exits 0 (your ownapp.stop()oncemain.tsis updated, see Upgrading) and closes what the startup made, such as a connection pool a provider opened.@Onand@Oncereach every instance the app makes, including a service only a guard or the presenter injects, a provider'suseClass,useValueoruseFactory.Clearer message command replies. The usage reply names the word a message left out or got wrong, quotes it as typed, and a pattern's own
--wordis matched where the pattern has it (docs).Mocks closer to discord.js. Mocks fill in more of what Discord always sends, in both modes, and
useStrictMocks()covers about twenty more behaviours that 5.0 makes the default.One process, two builds. A bot whose dependencies load both MeoCord's ES module and CommonJS builds shares one theme, one shutdown, one set of warnings and one exit code between them.
Upgrading from 4.2.2
main.tsand exit codes. A stop during startup now exits 0, and a built bot exits 1 whenMeoCordFactory.createrefuses its app.onShutdownruns on a stop during startup, for each class and provided value that was made and whoseonReady, and that of everything it depends on, has finished or doesn't exist.@Onhandlers that never ran now run, on a service only a stage or the presenter injects and on provided instances.@On('interactionCreate')stages get nocontext.response. A guard, interceptor or filter there that answered through it should answer throughcontext.getInteraction(); MeoCord also dispatches that interaction to its handler.A message command that works only in a server, by its
scope, amember,roleorchannelparam, or such a required flag, answers a DM that starts with a prefix or mention with "This command works in a server only." whatever words it gives, and gives no reply to one without.Observer durations for message and reaction handlers start when dispatch received the message or reaction, as for interactions, so a listener that waited behind another one reports that wait (docs).
Guards and observers, as now documented. A guard with
types: ['interaction']doesn't run before@Autocompletehandlers; declaretypes: ['interaction', 'autocomplete']to run it there.New startup warnings to act on. A missing
clientOptions.partialsentry that an@Onhandler's event needs now names the partial to add; without it, discord.js drops the event.meocord start --prodandregisterexit 128 plus the signal when the bot is killed by one the CLI didn't pass on, such as 137 for SIGKILL, wherestart --prodexited 0.A referenced TypeScript project's files resolve imports through the root
tsconfig.json'spaths, not their own.
Upgrading your tests
More behaviours under
useStrictMocks(). Each warns in default mode and becomes the default in 5.0.Mocks fill in more of what Discord sends, in both modes. A component interaction has the bot's message holding its component, a modal has empty
fields, a user'sdmChanneland itsrecipientare set, a mock given only aguildIdreads a placeholder server with that id,messages.fetch(id)finds a message made with that id, and channel types, display colours androles.resolve()read as discord.js gives them.The testing module matches the bot more closely.
init()makes the app's presenter, after the providers;close()shuts down what it injects.Routing in tests.
invoke()checks an autocomplete against the@Autocompletehandler it names, warning in default mode and rejecting underuseStrictMocks()where dispatch would pick another.Changed texts and types.
fromApp(),resolveRoute()andfindRouteConflicts()name anundefinedor module-namespace app, often a circular import, where each threw an emptyTypeError.
Deprecations
Warned now, refused in 5.0. Each runs as before with a warning at startup or when the class is decorated; 5.0 stops the bot or the command there.
Changing in 5.0, warned now:
- a static
prefix: []takes messages with no prefix; in 5.0 it starts no command.
- a static
Fixes to 4.2.2 behaviour
Running the bot
- A failed start is no longer among the apps a signal stops, so a later Ctrl+C stops only the running ones.
Message commands
- The usage reply names the word a message left out or replaced, such as
close is missing, and a missing required flag beside it, such as--in is missing, and quotes a word with its spaces as typed.
- The usage reply names the word a message left out or replaced, such as
Components
- The warning about a customId param that shares a name with a modal field or choice is given per handler, as
Controller.method.
- The warning about a customId param that shares a name with a modal field or choice is given per handler, as
Themes and translations
- A call keeps its theme for its whole run when another app in the process claims the theme outside calls.
Cooldowns
- A built-in store's
consume()refusal carriesretryTimestamp, so a custom store built on it no longer DMs a cooldown twice in one wait.
- A built-in store's
Logging
- Log lines escape U+061C, U+200E and U+200F in text a user wrote, as they escape other bidirectional controls.
Builds and the CLI
- An
externalspattern with thegoryflag keeps every matching import out of the bundle.
- An
Testing
createMockFn'smock.resultsfollows call order for a call that calls the mock again inside it.
Documentation
JsonifiedandShardContext.callsay an object arrives with its own fields only: JSON leaves a class's getters out.
Security
A handler a subclass overrides keeps its base method's guards and other method-level stages (GHSA-r9qr-grw6-8jpx).
Other behaviour the fix brings. An override's own
@UseThemegoes over the base method's, and its own@Validateor@Defertakes the place of the base method's; when the override callssuper, each guard still runs once per call.