Search in sources :

Example 6 with IChannel

use of io.discloader.discloader.entity.channel.IChannel in project DiscLoader by R3alCl0ud.

the class GuildChannel method edit.

@Override
public CompletableFuture<? extends IGuildChannel> edit(String name, int position, boolean nsfw, IOverwrite... overwrites) throws PermissionsException {
    CompletableFuture<IGuildChannel> future = new CompletableFuture<>();
    JSONObject settings = new JSONObject().put("name", name).put("position", position).put("nsfw", nsfw).put("permission_overwrites", overwrites);
    loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(settings), ChannelJSON.class).thenAcceptAsync(data -> {
        IChannel newChannel = EntityBuilder.getChannelFactory().buildChannel(data, getLoader(), getGuild(), false);
        if (newChannel instanceof IGuildChannel)
            future.complete((IGuildChannel) newChannel);
    }).exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : Endpoints(io.discloader.discloader.network.util.Endpoints) IChannel(io.discloader.discloader.entity.channel.IChannel) Methods(io.discloader.discloader.network.util.Methods) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) IPermission(io.discloader.discloader.entity.IPermission) ArrayList(java.util.ArrayList) SnowflakeUtil(io.discloader.discloader.entity.util.SnowflakeUtil) IGuildChannel(io.discloader.discloader.entity.channel.IGuildChannel) JSONObject(org.json.JSONObject) Map(java.util.Map) Permission(io.discloader.discloader.core.entity.Permission) IGuild(io.discloader.discloader.entity.guild.IGuild) EventListenerAdapter(io.discloader.discloader.common.event.EventListenerAdapter) FetchInvites(io.discloader.discloader.network.rest.actions.channel.FetchInvites) Role(io.discloader.discloader.core.entity.guild.Role) IGuildMember(io.discloader.discloader.entity.guild.IGuildMember) SetOverwrite(io.discloader.discloader.network.rest.actions.channel.SetOverwrite) CloseGuildChannel(io.discloader.discloader.network.rest.actions.channel.close.CloseGuildChannel) IOverwrite(io.discloader.discloader.entity.IOverwrite) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IRole(io.discloader.discloader.entity.guild.IRole) Permissions(io.discloader.discloader.entity.util.Permissions) EntityBuilder(io.discloader.discloader.common.registry.EntityBuilder) List(java.util.List) Guild(io.discloader.discloader.core.entity.guild.Guild) PermissionsException(io.discloader.discloader.common.exceptions.PermissionsException) IInvite(io.discloader.discloader.entity.invite.IInvite) ChannelJSON(io.discloader.discloader.network.json.ChannelJSON) GuildChannelUpdateEvent(io.discloader.discloader.common.event.channel.GuildChannelUpdateEvent) Overwrite(io.discloader.discloader.core.entity.Overwrite) IChannelCategory(io.discloader.discloader.entity.channel.IChannelCategory) EntityRegistry(io.discloader.discloader.common.registry.EntityRegistry) CompletableFuture(java.util.concurrent.CompletableFuture) IChannel(io.discloader.discloader.entity.channel.IChannel) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IGuildChannel(io.discloader.discloader.entity.channel.IGuildChannel)

Aggregations

IChannel (io.discloader.discloader.entity.channel.IChannel)6 ChannelJSON (io.discloader.discloader.network.json.ChannelJSON)6 IGuild (io.discloader.discloader.entity.guild.IGuild)4 IChannelCategory (io.discloader.discloader.entity.channel.IChannelCategory)3 RESTOptions (io.discloader.discloader.network.rest.RESTOptions)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 JSONObject (org.json.JSONObject)3 GuildChannelUpdateEvent (io.discloader.discloader.common.event.channel.GuildChannelUpdateEvent)2 IOverwrite (io.discloader.discloader.entity.IOverwrite)2 IGuildChannel (io.discloader.discloader.entity.channel.IGuildChannel)2 EventListenerAdapter (io.discloader.discloader.common.event.EventListenerAdapter)1 ChannelCreateEvent (io.discloader.discloader.common.event.channel.ChannelCreateEvent)1 ChannelDeleteEvent (io.discloader.discloader.common.event.channel.ChannelDeleteEvent)1 ChannelUpdateEvent (io.discloader.discloader.common.event.channel.ChannelUpdateEvent)1 PermissionsException (io.discloader.discloader.common.exceptions.PermissionsException)1 EntityBuilder (io.discloader.discloader.common.registry.EntityBuilder)1 EntityRegistry (io.discloader.discloader.common.registry.EntityRegistry)1 Overwrite (io.discloader.discloader.core.entity.Overwrite)1 Permission (io.discloader.discloader.core.entity.Permission)1 Guild (io.discloader.discloader.core.entity.guild.Guild)1