Search in sources :

Example 1 with AuditLog

use of io.discloader.discloader.core.entity.auditlog.AuditLog in project DiscLoader by R3alCl0ud.

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(int limit) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    JSONObject params = new JSONObject().put("limit", limit);
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(params), AuditLogJSON.class);
    cf.thenAcceptAsync(al -> {
        future.complete(new AuditLog(this, al));
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) AuditLogJSON(io.discloader.discloader.network.json.AuditLogJSON) AuditLog(io.discloader.discloader.core.entity.auditlog.AuditLog) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog)

Example 2 with AuditLog

use of io.discloader.discloader.core.entity.auditlog.AuditLog in project DiscLoader by R3alCl0ud.

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(IAuditLogEntry before) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    JSONObject params = new JSONObject().put("before", SnowflakeUtil.asString(before));
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(params), AuditLogJSON.class);
    cf.thenAcceptAsync(al -> {
        future.complete(new AuditLog(this, al));
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) AuditLogJSON(io.discloader.discloader.network.json.AuditLogJSON) AuditLog(io.discloader.discloader.core.entity.auditlog.AuditLog) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog)

Example 3 with AuditLog

use of io.discloader.discloader.core.entity.auditlog.AuditLog in project DiscLoader by R3alCl0ud.

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog() {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(), AuditLogJSON.class);
    cf.thenAcceptAsync(al -> {
        System.out.println("Does this get called?");
        try {
            future.complete(new AuditLog(this, al));
        } catch (Exception e) {
            future.completeExceptionally(e);
        }
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) AuditLogJSON(io.discloader.discloader.network.json.AuditLogJSON) AuditLog(io.discloader.discloader.core.entity.auditlog.AuditLog) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) PermissionsException(io.discloader.discloader.common.exceptions.PermissionsException) IOException(java.io.IOException) GuildSyncException(io.discloader.discloader.common.exceptions.GuildSyncException) UnauthorizedException(io.discloader.discloader.common.exceptions.UnauthorizedException) MissmatchException(io.discloader.discloader.common.exceptions.MissmatchException) AccountTypeException(io.discloader.discloader.common.exceptions.AccountTypeException)

Example 4 with AuditLog

use of io.discloader.discloader.core.entity.auditlog.AuditLog in project DiscLoader by R3alCl0ud.

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(ActionTypes action) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()) + "?action_type=" + action.toInt(), new RESTOptions(), AuditLogJSON.class);
    cf.thenAcceptAsync(al -> {
        future.complete(new AuditLog(this, al));
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) AuditLogJSON(io.discloader.discloader.network.json.AuditLogJSON) AuditLog(io.discloader.discloader.core.entity.auditlog.AuditLog) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog)

Example 5 with AuditLog

use of io.discloader.discloader.core.entity.auditlog.AuditLog in project DiscLoader by R3alCl0ud.

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(IUser user) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    JSONObject params = new JSONObject().put("user_id", SnowflakeUtil.asString(user));
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()), new RESTOptions(params), AuditLogJSON.class);
    cf.thenAcceptAsync(al -> {
        future.complete(new AuditLog(this, al));
    });
    cf.exceptionally(ex -> {
        future.completeExceptionally(ex);
        return null;
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) JSONObject(org.json.JSONObject) RESTOptions(io.discloader.discloader.network.rest.RESTOptions) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog) AuditLogJSON(io.discloader.discloader.network.json.AuditLogJSON) AuditLog(io.discloader.discloader.core.entity.auditlog.AuditLog) IAuditLog(io.discloader.discloader.entity.auditlog.IAuditLog)

Aggregations

AuditLog (io.discloader.discloader.core.entity.auditlog.AuditLog)8 IAuditLog (io.discloader.discloader.entity.auditlog.IAuditLog)8 AuditLogJSON (io.discloader.discloader.network.json.AuditLogJSON)8 RESTOptions (io.discloader.discloader.network.rest.RESTOptions)8 CompletableFuture (java.util.concurrent.CompletableFuture)8 JSONObject (org.json.JSONObject)5 AccountTypeException (io.discloader.discloader.common.exceptions.AccountTypeException)1 GuildSyncException (io.discloader.discloader.common.exceptions.GuildSyncException)1 MissmatchException (io.discloader.discloader.common.exceptions.MissmatchException)1 PermissionsException (io.discloader.discloader.common.exceptions.PermissionsException)1 UnauthorizedException (io.discloader.discloader.common.exceptions.UnauthorizedException)1 IOException (java.io.IOException)1