Interface MessageAuthor

  • All Superinterfaces:
    DiscordEntity, java.util.Formattable, Nameable

    public interface MessageAuthor
    extends DiscordEntity, Nameable
    This class represents either a user or a webhook.

    Do not confuse a webhook with a bot account which is also considered to be a user.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.util.Optional<User> asUser()
      Gets the author as user.
      default java.util.Optional<java.util.concurrent.CompletableFuture<Webhook>> asWebhook()
      Gets the author as a webhook.
      default boolean canAddNewReactionsInTextChannel()
      Checks if the author is allowed to add new reactions to messages in the channel where the message was sent.
      default boolean canAddNewReactionsToMessage()
      Checks if the author is allowed to add new reactions to the message.
      default boolean canAttachFilesToTextChannel()
      Checks if the author can attach files in the channel where the message was sent.
      default boolean canBanUserFromServer​(User userToBan)
      Checks if the author can ban the user from the server where the message was sent.
      default boolean canBanUsersFromServer()
      Checks if the author can ban users from the server where the message was sent.
      default boolean canChangeOwnNicknameOnServer()
      Checks if the author can change its own nickname in the server where the message was sent.
      default boolean canCreateChannelsOnServer()
      Checks if the author can create new channels on the server where the message was sent.
      default boolean canCreateInstantInviteToTextChannel()
      Checks if the author can create an instant invite to the channel where the message was sent.
      default boolean canDeafenMembersOnServer()
      Checks if the author can deafen members on the server where the message was sent.
      default boolean canDeleteMessage()
      Checks if the author can delete the message.
      default boolean canEmbedLinksInTextChannel()
      Checks if the author can use embed links in the channel where the message was sent.
      default boolean canKickUserFromServer​(User userToKick)
      Checks if the author can kick the user from the server where the message was sent.
      default boolean canKickUsersFromServer()
      Checks if the author can kick users from the server where the message was sent.
      default boolean canManageEmojisOnServer()
      Checks if the author can manage emojis on the server where the message was sent.
      default boolean canManageMessagesInTextChannel()
      Checks if the author can manage messages (delete or pin them or remove reactions of others) in the channel where the message was sent.
      default boolean canManageNicknamesOnServer()
      Checks if the author can manage nicknames on the server where the message was sent.
      default boolean canManageRolesOnServer()
      Checks if the author can manage roles on the server where the message was sent.
      default boolean canManageServer()
      Checks if the author can manage the server where the message was sent.
      default boolean canMentionEveryoneInTextChannel()
      Checks if the author can mention everyone (@everyone) in the channel where the message was sent.
      default boolean canMoveMembersOnServer()
      Checks if the author can move members on the server where the message was sent.
      default boolean canMuteMembersOnServer()
      Checks if the author can mute members on the server where the message was sent.
      default boolean canReadMessageHistoryOfTextChannel()
      Checks if the author can read the message history of the channel where the message was sent.
      default boolean canRemoveReactionsOfOthersInTextChannel()
      Checks if the author can remove reactions of other users in the channel where the message was sent.
      default boolean canSeeAllChannelsInCategory()
      Checks if the author can see all channels in the category of the channel where the message was sent.
      default boolean canSeeChannel()
      Checks if the author can see the channel where the message was sent.
      default boolean canUseExternalEmojisInTextChannel()
      Checks if the author can use external emojis in the channel where the message was sent.
      default boolean canUseTtsInTextChannel()
      Checks if the author can use tts (text to speech) in the channel where the message was sent.
      default boolean canViewAuditLogOfServer()
      Checks if the author can view the audit log of the server where the message was sent.
      default boolean canWriteInTextChannel()
      Checks if the author can send messages in the channel where the message was sent.
      Icon getAvatar()
      Gets the avatar of the author.
      Icon getAvatar​(int size)
      Gets the avatar of the user.
      default java.util.Optional<ServerVoiceChannel> getConnectedVoiceChannel()
      Gets the voice channel this MessageAuthor (if it is a User) is connected to on the server where the message has been sent.
      default java.lang.String getDiscriminatedName()
      If the author is a user, gets the discriminated name of the user, e.g.
      java.util.Optional<java.lang.String> getDiscriminator()
      Gets the discriminator of the author if the author is a user.
      default java.lang.String getDisplayName()
      Gets the display name of the author.
      Message getMessage()
      Gets the message.
      default java.util.Optional<java.awt.Color> getRoleColor()
      Gets the displayed color if the author was a User on a Server.
      java.util.Optional<java.lang.Long> getWebhookId()
      Gets the webhook id of this author if the message was sent by a webhook.
      default boolean isBotOwner()
      Checks if the author is the owner of the current account.
      default boolean isBotUser()
      Checks if the author is a bot user.
      default boolean isRegularUser()
      Checks if the author is a regular user.
      default boolean isServerAdmin()
      Checks if the author is an administrator of the server where the message was sent.
      default boolean isTeamMember()
      Checks if the author is a member of the team owning the bot account.
      boolean isUser()
      Checks if the author of the message is a user.
      boolean isWebhook()
      Checks if the author is a webhook.
      default boolean isYourself()
      Gets if this author is the user of the connected account.
    • Method Detail

      • getWebhookId

        java.util.Optional<java.lang.Long> getWebhookId()
        Gets the webhook id of this author if the message was sent by a webhook.
        Returns:
        The webhook id of this author if the message was sent by a webhook.
      • getMessage

        Message getMessage()
        Gets the message.
        Returns:
        The message.
      • getDisplayName

        default java.lang.String getDisplayName()
        Gets the display name of the author.
        Returns:
        The display name of the author.
      • getDiscriminatedName

        default java.lang.String getDiscriminatedName()
        If the author is a user, gets the discriminated name of the user, e.g. Bastian#8222, otherwise just gets the name of the author.
        Returns:
        The discriminated name of the user or the name of the author.
      • getDiscriminator

        java.util.Optional<java.lang.String> getDiscriminator()
        Gets the discriminator of the author if the author is a user.
        Returns:
        The discriminator of the author if the author is a user.
      • getAvatar

        Icon getAvatar()
        Gets the avatar of the author.
        Returns:
        The avatar of the author.
      • getAvatar

        Icon getAvatar​(int size)
        Gets the avatar of the user.
        Parameters:
        size - The size of the image, must be any power of 2 between 16 and 4096.
        Returns:
        The avatar of the user.
      • getConnectedVoiceChannel

        default java.util.Optional<ServerVoiceChannel> getConnectedVoiceChannel()
        Gets the voice channel this MessageAuthor (if it is a User) is connected to on the server where the message has been sent.
        Returns:
        The server voice channel the MessageAuthor is connected to.
      • isUser

        boolean isUser()
        Checks if the author of the message is a user.

        A user might be a human user using any number of Discord client applications or a bot user connecting via Discord's bot api. See isRegularUser() and isBotUser() for further detail.

        The opposite of this method is isWebhook().

        Returns:
        Whether the author is a user or not.
      • isBotOwner

        default boolean isBotOwner()
        Checks if the author is the owner of the current account.

        Will return false if the account is owned by a team.

        Returns:
        Whether the author is the owner of the current account.
      • isTeamMember

        default boolean isTeamMember()
        Checks if the author is a member of the team owning the bot account.
        Returns:
        Whether the author is a member of the team owning the bot account.
      • isBotUser

        default boolean isBotUser()
        Checks if the author is a bot user.

        Keep in mind, that if this returns false, it does not mean that the message was sent by a regular user. It's still possible that the message was sent via a webhook.

        Returns:
        Whether the author is a bot user.
      • isRegularUser

        default boolean isRegularUser()
        Checks if the author is a regular user.

        Keep in mind, that if this returns false, it does not mean that the message was sent by a bot user. It's still possible that the message was sent via a webhook.

        Returns:
        Whether the author is a regular user.
      • canCreateChannelsOnServer

        default boolean canCreateChannelsOnServer()
        Checks if the author can create new channels on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can create channels on the server or not.
      • canViewAuditLogOfServer

        default boolean canViewAuditLogOfServer()
        Checks if the author can view the audit log of the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can view the audit log of the server or not.
      • canChangeOwnNicknameOnServer

        default boolean canChangeOwnNicknameOnServer()
        Checks if the author can change its own nickname in the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can change its own nickname in the server or not.
      • canManageNicknamesOnServer

        default boolean canManageNicknamesOnServer()
        Checks if the author can manage nicknames on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can manage nicknames on the server or not.
      • canMuteMembersOnServer

        default boolean canMuteMembersOnServer()
        Checks if the author can mute members on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can mute members on the server or not.
      • canDeafenMembersOnServer

        default boolean canDeafenMembersOnServer()
        Checks if the author can deafen members on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can deafen members on the server or not.
      • canMoveMembersOnServer

        default boolean canMoveMembersOnServer()
        Checks if the author can move members on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can move members on the server or not.
      • canManageEmojisOnServer

        default boolean canManageEmojisOnServer()
        Checks if the author can manage emojis on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can manage emojis on the server or not.
      • canManageRolesOnServer

        default boolean canManageRolesOnServer()
        Checks if the author can manage roles on the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can manage roles on the server or not.
      • canManageServer

        default boolean canManageServer()
        Checks if the author can manage the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can manage the server or not.
      • canKickUsersFromServer

        default boolean canKickUsersFromServer()
        Checks if the author can kick users from the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can kick users from the server or not.
      • canKickUserFromServer

        default boolean canKickUserFromServer​(User userToKick)
        Checks if the author can kick the user from the server where the message was sent. This method also considers the position of the user roles. Always returns false if the author is not a user or the message was not sent on a server.
        Parameters:
        userToKick - The user which should be kicked.
        Returns:
        Whether the author can kick the user from the server or not.
      • canBanUsersFromServer

        default boolean canBanUsersFromServer()
        Checks if the author can ban users from the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can ban users from the server or not.
      • canBanUserFromServer

        default boolean canBanUserFromServer​(User userToBan)
        Checks if the author can ban the user from the server where the message was sent. This method also considers the position of the user roles. Always returns false if the author is not a user or the message was not sent on a server.
        Parameters:
        userToBan - The user which should be banned.
        Returns:
        Whether the author can ban the user from the server or not.
      • canSeeChannel

        default boolean canSeeChannel()
        Checks if the author can see the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can see the channel or not.
      • canSeeAllChannelsInCategory

        default boolean canSeeAllChannelsInCategory()
        Checks if the author can see all channels in the category of the channel where the message was sent. Always returns false if the author is not a user. Always returns true if the channel is not categorizable or has no category.
        Returns:
        Whether the user can see all channels in this category or not.
      • canCreateInstantInviteToTextChannel

        default boolean canCreateInstantInviteToTextChannel()
        Checks if the author can create an instant invite to the channel where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author can create an instant invite to the channel or not.
      • canWriteInTextChannel

        default boolean canWriteInTextChannel()
        Checks if the author can send messages in the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returns false if the author is not a user.
        Returns:
        Whether the author can write messages in the channel or not.
      • canUseExternalEmojisInTextChannel

        default boolean canUseExternalEmojisInTextChannel()
        Checks if the author can use external emojis in the channel where the message was sent. In private channels this always returns true if the author is part of the chat. Please notice, this does not check if a user has blocked private messages! It also doesn't check if the user is even able to send any external emojis (twitch subscription or nitro). Always returns false if the author is not a user.
        Returns:
        Whether the author can use external emojis in the channel or not.
      • canEmbedLinksInTextChannel

        default boolean canEmbedLinksInTextChannel()
        Checks if the author can use embed links in the channel where the message was sent. In private channels this always returns true if the author is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returns false if the author is not a user.
        Returns:
        Whether the author can embed links in the channel or not.
      • canReadMessageHistoryOfTextChannel

        default boolean canReadMessageHistoryOfTextChannel()
        Checks if the author can read the message history of the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Always returns false if the author is not a user.
        Returns:
        Whether the author can read the message history of the channel or not.
      • canUseTtsInTextChannel

        default boolean canUseTtsInTextChannel()
        Checks if the author can use tts (text to speech) in the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returns false if the author is not a user.
        Returns:
        Whether the author can use tts in the channel or not.
      • canAttachFilesToTextChannel

        default boolean canAttachFilesToTextChannel()
        Checks if the author can attach files in the channel where the message was sent. Always returns false if the author is not a user.
        Returns:
        Whether the author can attach files in the channel or not.
      • canAddNewReactionsInTextChannel

        default boolean canAddNewReactionsInTextChannel()
        Checks if the author is allowed to add new reactions to messages in the channel where the message was sent. Always returns false if the author is not a user.
        Returns:
        Whether the author is allowed to add new reactions to messages in the channel or not.
      • canManageMessagesInTextChannel

        default boolean canManageMessagesInTextChannel()
        Checks if the author can manage messages (delete or pin them or remove reactions of others) in the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Always returns false if the author is not a user.
        Returns:
        Whether the author can manage messages in the channel or not.
      • canRemoveReactionsOfOthersInTextChannel

        default boolean canRemoveReactionsOfOthersInTextChannel()
        Checks if the author can remove reactions of other users in the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Always returns false if the author is not a user.
        Returns:
        Whether the author can remove reactions of others in the channel or not.
      • canMentionEveryoneInTextChannel

        default boolean canMentionEveryoneInTextChannel()
        Checks if the author can mention everyone (@everyone) in the channel where the message was sent. In private channels this always returns true if the user is part of the chat. Always returns false if the author is not a user.
        Returns:
        Whether the given user can mention everyone (@everyone) or not.
      • canAddNewReactionsToMessage

        default boolean canAddNewReactionsToMessage()
        Checks if the author is allowed to add new reactions to the message. Always returns false if the author is not a user.
        Returns:
        Whether the author is allowed to add new reactions to the message or not.
      • canDeleteMessage

        default boolean canDeleteMessage()
        Checks if the author can delete the message. Always returns false if the author is not a user.
        Returns:
        Whether the author can delete the message or not.
      • getRoleColor

        default java.util.Optional<java.awt.Color> getRoleColor()
        Gets the displayed color if the author was a User on a Server.
        Returns:
        The display color, if applicable.
      • isServerAdmin

        default boolean isServerAdmin()
        Checks if the author is an administrator of the server where the message was sent. Always returns false if the author is not a user or the message was not sent on a server.
        Returns:
        Whether the author is an administrator of the server or not.
      • asUser

        java.util.Optional<User> asUser()
        Gets the author as user.
        Returns:
        The author as user.
      • isWebhook

        boolean isWebhook()
        Checks if the author is a webhook.

        The opposite of this method is isUser().

        Returns:
        Whether the author is a webhook or not.
      • asWebhook

        default java.util.Optional<java.util.concurrent.CompletableFuture<Webhook>> asWebhook()
        Gets the author as a webhook.
        Returns:
        The author as a webhook.
      • isYourself

        default boolean isYourself()
        Gets if this author is the user of the connected account.
        Returns:
        Whether this author is the user of the connected account or not.
        See Also:
        DiscordApi.getYourself()