Search in sources :

Example 11 with IGuildChannel

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

the class GuildChannel method setCategory.

@Override
public CompletableFuture<IGuildChannel> setCategory(IChannelCategory category) {
    CompletableFuture<IGuildChannel> future = new CompletableFuture<>();
    JSONObject settings = new JSONObject().put("parent_id", SnowflakeUtil.asString(category));
    loader.rest.request(Methods.PATCH, Endpoints.channel(getID()), new RESTOptions(settings), ChannelJSON.class).thenAcceptAsync(data -> {
        IGuildChannel newChannel = (IGuildChannel) EntityBuilder.getChannelFactory().buildChannel(data, getLoader(), getGuild(), false);
        future.complete(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) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IGuildChannel(io.discloader.discloader.entity.channel.IGuildChannel)

Aggregations

IGuildChannel (io.discloader.discloader.entity.channel.IGuildChannel)11 ChannelJSON (io.discloader.discloader.network.json.ChannelJSON)9 RESTOptions (io.discloader.discloader.network.rest.RESTOptions)9 CompletableFuture (java.util.concurrent.CompletableFuture)9 JSONObject (org.json.JSONObject)7 IGuild (io.discloader.discloader.entity.guild.IGuild)6 GuildChannelUpdateEvent (io.discloader.discloader.common.event.channel.GuildChannelUpdateEvent)5 PermissionsException (io.discloader.discloader.common.exceptions.PermissionsException)5 EntityBuilder (io.discloader.discloader.common.registry.EntityBuilder)5 IOverwrite (io.discloader.discloader.entity.IOverwrite)5 IChannelCategory (io.discloader.discloader.entity.channel.IChannelCategory)5 SnowflakeUtil (io.discloader.discloader.entity.util.SnowflakeUtil)5 Endpoints (io.discloader.discloader.network.util.Endpoints)5 Methods (io.discloader.discloader.network.util.Methods)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 EventListenerAdapter (io.discloader.discloader.common.event.EventListenerAdapter)4 IChannel (io.discloader.discloader.entity.channel.IChannel)4 IGuildMember (io.discloader.discloader.entity.guild.IGuildMember)4 IRole (io.discloader.discloader.entity.guild.IRole)4