-
Notifications
You must be signed in to change notification settings - Fork 1
Pre‐defined Context Resolvers
ACF Javacord comes with some pre-defined command context resolvers for generic Javacord. The objects listed below are supported for both types of commands, while message commands have additional pre-defined context resolvers. To see these, see Message Command Context Resolvers.
-
DiscordApi(Issuer-only) -
Message(Issuer-only) -
Server(Issuer-only) - Users
UserMember
- Channels
ChannelTypeServerChannelServerTextChannelServerVoiceChannelServerForumChannelServerThreadChannelChannelCategory
- Emojis
EmojiUnicodeEmojiCustomEmojiKnownCustomEmoji
ACF Javacord comes with a Member object, which represents a User within a server's context. It contains all server-specific information and methods of a User, and can be used as a command parameter:
@Default
public void onCommand(JavacordCommandEvent event, Member member) {
// This displays either the user's nickname within the server of the context, or the username
// of the user who invoked the command.
event.reply(member.getDisplayName());
}When a Member parameter is flagged with @Flags("other"), the user invoking the command must provide a member while entering it.
@Default
public void onCommand(JavacordCommandEvent event, @Flags("other") Member member) {
// This displays the display name of the given member.
event.reply(member.getDisplayName());
}When it is annotated with @BotUser, the Member object of the bot will be provided.
@Default
public void onCommand(JavacordCommandEvent event, @BotUser Member member) {
// This displays the display name of the bot.
event.reply(member.getDisplayName());
}ACF Javacord also comes with a UnicodeEmoji object, which allows for creating Emoji objects out of Unicode emojis, and can also be used as a command parameter:
@CommandAlias("unicodetest")
public class UnicodetestCommand extends BaseCommand {
@Default
public void onCommand(JavacordCommandEvent event, UnicodeEmoji emoji) {
// This will reply with the emoji itself.
// E.g. "e!unicodetest :smile:" or "e!unicodetest \uD83D\uDE04" or "e!unicodetest 😄" would all result in the same emoji being used in the reply.
event.reply(emoji.getMentionTag());
}
}