Interface PrivateChannel
- All Superinterfaces:
Channel,Formattable,IDetachableEntity,IMentionable,ISnowflake,MessageChannel
Represents the connection used for direct messaging.
When this channel comes from a user-installed interaction, bots cannot send messages outside their own DMs.
For friend DMs, you can open a private channel directly with the user.
- See Also:
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.entities.channel.Channel
MAX_NAME_LENGTH -
Method Summary
Modifier and TypeMethodDescriptiongetName()The human-readable name of this channel.getUser()TheUserthat thisPrivateChannelcommunicates with.Retrieves theUserthat thisPrivateChannelcommunicates with.Methods inherited from interface net.dv8tion.jda.api.entities.channel.Channel
delete, formatTo, getAsMention, getFlags, getJDA, getTypeMethods inherited from interface net.dv8tion.jda.api.entities.detached.IDetachableEntity
isDetachedMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreatedMethods inherited from interface net.dv8tion.jda.api.entities.channel.middleman.MessageChannel
addReactionById, addReactionById, canTalk, deleteMessageById, deleteMessageById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageAttachmentsById, editMessageById, editMessageById, editMessageById, editMessageById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageComponentsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageEmbedsById, editMessageFormatById, editMessageFormatById, endPollById, endPollById, getHistory, getHistoryAfter, getHistoryAfter, getHistoryAfter, getHistoryAround, getHistoryAround, getHistoryAround, getHistoryBefore, getHistoryBefore, getHistoryBefore, getHistoryFromBeginning, getIterableHistory, getLatestMessageId, getLatestMessageIdLong, pinMessageById, pinMessageById, purgeMessages, purgeMessages, purgeMessagesById, purgeMessagesById, purgeMessagesById, removeReactionById, removeReactionById, retrieveMessageById, retrieveMessageById, retrievePinnedMessages, retrievePollVotersById, retrievePollVotersById, retrieveReactionUsersById, retrieveReactionUsersById, sendFiles, sendFiles, sendMessage, sendMessage, sendMessageComponents, sendMessageComponents, sendMessageEmbeds, sendMessageEmbeds, sendMessageFormat, sendMessagePoll, sendTyping, unpinMessageById, unpinMessageById
-
Method Details
-
getUser
TheUserthat thisPrivateChannelcommunicates with.This user is only null if this channel is currently uncached, and one the following occur:
- A reaction is removed
- A reaction is added
- A message is deleted
- This account sends a message to a user from another shard (not shard 0)
- This account receives an interaction response, happens when using an user-installed interaction
- This channel represents a DM channel between friends, happens when using an user-installed interaction
In order to retrieve a user that is null, useretrieveUser()- Returns:
- Possibly-null
User. - See Also:
-
retrieveUser
Retrieves theUserthat thisPrivateChannelcommunicates with.
This method fetches the channel from the API and retrieves the User from that.- Returns:
- A
RestActionto retrieve theUserthat thisPrivateChannelcommunicates with.
-
getName
The human-readable name of this channel.If getUser returns null, this method will return an empty String. This happens when JDA does not have enough information to populate the channel name.
This will occur only when
getUser()is null, and the reasons are given ingetUser()If the channel name is important,
retrieveUser()should be used, instead.
-