Package com.mrivanplays.jdcf
Class CommandExecutionContext
- java.lang.Object
-
- com.mrivanplays.jdcf.CommandExecutionContext
-
public final class CommandExecutionContext extends java.lang.Object
Represents a generic data about theCommand
executed.
-
-
Constructor Summary
Constructors Constructor Description CommandExecutionContext(@NotNull net.dv8tion.jda.api.entities.Message message, @NotNull java.lang.String alias, boolean fromDispatcher, @NotNull CommandData commandData, @NotNull CommandManager creator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull java.lang.String
getAlias()
Returns the alias which triggered command execution.@NotNull net.dv8tion.jda.api.entities.User
getAuthor()
Returns the discordUser
as a whole, author of the command.@NotNull net.dv8tion.jda.api.entities.MessageChannel
getChannel()
Returns theMessageChannel
where the command was executed.@NotNull CommandData
getCommandData()
Returns the data of the command execution triggered.@NotNull CommandManager
getCommandManagerCreator()
Returns theCommandManager
, whom have initialized this command execution context.@Nullable net.dv8tion.jda.api.entities.Guild
getGuild()
Returns theGuild
where thegetMember()
have executed the command if it was executed in a guild.@NotNull net.dv8tion.jda.api.JDA
getJda()
Returns the shard from where the command was executed.@Nullable net.dv8tion.jda.api.entities.Member
getMember()
Returns the guildMember
, author of the command if the command was executed in guild.@NotNull net.dv8tion.jda.api.entities.Message
getMessage()
Returns the whole commandMessage
.@Nullable net.dv8tion.jda.api.entities.PrivateChannel
getPrivateChannel()
Returns thePrivateChannel
if the command was executed in the specifiedauthor
's DMs.@Nullable net.dv8tion.jda.api.entities.TextChannel
getTextChannel()
Returns theTextChannel
if the command was executed in a guild.boolean
isFromDispatcher()
Returns whenever this context was made from a dispatcherboolean
wasExecutedInGuild()
Returns whenever the command was executed in a guild.
-
-
-
Constructor Detail
-
CommandExecutionContext
public CommandExecutionContext(@NotNull @NotNull net.dv8tion.jda.api.entities.Message message, @NotNull @NotNull java.lang.String alias, boolean fromDispatcher, @NotNull @NotNull CommandData commandData, @NotNull @NotNull CommandManager creator)
-
-
Method Detail
-
getChannel
@NotNull public @NotNull net.dv8tion.jda.api.entities.MessageChannel getChannel()
Returns theMessageChannel
where the command was executed.- Returns:
- channel
-
wasExecutedInGuild
public boolean wasExecutedInGuild()
Returns whenever the command was executed in a guild.- Returns:
true
if executed in guild channel,false
otherwise
-
getTextChannel
@Nullable public @Nullable net.dv8tion.jda.api.entities.TextChannel getTextChannel()
Returns theTextChannel
if the command was executed in a guild.- Returns:
- channel or null
-
getPrivateChannel
@Nullable public @Nullable net.dv8tion.jda.api.entities.PrivateChannel getPrivateChannel()
Returns thePrivateChannel
if the command was executed in the specifiedauthor
's DMs.- Returns:
- channel or null
-
getMember
@Nullable public @Nullable net.dv8tion.jda.api.entities.Member getMember()
Returns the guildMember
, author of the command if the command was executed in guild.Keep in mind this is not the same as
getAuthor()
- Returns:
- member
-
getAuthor
@NotNull public @NotNull net.dv8tion.jda.api.entities.User getAuthor()
Returns the discordUser
as a whole, author of the command.Keep in mind this is not the same as
getMember()
- Returns:
- discord user, author
-
getJda
@NotNull public @NotNull net.dv8tion.jda.api.JDA getJda()
Returns the shard from where the command was executed.- Returns:
- shard
-
getMessage
@NotNull public @NotNull net.dv8tion.jda.api.entities.Message getMessage()
Returns the whole commandMessage
. It is discouraged to be used for retrieving the text.- Returns:
- message
-
getGuild
@Nullable public @Nullable net.dv8tion.jda.api.entities.Guild getGuild()
Returns theGuild
where thegetMember()
have executed the command if it was executed in a guild.- Returns:
- guild
-
getAlias
@NotNull public @NotNull java.lang.String getAlias()
Returns the alias which triggered command execution.- Returns:
- alias
-
getCommandData
@NotNull public @NotNull CommandData getCommandData()
Returns the data of the command execution triggered.- Returns:
- command data
-
getCommandManagerCreator
@NotNull public @NotNull CommandManager getCommandManagerCreator()
Returns theCommandManager
, whom have initialized this command execution context.- Returns:
- command manager initializer
-
isFromDispatcher
public boolean isFromDispatcher()
Returns whenever this context was made from a dispatcher- Returns:
true
if the command wasn't dispatched the normal way,false
otherwise
-
-