Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* This file is part of Discord4J.
*
* Discord4J is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Discord4J is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Discord4J. If not, see .
*/
package discord4j.rest.entity;
import discord4j.discordjson.json.*;
import discord4j.rest.RestClient;
import discord4j.rest.util.MultipartRequest;
import discord4j.rest.util.PaginationUtil;
import discord4j.rest.util.Snowflake;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.annotation.Nullable;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* Represents a guild or DM channel within Discord.
*/
public class RestChannel {
private final RestClient restClient;
private final long id;
private RestChannel(RestClient restClient, long id) {
this.restClient = restClient;
this.id = id;
}
/**
* Create a {@link RestChannel} with the given parameters.
*
* @param restClient REST API resources
* @param id the ID of this channel
*/
public static RestChannel create(RestClient restClient, Snowflake id) {
return new RestChannel(restClient, id.asLong());
}
/**
* Create a {@link RestChannel} with the given parameters.
*
* @param restClient REST API resources
* @param id the ID of this channel
*/
public static RestChannel create(RestClient restClient, long id) {
return new RestChannel(restClient, id);
}
/**
* Retrieve this channel's data upon subscription.
*
* @return a {@link Mono} where, upon successful completion, emits the {@link ChannelData} belonging to this
* channel. If an error is received, it is emitted through the {@code Mono}.
* @see Get Channel
*/
public Mono getData() {
return restClient.getChannelService().getChannel(id);
}
public RestMessage message(long messageId) {
return RestMessage.create(restClient, id, messageId);
}
/**
* Request to edit this text channel using a given {@link ChannelModifyRequest} as body and optionally, a reason.
*
* @param request request body used to create a new message
* @param reason a reason for this action, can be {@code null}
* @return a {@link Mono} where, upon successful completion, emits the edited {@link ChannelData}. If an error is
* received, it is emitted through the {@code Mono}.
* @see Modify Channel
*/
public Mono modify(ChannelModifyRequest request, @Nullable String reason) {
return restClient.getChannelService().modifyChannel(id, request, reason);
}
/**
* Request to delete this channel while optionally specifying a reason.
*
* @param reason a reason for this action, can be {@code null}
* @return A {@link Mono} where, upon successful completion, emits nothing; indicating the channel has been deleted.
* If an error is received, it is emitted through the {@code Mono}.
* @see
* Delete/Close Channel
*/
public Mono delete(@Nullable String reason) {
return restClient.getChannelService().deleteChannel(id, reason).then();
}
/**
* Request to retrieve all messages before the specified ID.
*
* The returned {@code Flux} will emit items in reverse-chronological order (newest to oldest). It is
* recommended to limit the emitted items by invoking either {@link Flux#takeWhile(Predicate)} (to retrieve IDs
* within a specified range) or {@link Flux#take(long)} (to retrieve a specific amount of IDs).
*
* The following example will get all messages from {@code messageId} to {@code myOtherMessageId}:
* {@code getMessagesBefore(messageId).takeWhile(message -> message.getId().compareTo(myOtherMessageId) >= 0)}
*
* @param messageId The ID of the newest message to retrieve.
* @return A {@link Flux} that continually emits all {@link MessageData messages} before the
* specified ID. If an error is received, it is emitted through the {@code Flux}.
* @see
* Get Channel Messages
*/
public Flux getMessagesBefore(long messageId) {
Function