Class Context

    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ArgumentList args()
      Gets the arguments of the command.
      discord4j.core.object.entity.User author()
      Gets the author of the message that created this context.
      discord4j.core.object.entity.channel.MessageChannel channel()
      Gets the channel of the message that created this context.
      Command command()
      Gets the command that created this context.
      discord4j.core.event.domain.message.MessageCreateEvent event()
      Gets the message create event associated to this command.
      FlagSet flags()  
      Locale getLocale()
      Gets the locale used by this translator.
      String prefixUsed()
      Gets the prefix used in the command that created this context.
      reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(String message)
      Sends a message in the same channel the command was sent.
      reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(Consumer<? super discord4j.core.spec.MessageCreateSpec> spec)
      Sends a message in the same channel the command was sent.
      String toString()  
    • Constructor Detail

      • Context

        public Context​(Command command,
                       discord4j.core.event.domain.message.MessageCreateEvent event,
                       List<String> args,
                       FlagSet flags,
                       String prefixUsed,
                       Locale locale,
                       discord4j.core.object.entity.channel.MessageChannel channel)
    • Method Detail

      • command

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

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

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

        public reactor.core.publisher.Mono<discord4j.core.object.entity.Message> reply​(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​(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
      • prefixUsed

        public String prefixUsed()
        Gets the prefix used in the command that created this context.
        Returns:
        the prefix used
      • author

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

        public discord4j.core.object.entity.channel.MessageChannel channel()
        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
      • getLocale

        public Locale getLocale()
        Description copied from interface: Translator
        Gets the locale used by this translator.
        Specified by:
        getLocale in interface Translator
        Returns:
        the locale