Skip to content

Command Arguments

pumbas600 edited this page Jan 4, 2022 · 19 revisions

Written for HalpBot-Core-1.0.1

In HalpBot, method parameters are automatically assumed to be command arguments except in the following 3 situations:

  1. The parameter type extends GenericEvent (E.g: MessageReceivedEvent). Instead, it'll pass the MessageReceivedEvent that JDA received when the command was called.

  2. The parameter type extends AbstractCommandAdapter (E.g: TokenCommandAdapter). Instead, it'll pass the TokenCommandAdapter that the command is registered to.

  3. The parameter is annotated with @Source. This tells HalpBot that the parameter is meant to be extracted from the MessageReceivedEvent (Just so that you don't have to).

Source Converters

Supported Types

HalpBot comes with built-in parsers that handle the most commonly used types.

Type Notes
Byte/byte
Short/short
Integer/int
Long/long
Float/float
Double/double
Character/char
Boolean/bool true is considered to be any of: true, yes, t, y (Not case-sensitive). Anything else will be false
String By default this only captures a single word
Enums Not case-sensitive
List Returns ArrayList. By default, you need to surround the elements with [...]
Set Returns HashSet. By default, you need to surround the elements with [...]
Arrays By default, you need to surround the elements with [...]
TextChannel A text channel specified by #channel-name. Note: For performance reasons, if you just need the id use a long annotated with @Id(TextChannel.class)
User The user specified by @username. Note: For performance reasons, if you just need the id use a long annotated with @Id(User.class)
Member The member specified by @username. Note: For performance reasons, if you just need the id use a long annotated with @Id(Member.class)
Default Object Parser See this for more information
MessageReceivedEvent Returns the MessageReceivedEvent that invoked the command
AbstractCommandAdapter Returns the AbstractCommandAdapter that the command is registered to

Reflections

Clone this wiki locally