use of org.javacord.api.interaction.ApplicationCommandPermissions in project Javacord by BtoBastian.
the class DiscordApiImpl method batchUpdateApplicationCommandPermissions.
@Override
public CompletableFuture<List<ServerApplicationCommandPermissions>> batchUpdateApplicationCommandPermissions(Server server, List<ServerApplicationCommandPermissionsBuilder> slashCommandPermissionsBuilders) {
ArrayNode body = JsonNodeFactory.instance.arrayNode();
for (ServerApplicationCommandPermissionsBuilder permission : slashCommandPermissionsBuilders) {
ObjectNode node = JsonNodeFactory.instance.objectNode();
node.put("id", permission.getCommandId());
ArrayNode array = node.putArray("permissions");
for (ApplicationCommandPermissions permissionPermission : permission.getPermissions()) {
array.add(((ApplicationCommandPermissionsImpl) permissionPermission).toJsonNode());
}
body.add(node);
}
return new RestRequest<List<ServerApplicationCommandPermissions>>(server.getApi(), RestMethod.PUT, RestEndpoint.SERVER_APPLICATION_COMMAND_PERMISSIONS).setUrlParameters(String.valueOf(server.getApi().getClientId()), server.getIdAsString()).setBody(body).execute(result -> jsonToServerApplicationCommandPermissionsList(result.getJsonBody()));
}
use of org.javacord.api.interaction.ApplicationCommandPermissions in project Javacord by BtoBastian.
the class ApplicationCommandPermissionsUpdaterDelegateImpl method update.
@Override
public CompletableFuture<ServerApplicationCommandPermissions> update(long commandId) {
ObjectNode body = JsonNodeFactory.instance.objectNode();
ArrayNode array = body.putArray("permissions");
for (ApplicationCommandPermissions permission : permissions) {
array.add(((ApplicationCommandPermissionsImpl) permission).toJsonNode());
}
return new RestRequest<ServerApplicationCommandPermissions>(server.getApi(), RestMethod.PUT, RestEndpoint.APPLICATION_COMMAND_PERMISSIONS).setUrlParameters(String.valueOf(server.getApi().getClientId()), server.getIdAsString(), String.valueOf(commandId)).setBody(body).execute(result -> new ServerApplicationCommandPermissionsImpl((DiscordApiImpl) server.getApi(), result.getJsonBody()));
}
Aggregations