nyxx_commands 6.0.5
nyxx_commands: ^6.0.5 copied to clipboard
A framework for easily creating slash commands and text commands for Discord using the nyxx library.
6.0.5 #
Bug fixes
- Correctly send flags when responding to interactions.
6.0.4 #
Bug fixes
- Add support for Components V2.
6.0.3 #
Bug fixes
- Expose the arguments list of the
executefunction (#154) - Fix crash when no permission overrides are present in a guild (#155)
6.0.2 #
Bug fixes
- Fixed autocompletion in commands in chat groups
6.0.1 #
Bug fixes
- Fixed ephemeral response levels breaking component helpers.
- Fixed
getMultiSelectionnot working. CommandsPlugin.guildis not longer ignored.
6.0.0 #
Breaking changes
- Update nyxx to version 6.0.0.
Bug fixes
- Fixes a type error that could occur when using FallbackConverter's toButton and toMultiselect.
6.0.0-dev.1 #
Breaking changes
- Update nyxx to version 6.0.0. See the changelog at https://pub.dev/packages/nyxx for more details.
5.0.2 #
Bug fixes
- Fix disposing the plugin partway through command execution causing errors.
5.0.1 #
Bug fixes
- Fix component timeouts triggering instantly.
- Fix component wrappers causing null assertions to trigger.
5.0.0 #
Breaking changes
- Removed all deprecated APIs.
- APIs which used to take
Typeobjects now takeRuntimeTypes for the relevant type. - APIs which used to take the
customIdof a component now take aComponentId. - Context types have been reorganized. See the docs for
IContextData,ICommandContextandIInteractiveContextfor more. - Converter & check APIs now take
IContextDataobjects instead ofIContextobjects. - Checks now use named parameters instead of positional ones in their constructors.
IInteractiveContext.respond(formerlyIContext.respond) now takes aResponseLevelobject instead ofprivateandhidden.- The
interactionsfield onCommandsPluginis now nullable to avoid alatemodifier. UseIContextData.interactionsinstead for a non nullable field.
New features
- Contexts are now managed by a
ContextManagerwhich allows users to create their own contexts. - Added support for modal helpers. See
IInteractionInteractiveContext.getModalfor more. - Added new errors:
ConverterFailedException,InteractionTimeoutException,UncaughtCommandsExceptionandUnhandledInteractionException. - Events & listeners are now handled by an
EventManagerandComponentIds. - Prefix callbacks can now be asynchronous and return any
Pattern. - Added
autoAcknowledgeDurationfor more control over auto-acknowledge. - Added parsing utilities on
AutocompleteContextfor parsing arguments. - Contexts in a command are now chained, so interaction expiry and inconsistent formatting of responses to commands are no longer an issue. See
IInteractiveContext.delegatefor more. - Added many helpers for handling message components:
awaitButtonPress,awaitSelectionandawaitMultiSelectionfor using fully custom components with nyxx_commands;getButtonPress,getButtonSelectionandgetConfirmationfor handling buttons;getSelectionandgetMultiSelectionfor handling multiselect menus.
- Added
SimpleConverterto simplify creating custom converters. - The prefix callback can now be set to null to disable message commands. This will change the default command type to
slashOnlyunlessCommandsOptions.inferDefaultCommandTypeis set tofalse. - Added
skipPatterntoStringView, similar toskipString.
Bug fixes
- Fixed a bug that prevented
partfiles from being compiled. - Fixed a bug that prevented enum parameters from being compiled.
- Fixed nested command
fullNames not being correct.
Miscellaneous
- Optimized the compilation script to generate less code and use a more reliable subtype checking method.
- Instructions for compilation can now be found at the package README.
- Bump
nyxxto 5.0.0 andnyxx_interactionsto 4.6.0.
5.0.0-dev.3 #
Bug fixes
- Fixed a bug which caused
IInteractiveContext.respondto error after auto-acknowledge. - Fixed a bug where
getSelectionandgetMultiSelectionwould result in an "Interaction failed" error, despite the response being sent. - Fixed a bug that caused a late initialization error to occur if an error occurred in
respond. - Fixed
getSelectionsending a new message for different pages instead of editing the same message.
5.0.0-dev.2 #
Breaking changes
- The
DartTypeclass introduced in 5.0.0-dev.0 has been replaced withRuntimeTypefrompackage:runtime_type. - All errors thrown by command callbacks are now caught instead of only subclasses of
Exception. The relevant fields onUncaughtExceptionandAutocompleteFailedExceptionhave therefore been changed fromExceptiontoObject. - APIs that took a combination of user, timeout and component id have been changed to use the new
ComponentIdclass.
New features
- Errors will now be added to
CommandsPlugin.onCommandErrorwhen a message component created by nyxx_commands enters an invalid state (e.g no handler found or the user was not allowed to use the component). See the docs forUnhandledInteractionExceptionfor more. - Added
ComponentIdas a way for nyxx_commands to generate an ID for message components that contains information about the component's state in nyxx_commands. - Added a new
InteractionTimeoutExceptionthrown when an interaction times out instead of Dart'sTimeoutException. - Added a
stackTracegetter to allCommandsExceptions.
Bug fixes
- Fixed an issue where enum values in annotations caused the compiler to crash.
Miscellaneous
- Added documentation with instructions on how to compile nyxx_commands to the README.
- Correctly export
ContextManager. - Changed the log message for uncaught exceptions. The message no longer contains the error description, instead passing the error object through the log record's error field. Versions of nyxx after 4.5.0 contain a
Loggingplugin that will display this error for you.
5.0.0-dev.1 #
Breaking changes:
CommandsPluginhas been made more type safe, making theinteractionsfield nullable. To use theIInteractionsinstance from your commands, seeIContextData.interactions.clienthas also been changed to be read-only.
New features:
- A helper for using modals has been added. See
IInteractionInteractiveContext.getModalfor more. getSelectionandgetMultiSelectionfromIInteractiveContextcan now be used without a converter, using thetoMultiSelectparameter.- Failed converters now throw a
ConverterFailedExceptioninstead of aBadInputException. SimpleConverter.providercan now be async.
Bug fixes:
IChatCommandComponent.fullNamenow correctly returns the full command name.- Responding to a component context now correctly clears components on the message.
Miscellaneous:
package:analyzerhas been bumped to 5.0.0.- A few elements that were previously unexported are now correctly exported.
5.0.0-dev.0 #
Breaking changes:
ChatCommand.typehas been moved toCommandOptions. UseChatCommand(options: CommandOptions(type: ...))instead ofChatCommand(type: ...)to set a commands type. With this change, thetextOnlyandslashOnlyconstructors have been removed fromChatCommand.Converters no longer take anIContextas a parameter but now take anICommandContextData.- Some of the arguments in
Checkconstructors have been changed from positional to named arguments. - All deprecated fields have been removed.
IInteractiveContext.respond(previouslyIContext.respond) now takes aResponseLevelinstead of the context-type-specific named parameters. SeeResponseLevelfor more.- All uses of
Types in the package have been replaced withDartTypes. This wrapper class allows for sound type safety and simplifies compilation. Notable places this change has an effect are inCommandsPlugin.getConverterandNoConverterException.type. - The old component wrappers have been replaced with newer, more versatile methods.
New features:
- The
prefixfunction used to determine the prefix for a given text message can now return aPatternand be asynchronous. This allows the use ofRegExps to determine command prefixes. CommandsPlugin.contextManagercan be used to create your own contexts from raw events.SimpleConverteris a newConverterthat simplifies the creation of custom converters. Providing a function to generate items and a function to stringify each item will create a converter with support for basic conversion, autocompletion and more.- The prefix is now nullable in the
CommandsPluginconstructor. Setting it tonullwill make the default command type automatically beslashOnlyifCommandsOptions.inferDefaultCommandTypeistrue. - Commands will now respond to the latest interaction instead of the original interaction if the component wrappers on
IInteractiveContextare used. SeeIInteractiveContext.delegatefor more. CommandOptions.preserveComponentMessagescan be used to choose whether Message Component responses should overwrite the message.CommandOptions.autoAcknowledgeDurationcan be used to manually set the auto-acknowledge timeout.CommandOptions.caseInsensitiveCommandscan be used to allow commands to be invoked case-insensitively.AutocompleteContexthas new methods for parsing values in the autocompletion event.
Bug fixes:
- Returning
nullin an autocomplete handler no longer displays an error in the Discord UI.
4.4.1 #
Bug fixes:
- Fix
partdirectives breaking compilation.
4.4.0 #
Miscellaneous:
- Bump
analyzerto 5.7.1,argsto 2.4.0,dart_styleto 2.2.5,loggingto 1.1.1,metato 1.9.0,nyxxto 4.5.0,nyxx_interactionsto 4.5.0,pathto 1.8.3build_runnerto 2.1.0,coverageto 1.6.3,lintsto 2.0.1,mockitoto 5.3.2, andtestto 1.23.1.
4.3.0 #
New features:
- Added support for command localization. See
localizedNameson allICommands andlocalizedDescriptionsforChatCommands and the@Description()annotation.
Bug fixes:
- Fixes
@Nameannotations not working when running withdart:mirrors. - Fixes the plugin not correctly disposing when the client is disposed.
- Fixed the automatic response sometimes failing.
Miscellaneous:
- Bump
nyxxto 4.0.0 andnyxx_interactionsto 4.3.1.
4.2.0 #
New features:
- Added a script which allows
nyxx_commandsto be compiled. For more information, rundart pub global activate nyxx_commandsandnyxx-compile --help. - Implemented support for permissions V2. See
PermissionsCheckfor more.
Deprecations:
- Deprecated
AbstractCheck.permissionsand all associated features.
4.2.0-dev.1 #
New features:
- Added a script which allows
nyxx_commandsto be compiled. For more information, rundart pub global activate nyxx_commandsandnyxx-compile --help.
4.2.0-dev.0 #
Deprecations:
- Deprecated
AbstractCheck.permissionsand all associated features.
New features:
- Added
AbstractCheck.allowsDmandAbstractCheck.requiredPermissionsfor integrating checks with permissions v2. - Updated
Check.deny,Check.anyandCheck.allto work with permissions v2. - Added
PermissionsCheck, for checking if users have a specific permission.
Miscellaneous:
- Bump
nyxx_interactionsto 4.2.0. - Added proper names to context type checks if none is provided.
4.1.2 #
Bug fixes:
- Fixes an issue where slash commands nested within text-only commands would not be registered
4.1.1 #
Bug fixes:
- Correctly export the
@Autocomplete(...)annotation.
4.1.0 #
New features:
- Support for autocompletion has been added. See
Converter.autocompleteCallbackand the@Autocomplete(...)annotation for more. - Added the ability to allow only slash commands or disable them entirely. See
CommandType.defandCommandOptions.defaultCommandTypefor more. - Added
ChatCommand.argumentTypes, which allows developers to access the argument types for a chat command callback. - Added
Converter.processOptionCallback, which allows developers to modify the builder generated for a command argument. - Added
IntConverter,DoubleConverterandNumConverterfor converting numbers with custom bounds. These new classes allow you to specify a minimum and maximum value for an argument when used with@UseConverter(...). - Added
GUildChannelConverterfor converting more specific types of guild channels.
Bug fixes:
- Fixed an issue with
IContext.getButtonPressnot behaving correctly whenauthorOnlyortimeoutwas specified. - Fixed the default converters for guild channels accepting all channels in the Discord UI even if they were not the correct type.
Miscellaneous:
- Updated the command name validation regex.
- Bump
nyxx_interactionsto 4.1.0.
4.0.0 #
Breaking changes:
nyxx_interactionshas been upgraded to 4.0.0.- The names of command classes have changed. The old class
Commandis now namedChatCommandandGroupis nowChatGroup. - The names of context classes have changed. The old class
Contextis now namedIChatContext,MessageContextisMessageChatContextandInteractionContextis nowInteractionChatContext. - All deprecated members have been removed.
- The
hideOriginalResponseparameter has been removed from theChatCommandconstructor. Use the newoptionsparameter and specifyhideOriginalResponsethere instead.
New features:
- Added support for User and Message Application Commands. See the docs for
UserCommandandMessageCommandfor more information. - Added new in-built checks for validating content types.
- Added helper methods for using
nyxx_interactionswithnyxx_commands. - Added support for the attachment command option type. Use the
IAttachmenttype as your command callback parameter type to use the appropriate converter.
Documentation:
- The documentation for the entire package has been rewritten, with examples, references and more. See the documentation for more details.
Bug fixes:
- Fix a bug concerning optional arguments having their default values wrapped in futures.
4.0.0-dev.2.1 #
Bug fixes:
- Fix a bug concerning types that didn't need to be converted being wrapped in Futures.
4.0.0-dev.2.0 #
Breaking changes:
- Upgrade to
nyxx_interactions4.0.0.
Bug fixes
- Fix
UserCommandCheckalways failing. - Fix parsing multiple arguments at once leading to race conditions.
- Fix a casting error that occurred when a text command was not found.
Documentation:
- The documentation for the entire package has been rewritten, with examples, references and more. See the documentation for more details.
New features:
- Added support for the
attachmentcommand option type. UseIAttachment(fromnyxx_interactions) as the argument type in your commands callback fornyxx_commandsto register it as an attachment command option. - Added
IInteractionContext, an interface implemented by all contexts originating from interactions.
4.0.0-dev.1.2 #
Bug fixes:
- Fixed a bug affecting command syncing with external sharding.
4.0.0-dev.1.1 #
Bug fixes:
- Fixed a bug affecting registration of slash commands nested two layers deep.
4.0.0-dev.1 #
New features:
- Export the command types for better typing. See the documentation for
ICallHooked,IChatCommandComponent,IChecked,ICommand,ICommandGroup,ICommandRegisterableandIOptionsfor more information. - Add new checks for allowing certain checks to be bypassed by certain command types. See the documentation for
ChatCommandCheck,InteractionCommandCheck,InteractionChatCommandCheck,MessageChatCommandCheck,MessageCommandCheckandUserCommandCheckfor more info. - Export
registerDefaultConvertersandparsefor users wanting to implement their own commands plugin.
4.0.0-dev.0 #
Breaking changes:
- The names of command classes have changed. The old class
Commandis now namedChatCommandandGroupis nowChatGroup. - The names of context classes have changed. The old class
Contextis now namedIChatContext,MessageContextisMessageChatContextandInteractionContextis nowInteractionChatContext. - All deprecated members have been removed.
- The
hideOriginalResponseparameter has been removed from theChatCommandconstructor. Use the newoptionsparameter and specifyhideOriginalResponsethere instead.
If you find any more breaking changes please notify us on the official nyxx Discord server, or open an issue on GitHub.
New features:
- Support for User Application Commands has been added. They can be created through the
UserCommandclass similarly toChatCommands, and must be added withCommandsPlugin.addCommand()asChatCommands are. - Support for Message Application Commands has been added. They can be created through the
MessageCommandclass similarly toChatCommands, and must be added withCommandsPlugin.addCommand()asChatCommands are. - Better support for command configuration has been added. Users can now specify options to apply only to specific commands through the
optionsparameter in all command constructors with the newCommandOptionsclass. Similarly to checks, these options are inherited but can be overridden by children. - Added a few simple functions for easier interaction with
nyxx_interactionscovering common use cases for interactions.
Bug fixes:
- Fixed an edge case issue with converters where assembled converters sometimes wouldn't return the correct type
3.3.0 #
New features:
- Added a
remaining()method toCooldownCheckto get the remaining cooldown for a context.
Deprecations:
registerChildhas been deprecated, users should prefer the better namedaddCommandmethod.
3.2.0 #
Bug fixes:
- Exceptions are now correctly caught for commands with async
executefunctions. - Check hooks are now correctly called when using
Check.all,Check.anyorCheck.deny.
New features:
- Added a new
privateoption toContext.respondthat allows users to send private responses to commands. - Added the ability to combine
CooldownTypesusing the binary OR (|) operator. - Added a new
dmOrfunction that can be used inCommandsPlugin.prefixto allow users to omit the bot prefix in DMs.
3.1.1 #
Bug fixes:
- Fixed an issue where
Check.all,Check.anyandCheck.denywould not acceptAbstractChecks as arguments.
3.1.0 #
New features:
- Default choices for
CombineConverters andFallbackConverters can now be specified in thechoicesparameter. - You can now specify the Discord slash command option type to use in
Converter,CombineConverterandFallbackConverters with thetypeparameter. - Added a new
hideOriginalResponseoption toCommandsOptionsthat allows you to hide the automatic acknowledgement of interactions withautoAcknowledgeInteractions. - Added a new
acknowledgemethod toInteractionContextthat allows you to overridehideOriginalResponse. - Added a new
hideOriginalResponseparameter toCommandconstructors that allows you to overrideCommandsOptions.hideOriginalResponseon a per-command basis. - Added a new
hiddenparameter toInteractionContext.respondthat allows you to send an ephemeral response. The hidden state of the response sent is guaranteed to match thehiddenparameter, however to avoid strange behavior it is recommended to acknowledge the interaction withInteractionContext.acknowledgeif the response is delayed. - Added a new
mentionparameter toMessageContext.respondthat allows you to specify whether the reply to the command should mention the user or not. - Added a new
UseConverterdecorator that allows you to override the converter used to parse a specific argument. - Added converters for
doubles andMentionables. - Added a new global
mentionOrfunction that can be used inCommandsPlugin.prefixto allow mention prefixes.
Miscellaneous:
autoAcknowledgeInteractionsno longer immediately acknowledges interactions upon receiving them, allowing ephemeral responses to be correctly sent.- Bumped
nyxx_interactionsto 3.1.0 - Argument parsing is now done in parallel, making commands with multiple arguments faster to invoke.
Deprecations:
- Setting the Discord slash command option type to use for a Dart
Typevia thediscordTypesmap is now deprecated. Use thetypeparameter in converter constructors instead. Context.sendis now deprecated asContext.respondis more appropriate for most cases. IfContext.sendwas really what you wanted, useContext.channel.sendMessageinstead.
3.0.0 #
Breaking changes:
- The base
Botclass has been replaced with aCommandsPluginclass that can be used as a plugin with nyxx3.0.0. nyxxandnyxx_interactionsdependencies have been bumped to3.0.0; versions2.xare now unsupported.BotOptionshas been renamed toCommandsOptionsand no longer supports the options found inClientOptions. Create two separate instances and pass them toNyxxFactory.createNyxx...andCommandsPluginrespectively, in theoptionsnamed parameter.- The
botfield onContexthas been replaced with aclientfield pointing to theINyxxinstance and acommandsfield pointing to theCommandsPlugininstance.
2.0.0 #
Breaking changes:
- Messages sent by bot users will no longer be executed by default, see
BotOptions.acceptBotCommandsandBotOptions.acceptSelfCommands.
New features:
- A new
acceptBotCommandsoption has been added toBotOptionsto allow executing commands from messages sent by other bot users. - A new
acceptSelfCommandsoptions has been added toBotOptionsto allow executing commands from messages sent by the bot itself. onPreCallandonPostCallstreams onCommandsandGroupscan be used to register pre- and post- call hooks.AbstractCheckclass can be extended to implement stateful checks.CooldownCheckcan be used to apply a cooldown to a command based on different criteria.InteractionCheckandMessageCheckcan be used withCheck.any()to allow slash commands or text commands to bypass other checks.Check.all()can be used to group checks.
Bug fixes:
- Invalid cased command/group/argument names are now caught and a
CommandRegistrationErroris thrown. StringView.escape()now correctly escapes fromstarttoendand notstarttoindex.
1.0.0 #
- Version 1 was skipped to keep version consistent with the other nyxx libraries.
0.4.0 #
Breaking changes:
- Exceptions have been reworked and are no longer named the same.
New features:
- Converters can now specify pre-defined choices for their type, this behavior can be overridden on a per-command basis with the
@Choicesdecorator. - Command arguments can now have custom names with the
@Namedecorator.
0.3.0 #
New features:
- Checks now integrate with Discord's slash command permissions.
- Checks can now be asynchronous.
- Added
RoleCheck,UserCheckandGuildCheckthat represent the basic Discord slash command permissions: role restricted, user restricted and guild restricted (guild command). - Slash command arguments can have descriptions set with the
@Descriptiondecorator.
Breaking changes:
- Checks are no longer a simple function.
0.2.0 #
Breaking changes:
- Reorder
descriptionandexecuteparameters inCommand.textOnlyandCommand.slashOnlyconstructors. - Remove
syncDeletedoption fromBotOptionsas nyxx_interactions removes them on sync anyways.
New features:
- Add
send(MessageBuilder)andrespond(MessageBuilder)methods toContext. - Add
childrenas an optional argument toCommandandGroupconstructor. - Add
autoAcknowledgeInteractionsoption toBotOptionsto determine whether to automatically respond to interaction events. - Commands can now restrict execution using checks.
Bugfixes:
InteractionContext.respondwill no longer throw an error when responding immediately.- Slash Commands can no longer have direct slash command children.
- Errors emitted outside of argument parsing and callback execution are now correctly sent to
Bot.onCommandError.
Miscellaneous:
- Text-only and slash-only commands can now have
Contextas their first argument type.
0.1.0 #
- Initial release.