@@ -83,7 +83,8 @@ The following message frameworks are currently supported out of the box:
8383* [ Javacord] ( #javacord )
8484* [ JDA] ( #jda )
8585
86- If you want to have support for an additional, do not hesitate to open a pull request or feature request issue.
86+ If you want to have support for an additional framework, do not hesitate to open a pull request or feature request
87+ issue.
8788
8889
8990
@@ -222,53 +223,51 @@ public class PingCommand implements Command<Message> {
222223With everything else using the default, this is already enough to have a working ping bot.
223224A fully self-contained example can be found at ` examples/simplePingBotJavacord ` .
224225
225- To further customize the behavior of a command you can either annotate the command class or overwrite the according
226- methods in your command implementation to replace the default implementations which evaluate the annotations.
227- Having annotations applied and at the same time overwriting the according methods makes only sense if you want the
228- annotations only for documentary purpose or evaluate them yourself, as the default implementations of those methods
229- are the only places where the annotations are evaluated by default. Every other place like for example command handler
230- call the methods on the command implementation.
226+ To further customize the behavior of a command, you can either annotate the command class or overwrite the
227+ corresponding methods. Annotations are ignored when the corresponding methods are overwritten, but they can still be
228+ separately evaluated or used as documentation. For all functionality this framework uses the command method
229+ implementations. The annotations are only read in the default implementations of those methods.
231230
232231#### Command Aliases
233232
234- By overwriting the ` Command#getAliases() ` method or applying one or multiple [ ` @Alias ` ] [ @Alias JavaDoc ] annotations the
235- aliases to which the command reacts can be configured. If at least one alias is configured, only the explicitly
236- configured ones are available. If no alias is configured, the class name, stripped by ` Command ` or ` Cmd `
237- suffix and / or prefix and the first letter lowercased is used as default .
233+ By overwriting the ` Command#getAliases() ` method or applying one or multiple [ ` @Alias ` ] [ @Alias JavaDoc ] annotations, the
234+ aliases to which the command reacts can be configured. If no aliases are configured, the class name, with the ` Command `
235+ or ` Cmd ` suffix / prefix stripped and the first letter lowercased is used as a default. If at least one alias is
236+ configured, only the explicitly configured ones are used.
238237
239238#### Asynchronous Command Execution
240239
241- By overwriting the ` Command#isAsynchronous() ` method or applying the [ ` @Asynchronous ` ] [ @Asynchronous JavaDoc ] annotation
242- the command handler can be told to execute the command asynchronously.
240+ By overwriting the ` Command#isAsynchronous() ` method or applying the [ ` @Asynchronous ` ] [ @Asynchronous JavaDoc ]
241+ annotation, the command handler can be told to execute the command asynchronously.
243242
244243How exactly this is implemented is up to the command handler that evaluates this command. Usually the command will be
245- execute in some thread pool. But it would also be valid for a command handler to execute each asynchronous command
246- execution in a new thread, so using this can add significant overhead if overused. As long as a command is not doing
247- long-running or blocking operations it might be a good idea to not execute the command asynchronously. But if
248- long-running or blocking operations are done in the command code directly, depending on the underlying message framework
249- it might be a good idea to execute the command asynchronously to not block message dispatching which could introduce
244+ executed in some thread pool. But, it would also be valid for a command handler to execute each asynchronous command
245+ execution in a new thread, so using this can add significant overhead if overused. If a command is not doing
246+ long-running or blocking operations, it may be preferable to not execute the command asynchronously. Although, if
247+ long-running or blocking operations are done in the command code directly, it may be preferable to execute the command
248+ asynchronously, as (depending on the underlying message framework) message dispatching could be blocked, introducing
250249serious lag to the command execution.
251250
252- As the command executions are potentially done on different threads, special care must be taken if the command holds
251+ As the command executions are potentially done on different threads, special care must be taken, if the command holds
253252state, to make sure this state is accessed in a thread-safe manner. This can of course also happen without the command
254253being configured asynchronously if the underlying message framework dispatches message events on different threads.
255254
256255#### Command Description
257256
258- By overwriting the ` Command#getDescription() ` method or applying the [ ` @Description ` ] [ @Description JavaDoc ] annotation
259- the description of the command can be configured. Currently this description is used nowhere , but can for example be
260- displayed in an own help command.
257+ By overwriting the ` Command#getDescription() ` method or applying the [ ` @Description ` ] [ @Description JavaDoc ] annotation,
258+ the description of the command can be configured. This description is not currently used by this framework , but it can
259+ be used, for example, in a custom help command.
261260
262261#### Command Restrictions
263262
264263By overwriting the ` Command#getRestrictionChain() ` method or applying one or multiple
265- [ ` @RestrictedTo ` ] [ @RestrictedTo JavaDoc ] annotations and optionally the
266- [ ` @RestrictionPolicy ` ] [ @RestrictionPolicy JavaDoc ] annotation the restriction rules for a command can be configured. If
264+ [ ` @RestrictedTo ` ] [ @RestrictedTo JavaDoc ] annotations, and optionally the
265+ [ ` @RestrictionPolicy ` ] [ @RestrictionPolicy JavaDoc ] annotation, the restriction rules for a command can be configured. If
267266multiple ` @RestrictedTo ` annotations are present and the default implementation of the method is used, a
268267` @RestrictionPolicy ` annotation that defines how the single restrictions are to be combined is mandatory. With this
269- annotation the single restrictions can be combined in an all-of, any-of, or none-of logic.
268+ annotation the single restrictions can be combined using all-of, any-of, or none-of logic.
270269
271- For more complex boolean logic either overwrite the ` getRestrictionChain ` method or provide own CDI beans that
270+ For more complex boolean logic either overwrite the ` getRestrictionChain ` method or provide custom CDI beans that
272271implement the [ ` Restriction ` ] [ Restriction JavaDoc ] interface and contain the intended logic. For the latter also helpers
273272like [ ` ChannelJavacord ` ] [ ChannelJavacord JavaDoc ] , [ ` RoleJavacord ` ] [ RoleJavacord JavaDoc ] ,
274273[ ` ServerJavacord ` ] [ ServerJavacord JavaDoc ] , [ ` UserJavacord ` ] [ UserJavacord JavaDoc ] , [ ` AllOf ` ] [ AllOf JavaDoc ] ,
@@ -296,8 +295,8 @@ public class MyFancyServer extends ServerJavacord {
296295
297296#### Command Usage
298297
299- By overwriting the ` Command#getUsage() ` method or applying the [ ` @Usage ` ] [ @Usage JavaDoc ] annotation the usage of the
300- command can be configured. This usage can for example be displayed in an own help command.
298+ By overwriting the ` Command#getUsage() ` method or applying the [ ` @Usage ` ] [ @Usage JavaDoc ] annotation, the usage of the
299+ command can be configured. This usage can be used, for example, in a custom help command.
301300
302301When using the [ ` ParameterParser ` ] [ ParameterParser JavaDoc ] , the usage string has to follow a pre-defined format that
303302is described at [ Parsing Parameters] ( #parsing-parameters ) .
@@ -313,7 +312,7 @@ The first is the method `Command.getParameters(...)` which you give the paramete
313312parameters to split into. The provided string will then be split at any arbitrary amount of consecutive whitespace
314313characters. The last element of the returned array will have all remaining text in the parameter string. If you expect
315314exactly three parameters without whitespaces, you should set the max parameters to four, so you can easily test the
316- length of the returned array whether too many parameters were given to the command.
315+ length of the returned array to determine if too many parameters were given to the command.
317316
318317##### Semantic Parsing and Validation
319318
@@ -437,13 +436,13 @@ public class DoCommand implements Command<Message> {
437436#### Customizing Parameter Converters
438437
439438A custom parameter converter can be configured by providing a CDI bean that implements the
440- [ ` ParameterConverter ` ] [ ParameterConverter JavaDoc ] interface. In the implementation of the ` convert ` method the string
441- parameter, parameter type, and command context are given and from this the converted parameter value can be calculated .
439+ [ ` ParameterConverter ` ] [ ParameterConverter JavaDoc ] interface. The implementation of the ` convert ` method
440+ calculates the converted parameter value using the string parameter, parameter type, and command context .
442441The class also needs to be annotated with one or multiple [ ` ParameterType ` ] [ ParameterType JavaDoc ] qualifiers
443442that define the parameter type aliases for which the annotated parameter converter works. Without such
444443qualifier the converter will simply never be used. It is an error to have multiple parameter converters with the
445- same parameter type that can be applied to the same framework message type and this will produce an error latest
446- when a parameter with that type is being converted. The only exception are the built-in parameter types.
444+ same parameter type that can be applied to the same framework message type, and this will produce an error latest
445+ when a parameter with that type is being converted. The only exceptions are the built-in parameter types.
447446A user-supplied converter with the same parameter type as a built-in converter will be preferred,
448447but it would still be an error to have multiple such overrides for the same type.
449448
@@ -461,7 +460,7 @@ public class StringsConverter implements ParameterConverter<Object, List<String>
461460
462461#### Customizing the Command Recognition and Resolution Process
463462
464- The command recognition and resolution process consists of five phases. Actually these phases can vary, as a command
463+ The command recognition and resolution process consists of five phases. Actually, these phases can vary, as a command
465464handler or a command context transformer can fast-forward the process to a later phase to skip unnecessary work, or
466465some phase can fail the process with a command not found event.
467466
@@ -475,23 +474,23 @@ The five phases that are handled are in order:
475474For all but the first and last, there is a before and an after sub phase each during which the command context
476475transformer is called.
477476
478- If at the end of the initialization phase, any before, or any after sub phase the command is set
477+ If at the end of the initialization phase, or any before / after sub phases, the command is set
479478in the context, processing is fast forwarded immediately to the command execution phase and all other
480479inbetween phases and sub phases are skipped.
481480
482- If at the end of the initialization phase, any before, or any after sub phase before the
481+ If at the end of the initialization phase, or any before / after sub phases before the
483482` BEFORE_COMMAND_COMPUTATION ` sub phase, the alias is set in the context, processing is
484483fast forwarded immediately to the before command computation sub phase and all other inbetween
485484phases and sub phases are skipped.
486485
487- If at the end of the initialization phase, any before, or any after sub phase before the
486+ If at the end of the initialization phase, or any before / after sub phases before the
488487` BEFORE_ALIAS_AND_PARAMETER_STRING_COMPUTATION ` sub phase, the prefix is set in the context,
489488processing is fast forwarded immediately to the before alias and parameter string computation
490489sub phase and all other inbetween phases and sub phases are skipped.
491490
492491##### Before Prefix Computation Sub Phase
493492
494- At the start of this sub phase, usually only the message, and message content are set.
493+ At the start of this sub phase, usually only the message and message content are set.
495494
496495##### After Prefix Computation Sub Phase
497496
@@ -538,20 +537,19 @@ a command not found event is being fired and processing stops completely.
538537
539538##### Hooking into a Sub Phase
540539
541- For each of the described sub phases exactly one context transformer that is compatible with the framework message
540+ For each of the described sub phases, exactly one context transformer that is compatible with the framework message
542541can be registered. If you need multiple such transformers, then make one distributing transformer that calls the
543542other transformers in the intended order. You can also register one context transformer for multiple phases.
544543The ` transform ` method gets the current phase as argument and can then decide what to do based on that phase parameter.
545544
546545A command context transformer can be registered by providing a CDI bean that implements the
547546[ ` CommandContextTransformer ` ] [ CommandContextTransformer JavaDoc ] interface. In the implementation of the ` transform `
548- method you can determine from the current command context and the given phase how you like the command context to
549- be and return the adapted command context or even a completely new command context.
547+ method, given the current phase, you can transform the current command context, or even return a completely new one.
550548Additionally the bean has to be annotated with at least one [ ` @InPhase ` ] [ @InPhase JavaDoc ] qualifier annotation, or it
551549will simply not be used silently. The transformer will be called for each sub phase that is added with that annotation.
552550
553- There are also helper classes that can be used as super classes for own command context transformers like for example
554- a provider that returns the mention string for the bot as command prefix if Javacord is used as the underlying
551+ There are also helper classes that can be used as super classes for own command context transformers, for example,
552+ a transformer that returns the mention string for the bot as command prefix if Javacord is used as the underlying
555553message framework.
556554
557555_ ** Warning:** _ The command prefix can technically be configured to be empty, but this means that if the alias and
@@ -624,13 +622,13 @@ public class MyAliasAndParameterStringTransformer implements CommandContextTrans
624622#### Storing Additional Data in the Command Context
625623
626624The ` CommandContext ` is also a store for arbitrary additional information that you can attach to a command invocation.
627- You can for example attach some information during execution of a command context transformer and then later
625+ You can, for example, attach some information during execution of a command context transformer and then later
628626evaluate this information in a custom restriction class or in the implementation of the actual command.
629627
630628The methods regarding additional data all have a generic type argument, as they all return a value, either the current
631629one or the previous one, depending on the method. This value can be cast to the correct type for you, but be careful
632- to select the proper type. As this is an unsafe operation the type has to be chosen wisely. If you for example select
633- ` String ` as type and then try to get a ` User ` object from the returned optional, you will get a ` ClassCastException `
630+ to select the proper type. As this is an unsafe operation, the type has to be chosen wisely. If you, for example, select
631+ ` String ` as the type and then try to get a ` User ` object from the returned optional, you will get a ` ClassCastException `
634632at runtime.
635633
636634The type can be specified explicitly like
0 commit comments