Class RestChannel
- java.lang.Object
-
- discord4j.rest.entity.RestChannel
-
public class RestChannel extends Object
Represents a guild or DM channel within Discord.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Void>addGroupDMRecipient(Snowflake userId, discord4j.discordjson.json.GroupAddRecipientRequest request)Mono<Void>addPinnedMessage(Snowflake messageId)Request to pin a message in this channel.Flux<Snowflake>bulkDelete(Publisher<Snowflake> messageIds)Request to bulk delete the supplied message IDs.static RestChannelcreate(RestClient restClient, Snowflake id)Create aRestChannelwith the given parameters.Mono<discord4j.discordjson.json.InviteData>createInvite(discord4j.discordjson.json.InviteCreateRequest request, String reason)Request to create an invite.Mono<discord4j.discordjson.json.MessageData>createMessage(discord4j.discordjson.json.EmbedData embed)Wrapper forcreateMessage(MessageCreateRequest)taking an embed only.Mono<discord4j.discordjson.json.MessageData>createMessage(discord4j.discordjson.json.MessageCreateRequest request)Request to create a message using a givenMessageCreateRequestas body.Mono<discord4j.discordjson.json.MessageData>createMessage(MultipartRequest<discord4j.discordjson.json.MessageCreateRequest> request)Request to create a message using a givenMultipartRequestas body.Mono<discord4j.discordjson.json.MessageData>createMessage(String content)Wrapper forcreateMessage(MessageCreateRequest)taking only message content.Mono<Void>delete(String reason)Request to delete this channel while optionally specifying a reason.Mono<Void>deleteChannelPermission(Snowflake targetId, String reason)Request to delete this permission overwrite while optionally specifying a reason.Mono<Void>deleteGroupDMRecipient(Snowflake userId)Mono<Void>deletePinnedMessage(Snowflake messageId)Request to unpin a message in this channel.Mono<Void>editChannelPermissions(Snowflake targetId, discord4j.discordjson.json.PermissionsEditRequest request, String reason)Request to edit channel permission overwrites for the given member or role while optionally specifying a reason.booleanequals(Object o)Mono<discord4j.discordjson.json.FollowedChannelData>follow(discord4j.discordjson.json.NewsChannelFollowRequest request)Requests to follow this channel.Mono<discord4j.discordjson.json.ChannelData>getData()Retrieve this channel's data upon subscription.SnowflakegetId()Returns the ID of this channel.Flux<discord4j.discordjson.json.InviteData>getInvites()Request to retrieve this channel's invites.Flux<discord4j.discordjson.json.MessageData>getMessagesAfter(Snowflake messageId)Request to retrieve all messages after the specified ID.Flux<discord4j.discordjson.json.MessageData>getMessagesBefore(Snowflake messageId)Request to retrieve all messages before the specified ID.Flux<discord4j.discordjson.json.MessageData>getPinnedMessages()Request to retrieve all the pinned messages for this channel.RestMessagegetRestMessage(Snowflake messageId)Create aRestMessageentity for a given ID under this channel.Flux<discord4j.discordjson.json.WebhookData>getWebhooks()inthashCode()RestMessagemessage(Snowflake messageId)Return aRestMessagebelonging to this channel.Mono<discord4j.discordjson.json.ChannelData>modify(discord4j.discordjson.json.ChannelModifyRequest request, String reason)Request to edit this text channel using a givenChannelModifyRequestas body and optionally, a reason.Mono<Void>type()Request to trigger the typing indicator in this channel.
-
-
-
Method Detail
-
create
public static RestChannel create(RestClient restClient, Snowflake id)
Create aRestChannelwith the given parameters.- Parameters:
restClient- REST API resourcesid- the ID of this channel
-
getId
public Snowflake getId()
Returns the ID of this channel.- Returns:
- The ID of this channel
-
getData
public Mono<discord4j.discordjson.json.ChannelData> getData()
Retrieve this channel's data upon subscription.- Returns:
- a
Monowhere, upon successful completion, emits theChannelDatabelonging to this channel. If an error is received, it is emitted through theMono. - See Also:
- Get Channel
-
message
public RestMessage message(Snowflake messageId)
Return aRestMessagebelonging to this channel. This method does not perform any API request.- Parameters:
messageId- the message ID under this channel- Returns:
- a
RestMessagerepresented by the given parameters.
-
modify
public Mono<discord4j.discordjson.json.ChannelData> modify(discord4j.discordjson.json.ChannelModifyRequest request, @Nullable String reason)
Request to edit this text channel using a givenChannelModifyRequestas body and optionally, a reason.- Parameters:
request- request body used to create a new messagereason- a reason for this action, can benull- Returns:
- a
Monowhere, upon successful completion, emits the editedChannelData. If an error is received, it is emitted through theMono. - See Also:
- Modify Channel
-
delete
public Mono<Void> delete(@Nullable String reason)
Request to delete this channel while optionally specifying a reason.- Parameters:
reason- a reason for this action, can benull- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the channel has been deleted. If an error is received, it is emitted through theMono. - See Also:
- Delete/Close Channel
-
getMessagesBefore
public Flux<discord4j.discordjson.json.MessageData> getMessagesBefore(Snowflake messageId)
Request to retrieve all messages before the specified ID.The returned
Fluxwill emit items in reverse-chronological order (newest to oldest). It is recommended to limit the emitted items by invoking eitherFlux.takeWhile(Predicate)(to retrieve IDs within a specified range) orFlux.take(long)(to retrieve a specific amount of IDs).The following example will get all messages from
messageIdtomyOtherMessageId:getMessagesBefore(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) >= 0)- Parameters:
messageId- The ID of the newest message to retrieve.- Returns:
- A
Fluxthat continually emits allmessagesbefore the specified ID. If an error is received, it is emitted through theFlux. - See Also:
- Get Channel Messages
-
getMessagesAfter
public Flux<discord4j.discordjson.json.MessageData> getMessagesAfter(Snowflake messageId)
Request to retrieve all messages after the specified ID.The returned
Fluxwill emit items in chronological order (oldest to newest). It is recommended to limit the emitted items by invoking eitherFlux.takeWhile(Predicate)(to retrieve IDs within a specified range) orFlux.take(long)(to retrieve a specific amount of IDs).The following example will get all messages from
messageIdtomyOtherMessageId:getMessagesAfter(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) <= 0)- Parameters:
messageId- the ID of the oldest message to retrieve.- Returns:
- a
Fluxthat continually emits allmessagesafter the specified ID. If an error is received, it is emitted through theFlux. - See Also:
- Get Channel Messages
-
getRestMessage
public RestMessage getRestMessage(Snowflake messageId)
Create aRestMessageentity for a given ID under this channel. This method does not perform any network request.- Parameters:
messageId- the message's ID- Returns:
- a
RestMessagefacade for the given message under this channel to perform actions on it
-
createMessage
public Mono<discord4j.discordjson.json.MessageData> createMessage(discord4j.discordjson.json.MessageCreateRequest request)
Request to create a message using a givenMessageCreateRequestas body. If you want to include attachments to your message, seecreateMessage(MultipartRequest).- Parameters:
request- request body used to create a new message- Returns:
- a
Monowhere, upon successful completion, emits the createdMessageData. If an error is received, it is emitted through theMono. - See Also:
- Create Message
-
createMessage
public Mono<discord4j.discordjson.json.MessageData> createMessage(MultipartRequest<discord4j.discordjson.json.MessageCreateRequest> request)
Request to create a message using a givenMultipartRequestas body. AMultipartRequestis a custom object allowing you to add attachments to a message.- Parameters:
request- request body used to create a new message- Returns:
- a
Monowhere, upon successful completion, emits the createdMessageData. If an error is received, it is emitted through theMono. - See Also:
- Create Message
-
createMessage
public Mono<discord4j.discordjson.json.MessageData> createMessage(String content)
Wrapper forcreateMessage(MessageCreateRequest)taking only message content.- Parameters:
content- The content of the message- Returns:
- a
Monowhere, upon successful completion, emits the createdMessageData. If an error is received, it is emitted through theMono.
-
createMessage
public Mono<discord4j.discordjson.json.MessageData> createMessage(discord4j.discordjson.json.EmbedData embed)
Wrapper forcreateMessage(MessageCreateRequest)taking an embed only.- Parameters:
embed- The embed of the message- Returns:
- a
Monowhere, upon successful completion, emits the createdMessageData. If an error is received, it is emitted through theMono.
-
bulkDelete
public Flux<Snowflake> bulkDelete(Publisher<Snowflake> messageIds)
Request to bulk delete the supplied message IDs.- Parameters:
messageIds- aPublisherto supply the message IDs to bulk delete.- Returns:
- a
Fluxthat continually emitsmessage IDsthat were not bulk deleted (typically if the ID was older than 2 weeks). If an error is received, it is emitted through theFlux. - See Also:
- Bulk Delete Messages
-
editChannelPermissions
public Mono<Void> editChannelPermissions(Snowflake targetId, discord4j.discordjson.json.PermissionsEditRequest request, @Nullable String reason)
Request to edit channel permission overwrites for the given member or role while optionally specifying a reason.- Parameters:
targetId- the ID of the member or role to add the overwrite forrequest- the overwrite request to editreason- the reason, if present- Returns:
- a
Monowhere, upon successful completion, emits nothing; If an error is received, it is emitted through theMono - See Also:
- Edit Channel Permissions
-
getInvites
public Flux<discord4j.discordjson.json.InviteData> getInvites()
Request to retrieve this channel's invites.- Returns:
- a
Fluxthat continually emits this channel'sinvites. If an error is received, it is emitted through theFlux. - See Also:
- Get Channel Invites
-
createInvite
public Mono<discord4j.discordjson.json.InviteData> createInvite(discord4j.discordjson.json.InviteCreateRequest request, @Nullable String reason)
Request to create an invite.- Parameters:
request- request body used to create a new invitereason- the reason, if present- Returns:
- a
Monowhere, upon successful completion, emits the createdInviteData. If an error is received, it is emitted through theMono. - See Also:
- Create Channel Invite
-
deleteChannelPermission
public Mono<Void> deleteChannelPermission(Snowflake targetId, @Nullable String reason)
Request to delete this permission overwrite while optionally specifying a reason.- Parameters:
reason- the reason, if present.- Returns:
- a
Monowhere, upon successful completion, emits nothing; indicating the permission overwrite has been deleted. If an error is received, it is emitted through theMono. - See Also:
- Delete Channel Permission
-
follow
public Mono<discord4j.discordjson.json.FollowedChannelData> follow(discord4j.discordjson.json.NewsChannelFollowRequest request)
Requests to follow this channel. Only works if this channel represents a news channel. Following this channel will create a webhook in a chosen target channel where 'MANAGE_WEBHOOKS' permission is granted.- Parameters:
request- the request to follow this channel- Returns:
- A
Monowhere, upon successful completion, emits the data indicating that the channel has been followed. If an error is received, it is emitted through theMono.
-
type
public Mono<Void> type()
Request to trigger the typing indicator in this channel. A single invocation of this method will trigger the indicator for 10 seconds or until the bot sends a message in this channel.- Returns:
- a
Monowhich completes upon successful triggering of the typing indicator in this channel. If an error is received, it is emitted through theMono. - See Also:
- Trigger Typing Indicator
-
getPinnedMessages
public Flux<discord4j.discordjson.json.MessageData> getPinnedMessages()
Request to retrieve all the pinned messages for this channel.- Returns:
- a
Fluxthat continually emits all the pinned messages for this channel. If an error is received, it is emitted through theFlux. - See Also:
- Get Pinned Messages
-
addPinnedMessage
public Mono<Void> addPinnedMessage(Snowflake messageId)
Request to pin a message in this channel.- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the messaged was pinned. If an error is received, it is emitted through theMono.
-
deletePinnedMessage
public Mono<Void> deletePinnedMessage(Snowflake messageId)
Request to unpin a message in this channel.- Returns:
- A
Monowhere, upon successful completion, emits nothing; indicating the message was unpinned. If an error is received, it is emitted through theMono.
-
addGroupDMRecipient
public Mono<Void> addGroupDMRecipient(Snowflake userId, discord4j.discordjson.json.GroupAddRecipientRequest request)
-
getWebhooks
public Flux<discord4j.discordjson.json.WebhookData> getWebhooks()
-
-