Class Context

java.lang.Object
com.github.alex1304.ultimategdbot.api.command.Context

public class Context
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    Context​(Command command, discord4j.core.event.domain.message.MessageCreateEvent event, java.util.List<java.lang.String> args, FlagSet flags, Bot bot, java.lang.String prefixUsed, discord4j.core.object.entity.MessageChannel channel)  
  • Method Summary

    Modifier and Type Method Description
    ArgumentList getArgs()
    Gets the arguments of the command.
    discord4j.core.object.entity.User getAuthor()
    Gets the author of the message that created this context.
    Bot getBot()
    Gets the bot instance.
    discord4j.core.object.entity.MessageChannel getChannel()
    Gets the channel of the message that created this context.
    Command getCommand()
    Gets the command that created this context.
    discord4j.core.event.domain.message.MessageCreateEvent getEvent()
    Gets the message create event associated to this command.
    FlagSet getFlags()  
    java.lang.String getPrefixUsed()
    Gets the prefix used in the command that created this context.
    reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(java.lang.String message)
    Sends a message in the same channel the command was sent.
    reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(java.util.function.Consumer<? super discord4j.core.spec.MessageCreateSpec> spec)
    Sends a message in the same channel the command was sent.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Context

      public Context​(Command command, discord4j.core.event.domain.message.MessageCreateEvent event, java.util.List<java.lang.String> args, FlagSet flags, Bot bot, java.lang.String prefixUsed, discord4j.core.object.entity.MessageChannel channel)
  • Method Details

    • getCommand

      public Command getCommand()
      Gets the command that created this context.
      Returns:
      the original command
    • getEvent

      public discord4j.core.event.domain.message.MessageCreateEvent getEvent()
      Gets the message create event associated to this command.
      Returns:
      the event
    • getArgs

      public ArgumentList getArgs()
      Gets the arguments of the command.
      Returns:
      the args
    • getFlags

      public FlagSet getFlags()
    • getBot

      public Bot getBot()
      Gets the bot instance.
      Returns:
      the bot
    • reply

      public reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(java.lang.String message)
      Sends a message in the same channel the command was sent.
      Parameters:
      message - the message content of the reply
      Returns:
      a Mono emitting the message sent
    • reply

      public reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(java.util.function.Consumer<? super discord4j.core.spec.MessageCreateSpec> spec)
      Sends a message in the same channel the command was sent. This method supports advanced message construction.
      Parameters:
      spec - the message content of the reply
      Returns:
      a Mono emitting the message sent
    • getPrefixUsed

      public java.lang.String getPrefixUsed()
      Gets the prefix used in the command that created this context.
      Returns:
      the prefix used
    • getAuthor

      public discord4j.core.object.entity.User getAuthor()
      Gets the author of the message that created this context. It is a convenient way to do
       getEvent().getMessage().getAuthor().orElseThrow();
       
      Returns:
      the author
    • getChannel

      public discord4j.core.object.entity.MessageChannel getChannel()
      Gets the channel of the message that created this context. The channel was cached beforehand, so it can return a MessageChannel instance directly as opposed to a Mono of it.
      Returns:
      the author
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object