Package revxrsal.commands.jda.core
Class BaseActorJDA
java.lang.Object
revxrsal.commands.jda.core.BaseActorJDA
- All Implemented Interfaces:
CommandActor
,JDAActor
-
Constructor Summary
ConstructorDescriptionBaseActorJDA
(net.dv8tion.jda.api.events.message.MessageReceivedEvent event, CommandHandler handler) -
Method Summary
Modifier and TypeMethodDescriptioncheckInGuild
(ExecutableCommand command) Returns this actor if it is in a guild, otherwise throws aGuildOnlyCommandException
.checkNotInGuild
(ExecutableCommand command) Returns this actor if it is not in a guild, otherwise throws aPrivateMessageOnlyCommandException
.void
Replies to the sender with the specified message, and marks it as an error depending on the platform.@NotNull net.dv8tion.jda.api.entities.MessageChannel
Returns the channel this actor sent the command inReturns the command handler that constructed this actor@NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent
getEvent()
Returns theMessageReceivedEvent
that created this actor@NotNull net.dv8tion.jda.api.entities.Guild
getGuild()
Returns the guild of this actor, or throws aIllegalStateException
if the command was not run in a guild.@NotNull String
getId()
Returns the snowflake ID of this actor as a string.long
Returns the snowflake ID of this actor@NotNull net.dv8tion.jda.api.entities.Member
Returns theMember
of this actor.@NotNull net.dv8tion.jda.api.entities.Message
Returns the message of the actor@NotNull String
getName()
Returns the name of this actor.@NotNull UUID
Returns the unique UID of this subject.@NotNull net.dv8tion.jda.api.entities.User
getUser()
Returns the underlyingUser
of this actorboolean
Returns whether this actor sent a command in a guild or notvoid
Replies to the sender with the specified message.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface revxrsal.commands.command.CommandActor
as, errorLocalized, getLocale, getTranslator, replyLocalized
-
Constructor Details
-
BaseActorJDA
public BaseActorJDA(net.dv8tion.jda.api.events.message.MessageReceivedEvent event, CommandHandler handler)
-
-
Method Details
-
getName
Description copied from interface:CommandActor
Returns the name of this actor. Varies depending on the platform.- Specified by:
getName
in interfaceCommandActor
- Returns:
- The actor name
-
getUniqueId
Description copied from interface:CommandActor
Returns the unique UID of this subject. Varies depending on the platform.Although some platforms explicitly have their underlying senders have UUIDs, some platforms may have to generate this UUID based on other available data.
- Specified by:
getUniqueId
in interfaceCommandActor
- Returns:
- The UUID of this subject.
-
reply
Description copied from interface:CommandActor
Replies to the sender with the specified message.Varies depending on the platform.
- Specified by:
reply
in interfaceCommandActor
- Parameters:
message
- Message to reply with.
-
error
Description copied from interface:CommandActor
Replies to the sender with the specified message, and marks it as an error depending on the platform.Note that, in certain platforms where no "error" mode is available, this may effectively be equivilent to calling
CommandActor.reply(String)
.This method should not throw any exceptions.
- Specified by:
error
in interfaceCommandActor
- Parameters:
message
- Message to reply with
-
getCommandHandler
Description copied from interface:CommandActor
Returns the command handler that constructed this actor- Specified by:
getCommandHandler
in interfaceCommandActor
- Returns:
- The command handler
-
getMember
@NotNull public @NotNull net.dv8tion.jda.api.entities.Member getMember()Description copied from interface:JDAActor
Returns theMember
of this actor. This will throw an exception in case of private messages. Check withJDAActor.isGuildEvent()
. -
checkInGuild
Description copied from interface:JDAActor
Returns this actor if it is in a guild, otherwise throws aGuildOnlyCommandException
.- Specified by:
checkInGuild
in interfaceJDAActor
- Parameters:
command
- Command to check for.- Returns:
- This actor
-
checkNotInGuild
public JDAActor checkNotInGuild(ExecutableCommand command) throws PrivateMessageOnlyCommandException Description copied from interface:JDAActor
Returns this actor if it is not in a guild, otherwise throws aPrivateMessageOnlyCommandException
.- Specified by:
checkNotInGuild
in interfaceJDAActor
- Parameters:
command
- Command to check for.- Returns:
- This actor
- Throws:
PrivateMessageOnlyCommandException
-
getMessage
@NotNull public @NotNull net.dv8tion.jda.api.entities.Message getMessage()Description copied from interface:JDAActor
Returns the message of the actor- Specified by:
getMessage
in interfaceJDAActor
- Returns:
- The actor's sent message
-
getEvent
@NotNull public @NotNull net.dv8tion.jda.api.events.message.MessageReceivedEvent getEvent()Description copied from interface:JDAActor
Returns theMessageReceivedEvent
that created this actor -
getIdLong
public long getIdLong()Description copied from interface:JDAActor
Returns the snowflake ID of this actor -
getId
Description copied from interface:JDAActor
Returns the snowflake ID of this actor as a string. -
getUser
@NotNull public @NotNull net.dv8tion.jda.api.entities.User getUser()Description copied from interface:JDAActor
Returns the underlyingUser
of this actor -
getGuild
@NotNull public @NotNull net.dv8tion.jda.api.entities.Guild getGuild()Description copied from interface:JDAActor
Returns the guild of this actor, or throws aIllegalStateException
if the command was not run in a guild. -
getChannel
@NotNull public @NotNull net.dv8tion.jda.api.entities.MessageChannel getChannel()Description copied from interface:JDAActor
Returns the channel this actor sent the command in- Specified by:
getChannel
in interfaceJDAActor
- Returns:
- The channel
-
isGuildEvent
public boolean isGuildEvent()Description copied from interface:JDAActor
Returns whether this actor sent a command in a guild or not- Specified by:
isGuildEvent
in interfaceJDAActor
- Returns:
- If this command was run in a guild
-