@CheckReturnValue
    public AuditableRestAction<Emote> createEmote(String name, Icon icon, Role... roles)
    {
        checkPermission(Permission.MANAGE_EMOTES);
        Checks.notBlank(name, "Emote name");
        Checks.notNull(icon, "Emote icon");
        Checks.notNull(roles, "Roles");

        JSONObject body = new JSONObject();
        body.put("name", name);
        body.put("image", icon.getEncoding());
        if (roles.length > 0) // making sure none of the provided roles are null before mapping them to the snowflake id
            body.put("roles", Stream.of(roles).filter(Objects::nonNull).map(ISnowflake::getId).collect(Collectors.toSet()));

        Route.CompiledRoute route = Route.Emotes.CREATE_EMOTE.compile(getGuild().getId());
        return new AuditableRestAction<Emote>(getJDA(), route, body)
        {
            @Override
            protected void handleResponse(Response response, Request<Emote> request)
            {
                if (!response.isOk())
                {
                    request.onFailure(response);
                    return;
                }

                JSONObject obj = response.getObject();
                EmoteImpl emote = api.get().getEntityBuilder().createEmote((GuildImpl) getGuild(), obj, true);
                request.onSuccess(emote);
            }
        };
    }
@ CheckReturnValue public AuditableRestAction < Emote > createEmote ( String name , Icon icon , Role ... roles ) { checkPermission ( Permission . MANAGE_EMOTES ) ; Checks . notBlank ( name , "Emote name" ) ; Checks . notNull ( icon , "Emote icon" ) ; Checks . notNull ( roles , "Roles" ) ; JSONObject body = new JSONObject ( ) ; body . put ( "name" , name ) ; body . put ( "image" , icon . getEncoding ( ) ) ; if ( roles . length > 0 ) body . put ( "roles" , Stream . of ( roles ) . filter ( Objects :: nonNull ) . map ( ISnowflake :: getId ) . collect ( Collectors . toSet ( ) ) ) ; Route . CompiledRoute route = Route . Emotes . CREATE_EMOTE . compile ( getGuild ( ) . getId ( ) ) ; return new AuditableRestAction < Emote > ( getJDA ( ) , route , body ) { @ Override protected void handleResponse ( Response response , Request < Emote > request ) { if ( ! response . isOk ( ) ) { request . onFailure ( response ) ; return ; } JSONObject obj = response . getObject ( ) ; EmoteImpl emote = api . get ( ) . getEntityBuilder ( ) . createEmote ( ( GuildImpl ) getGuild ( ) , obj , true ) ; request . onSuccess ( emote ) ; } } ; }
Creates a new {@link net.dv8tion.jda.core.entities.Emote Emote} in this Guild.
<br>If one or more Roles are specified the new Emote will only be available to Members with any of the specified Roles (see {@link Member#canInteract(Emote)})
<br>For this to be successful, the logged in account has to have the {@link net.dv8tion.jda.core.Permission#MANAGE_EMOTES MANAGE_EMOTES} Permission.

<p><b><u>Unicode emojis are not included as {@link net.dv8tion.jda.core.entities.Emote Emote}!</u></b>

<p>Note that a guild is limited to 50 normal and 50 animated emotes by default.
Some guilds are able to add additional emotes beyond this limitation due to the
{@code MORE_EMOJI} feature (see {@link net.dv8tion.jda.core.entities.Guild#getFeatures() Guild.getFeatures()}).
<br>Due to simplicity we do not check for these limits.

<p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
<ul>
<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
<br>The emote could not be created due to a permission discrepancy</li>

<li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
<br>We were removed from the Guild before finishing the task</li>
</ul>

@param  name
The name for the new Emote
@param  icon
The {@link net.dv8tion.jda.core.entities.Icon} for the new Emote
@param  roles
The {@link net.dv8tion.jda.core.entities.Role Roles} the new Emote should be restricted to
<br>If no roles are provided the Emote will be available to all Members of this Guild

@throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
If the logged in account does not have the {@link net.dv8tion.jda.core.Permission#MANAGE_EMOTES MANAGE_EMOTES} Permission

@return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction} - Type: {@link net.dv8tion.jda.core.entities.Emote Emote}