Skip to content
GitHub

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 own app.stop() once main.ts is updated, see Upgrading) and closes what the startup made, such as a connection pool a provider opened.

  • @On and @Once reach every instance the app makes, including a service only a guard or the presenter injects, a provider's useClass, useValue or useFactory.

  • 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 --word is 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.ts and exit codes. A stop during startup now exits 0, and a built bot exits 1 when MeoCordFactory.create refuses its app.

  • onShutdown runs on a stop during startup, for each class and provided value that was made and whose onReady, and that of everything it depends on, has finished or doesn't exist.

  • @On handlers that never ran now run, on a service only a stage or the presenter injects and on provided instances.

  • @On('interactionCreate') stages get no context.response. A guard, interceptor or filter there that answered through it should answer through context.getInteraction(); MeoCord also dispatches that interaction to its handler.

  • A message command that works only in a server, by its scope, a member, role or channel param, 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 @Autocomplete handlers; declare types: ['interaction', 'autocomplete'] to run it there.

  • New startup warnings to act on. A missing clientOptions.partials entry that an @On handler's event needs now names the partial to add; without it, discord.js drops the event.

  • meocord start --prod and register exit 128 plus the signal when the bot is killed by one the CLI didn't pass on, such as 137 for SIGKILL, where start --prod exited 0.

  • A referenced TypeScript project's files resolve imports through the root tsconfig.json's paths, 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's dmChannel and its recipient are set, a mock given only a guildId reads a placeholder server with that id, messages.fetch(id) finds a message made with that id, and channel types, display colours and roles.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 @Autocomplete handler it names, warning in default mode and rejecting under useStrictMocks() where dispatch would pick another.

  • Changed texts and types. fromApp(), resolveRoute() and findRouteConflicts() name an undefined or module-namespace app, often a circular import, where each threw an empty TypeError.

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.

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.
  • Components

    • The warning about a customId param that shares a name with a modal field or choice is given per handler, as Controller.method.
  • 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 carries retryTimestamp, so a custom store built on it no longer DMs a cooldown twice in one wait.
  • 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 externals pattern with the g or y flag keeps every matching import out of the bundle.
  • Testing

    • createMockFn's mock.results follows call order for a call that calls the mock again inside it.
  • Documentation

    • Jsonified and ShardContext.call say 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 @UseTheme goes over the base method's, and its own @Validate or @Defer takes the place of the base method's; when the override calls super, each guard still runs once per call.

The 4.2.3 notes in full

Earlier releases

  • 4.2.2 · · 10 patch changes
  • 4.2.1 · · 53 patch changes
  • 4.2.0 · · 7 minor changes and 3 patch changes