Releases: Mimickal/discordjs-command-registry
Command handler decorators
Note: v3.1.0
does not exist because I unpublished it after a bout of temporary insanity working directly off master
Added requireAdmin
and requireGuild
decorators that can wrap command handlers with common logic.
In the following example, using requireGuild
allows the handler to skip checking if the interaction is happening in a guild.
const { requireGuild, SlashCommandBuilder } = require('discord-command-registry');
const cmd = new SlashCommandBuilder().setHandler(requireGuild(cmdHandler));
// interaction.guild is now guaranteed to not be null
function cmdHandler(interaction) {
interaction.guild; // Not null!
}
Fix missing utility exports
...by removing them entirely.
- Utility functions are no longer forwarded. Import these directly from
discord.js
instead. See #14. - The
register
script now has an option to print the library version.
Fix TypeScript errors
This release fixes some scenarios where TypeScript would report type incompatibilities in builders.
.addXOption
functions from Discord.js now preserve type information.- Handler functions now determine
interaction
type better. - Handler functions don't cause TypeScript errors anymore (no idea how I didn't catch this the first time around).
The port to TypeScript
Changes:
- This library now uses TypeScript! This should be a drop-in replacement, but with type safety now.
- Our custom option resolvers now have first-class builder support. See
addApplicationOption
andaddEmojiOption
. - Tests are no longer packaged with the project. Unlikely this affects anybody, but it's worth mentioning.
Command registration script
This releases adds a script that will handle most basic registration cases. This avoids the need to write your own script to wrap SlashCommandBuilder.registerCommands(...)
. The script can be called from projects using this library as a dependency.
To run this script, use (note the --
to pass args through to the script):
npm exec register -- --help
(breaking) discord.js v14 support
This release updates the existing functionality to work with Discord.js version 14.
This is a breaking change. From this release on, all future updates will be for Discord.js v14.
If you still need v13 support, the 1.x versions of this library still work fine.
Fix raw Emoji ID resolution
Attention: This is the most recent release that supports discord.js v13!
Options.getEmoji(...)
was not properly resolving GuildEmoji
from raw ID strings. It was, instead, returning the raw ID as a string, which newer versions of Discord.js doesn't play nice with. It now returns a GuildEmoji
object when emojis are specified as raw Discord IDs.
Apologies to my TypeScript friends who are probably crying right now.
Fix multi-part emoji parsing
Options.getEmoji(...)
was not properly recognizing multi-part emojis like 1️⃣ and 🕴️. Now it does.
Also update dependencies, so we're now using Discord API v10.
Add ContextMenuCommandBuilder support (and more!)
A couple of nice additions here;
ContextMenuCommandBuilder
builders can now be defined with command handlers.const { ApplicationCommandType, SlashCommandRegistry } = require('discord-command-registry'); new SlashCommandBuilder().addContextMenuCommand(command => command .setName('menu-option') .setType(ApplicationCommandType.Message) .setHandler(interaction => interaction.reply('selected something from the menu!')) )
@discordjs/builders
defined utility methods, such asbold
for dressing up messages. These are all now forwarded through this library, so they can be directly imported.const { bold } = require('discord-command-registry');
- Add new option helper for Emojis. Like
Options.getApplication(...)
, you use this by defining string option, then usingOption.getEmoji(interaction, 'opt_name')
in your handler. - Option resolvers now support an optional third
required
argument to be in line with the ones built into Discord.js. Like the built-in ones, these default to false. Example:Option.getEmoji(interaction, 'opt_name', true)
.
Update dependencies
Update the discord-api-types
and @discordjs/builders
packages