Package org.javacord.api.entity.message
Interface MessageAuthor
-
- All Superinterfaces:
DiscordEntity,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 Optional<User>asUser()Gets the author as user.default Optional<CompletableFuture<Webhook>>asWebhook()Gets the author as a webhook.default booleancanAddNewReactionsInTextChannel()Checks if the author is allowed to add new reactions to messages in the channel where the message was sent.default booleancanAddNewReactionsToMessage()Checks if the author is allowed to add new reactions to the message.default booleancanAttachFilesToTextChannel()Checks if the author can attach files in the channel where the message was sent.default booleancanBanUserFromServer(User userToBan)Checks if the author can ban the user from the server where the message was sent.default booleancanBanUsersFromServer()Checks if the author can ban users from the server where the message was sent.default booleancanChangeOwnNicknameOnServer()Checks if the author can change its own nickname in the server where the message was sent.default booleancanConnectToVoiceChannel()Checks if the author can connect to the voice channel where the message was sent.default booleancanCreateChannelsOnServer()Checks if the author can create new channels on the server where the message was sent.default booleancanCreateInstantInviteToTextChannel()Checks if the author can create an instant invite to the channel where the message was sent.default booleancanDeafenMembersOnServer()Checks if the author can deafen members on the server where the message was sent.default booleancanDeleteMessage()Checks if the author can delete the message.default booleancanEmbedLinksInTextChannel()Checks if the author can use embed links in the channel where the message was sent.default booleancanKickUserFromServer(User userToKick)Checks if the author can kick the user from the server where the message was sent.default booleancanKickUsersFromServer()Checks if the author can kick users from the server where the message was sent.default booleancanManageEmojisOnServer()Checks if the author can manage emojis on the server where the message was sent.default booleancanManageMessagesInTextChannel()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 booleancanManageNicknamesOnServer()Checks if the author can manage nicknames on the server where the message was sent.default booleancanManageRolesOnServer()Checks if the author can manage roles on the server where the message was sent.default booleancanManageServer()Checks if the author can manage the server where the message was sent.default booleancanMentionEveryoneInTextChannel()Checks if the author can mention everyone (@everyone) in the channel where the message was sent.default booleancanMoveMembersOnServer()Checks if the author can move members on the server where the message was sent.default booleancanMuteMembersOnServer()Checks if the author can mute members on the server where the message was sent.default booleancanMuteUsersInVoiceChannel()Checks if the author can mute other users in the voice channel where the message was sent.default booleancanReadMessageHistoryOfTextChannel()Checks if the author can read the message history of the channel where the message was sent.default booleancanRemoveReactionsOfOthersInTextChannel()Checks if the author can remove reactions of other users in the channel where the message was sent.default booleancanSeeAllChannelsInCategory()Checks if the author can see all channels in the category of the channel where the message was sent.default booleancanSeeChannel()Checks if the author can see the channel where the message was sent.default booleancanUseExternalEmojisInTextChannel()Checks if the author can use external emojis in the channel where the message was sent.default booleancanUseTtsInTextChannel()Checks if the author can use tts (text to speech) in the channel where the message was sent.default booleancanViewAuditLogOfServer()Checks if the author can view the audit log of the server where the message was sent.default booleancanWriteInTextChannel()Checks if the author can send messages in the channel where the message was sent.IcongetAvatar()Gets the avatar of the author.default Optional<ServerVoiceChannel>getConnectedVoiceChannel()Gets the voice channel this MessageAuthor (if it is an User) is connected to on the server where the message has been sent.default StringgetDiscriminatedName()If the author is a user, gets the discriminated name of the user, e.Optional<String>getDiscriminator()Gets the discriminator of the author if the author is a user.default StringgetDisplayName()Gets the display name of the author.MessagegetMessage()Gets the message.default Optional<Color>getRoleColor()Gets the displayed color if the author was a User on a Server.default booleanisBotOwner()Checks if the author is the owner of the current account.default booleanisBotUser()Checks if the author is a bot user.default booleanisRegularUser()Checks if the author is a regular user.default booleanisServerAdmin()Checks if the author is an administrator of the server where the message was sent.booleanisUser()Checks if the author of the message is a user.booleanisWebhook()Checks if the author is a webhook.default booleanisYourself()Gets if this author is the user of the connected account.-
Methods inherited from interface org.javacord.api.entity.DiscordEntity
getApi, getCreationTimestamp, getCreationTimestamp, getId, getIdAsString
-
-
-
-
Method Detail
-
getMessage
Message getMessage()
Gets the message.- Returns:
- The message.
-
getDisplayName
default String getDisplayName()
Gets the display name of the author.- Returns:
- The display name of the author.
-
getDiscriminatedName
default 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
Optional<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.
-
getConnectedVoiceChannel
default Optional<ServerVoiceChannel> getConnectedVoiceChannel()
Gets the voice channel this MessageAuthor (if it is an 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()andisBotUser()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. Always returnsfalseif logged in to a user account.- Returns:
- Whether the author is the owner of the current 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 methods also considers the position of the user roles. Always returnsfalseif 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 returnsfalseif 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 methods also considers the position of the user roles. Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif 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 returnsfalseif the author is not a user. Always returnstrueif 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 returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif 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 returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the author is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Please notice, this does not check if a user has blocked private messages! Always returnsfalseif 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 returnsfalseif 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 returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif 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 chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif the author is not a user.- Returns:
- Whether the given user can mention everyone (@everyone) or not.
-
canConnectToVoiceChannel
default boolean canConnectToVoiceChannel()
Checks if the author can connect to the voice channel where the message was sent. In private chats (private channel or group channel) this always returnstrueif the user is part of the chat. Always returnsfalseif the author is not a user or if the channel is not a voice channel.- Returns:
- Whether the author can connect to the voice channel or not.
-
canMuteUsersInVoiceChannel
default boolean canMuteUsersInVoiceChannel()
Checks if the author can mute other users in the voice channel where the message was sent. In private chats (private channel or group channel) this always returns @{code false}. Always returnsfalseif the author is not a user or if the channel is not a voice channel.- Returns:
- Whether the author can mute other users in the voice channel or not.
-
canAddNewReactionsToMessage
default boolean canAddNewReactionsToMessage()
Checks if the author is allowed to add new reactions to the message. Always returnsfalseif 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 returnsfalseif the author is not a user.- Returns:
- Whether the author can delete the message or not.
-
getRoleColor
default Optional<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 returnsfalseif 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.
-
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 Optional<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()
-
-