Improve help output for commands split over multiple base commands
Fix help last page detection
Fix missing argument on Player Context Resolve
Expose registered root commands
When @ mentioning someone in Discord, if you manually click the user's name then the ID will be in the chat field as "<@!...>". However, one can _also_ mention a user like so "<@...>".
This PR handles both cases.
In a previous PR, some contexts were not changed from **IssuerOnly** to **IssuerAware**. This has been patched.
I've added a context to resolve a Role. It makes use of the next item I added.
The CrossGuild annotation is used to signify whether or not the context is to be interpreted from a guild perspective or a bot perspective (i.e. all guilds). This annotation could probably be better named.
This pull request is an initial attempt at implementing permission for commands for the JDA module.
It includes one added file, **JDACommandPermissionResolver** which implements CommandPermissionResolver.
I created a map to store the Discord permission offsets stored mapped by their kebab-cased name (i.e. "ADMINISTRATOR" becomes "administrator", "MANAGE_SERVER" becomes "manage-server".
The implementation of `hasPermission(JDACommandEvent, String)` is fairly simple:
- Get the issuer's Member object
- Check if it's null; if so, return false.
- Get the permission offset from the aforementioned map
- Check if it's null; if so, return false.
- Return whether or not the member has the permission.
---------------------------------------
This PR allows new commands to use the `@CommandPermission` annotation like so:
```java
@CommandAlias("test|t")
public class Command extends BaseCommand {
@Subcommand("admin|a")
@CommandPermission("manage-server")
public void adminCommand(MessageReceivedEvent event) {
//...
}
}
```
Because Discord does not support coloring messages outside of embeddable fields, it is safe to use a simple message formatter than just returns the message itself.
As I was testing my previous PR, I noticed messages coming through with coloring symbols (e.g. `<c1></c1>`), and each only went up to `c3` maximum. Finally, I figured out these were colors that needed to be handled in each case.
To remove colored messages from Discord, the message formatter is passed three empty strings for each of `c1`, `c2`, and `c3` respectively.
Finally, the default formatter is set inside of `JDACommandManager` but can always be overridden by the user.
The javadocs for Float and Double specify this for the MIN_VALUE:
A constant holding the smallest positive nonzero value of type...
So the true minimum value must be calculated by the negative max value.
* Register default completion
* Remove auto add @ because it is possible to have completion ids without them
Aikar note - Going to make this private in next commit until feature is done
* Use method handles for invocation
* Fix parsing, add more safety and add for named MessageChannels, and format
* Add methodhandle support to BaseCommand