Class SelfUserImpl

All Implemented Interfaces:
Formattable, IMentionable, ISnowflake, SelfUser, User, UserSnowflake

public class SelfUserImpl extends UserImpl implements SelfUser
  • Constructor Details

    • SelfUserImpl

      public SelfUserImpl(long id, JDAImpl api)
  • Method Details

    • hasPrivateChannel

      public boolean hasPrivateChannel()
      Description copied from interface: User
      Whether or not the currently logged in user and this user have a currently open PrivateChannel or not.
      Specified by:
      hasPrivateChannel in interface User
      Overrides:
      hasPrivateChannel in class UserImpl
      Returns:
      True if the logged in account shares a PrivateChannel with this user.
    • getPrivateChannel

      public PrivateChannel getPrivateChannel()
      Overrides:
      getPrivateChannel in class UserImpl
    • openPrivateChannel

      @Nonnull public CacheRestAction<PrivateChannel> openPrivateChannel()
      Description copied from interface: User
      Opens a PrivateChannel with this User.
      If a channel has already been opened with this user, it is immediately returned in the RestAction's success consumer without contacting the Discord API. You can use useCache(false) to force the request for a new channel object, which is rarely useful since the channel id never changes.

      Examples

      
       // Send message without response handling
       public void sendMessage(User user, String content) {
           user.openPrivateChannel()
               .flatMap(channel -> channel.sendMessage(content))
               .queue();
       }
      
       // Send message and delete 30 seconds later
       public RestAction<Void> sendSecretMessage(User user, String content) {
           return user.openPrivateChannel() // RestAction<PrivateChannel>
                      .flatMap(channel -> channel.sendMessage(content)) // RestAction<Message>
                      .delay(30, TimeUnit.SECONDS) // RestAction<Message> with delayed response
                      .flatMap(Message::delete); // RestAction<Void> (executed 30 seconds after sending)
       }
       
      Specified by:
      openPrivateChannel in interface User
      Overrides:
      openPrivateChannel in class UserImpl
      Returns:
      CacheRestAction - Type: PrivateChannel
      Retrieves the PrivateChannel to use to directly message this User.
      See Also:
    • getApplicationIdLong

      public long getApplicationIdLong()
      Description copied from interface: SelfUser
      The associated application id for the bot account.
      For most bots this is identical to the user id.
      Specified by:
      getApplicationIdLong in interface SelfUser
      Returns:
      The application id
    • isVerified

      public boolean isVerified()
      Description copied from interface: SelfUser
      The status of this account's verification. (Have you accepted the verification email)
      Specified by:
      isVerified in interface SelfUser
      Returns:
      True, if this account is verified.
    • isMfaEnabled

      public boolean isMfaEnabled()
      Description copied from interface: SelfUser
      If true, this account is protected by Multi-Factor authorization.
      If this is a Client account, then this describes the MFA status of the Client account.
      If this is a Bot account, then this describes the MFA status of the Client account that owns this Bot.
      Specified by:
      isMfaEnabled in interface SelfUser
      Returns:
      True, if this account has MFA protecting it.
    • getAllowedFileSize

      public long getAllowedFileSize()
      Description copied from interface: SelfUser
      Returns the maximum size for files that can be uploaded with this account.
      Returns 10485760 for bots.
      Specified by:
      getAllowedFileSize in interface SelfUser
      Returns:
      The maximum size for files that can be uploaded with this account
      See Also:
    • getManager

      @Nonnull public AccountManager getManager()
      Description copied from interface: SelfUser
      The AccountManager for the currently logged in account.
      This can be used to atomically set account fields (like avatar/username) You modify multiple fields in one request by chaining setters before calling RestAction.queue().
      Specified by:
      getManager in interface SelfUser
      Returns:
      An AccountManager instance for the current account
    • setVerified

      public SelfUserImpl setVerified(boolean verified)
    • setMfaEnabled

      public SelfUserImpl setMfaEnabled(boolean enabled)
    • setApplicationId

      public SelfUserImpl setApplicationId(long id)
    • copyOf

      public static SelfUserImpl copyOf(SelfUserImpl other, JDAImpl jda)