Search in sources :

Example 6 with IAuditLog

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

the class Guild method getAuditLog.

/*
	 * (non-Javadoc)
	 * 
	 * @see io.discloader.discloader.entity.guild.IGuild#getAuditLog(io.discloader.
	 * discloader.entity.auditlog.ActionTypes, short)
	 */
@Override
public CompletableFuture<IAuditLog> getAuditLog(ActionTypes action, int limit) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    CompletableFuture<AuditLogJSON> cf = loader.rest.request(Methods.GET, Endpoints.auditLogs(getID()) + "?action_type=" + action.toInt() + "&limit=" + limit, 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 7 with IAuditLog

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

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(IUser user, ActionTypes action, IAuditLogEntry before, int limit) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    JSONObject params = new JSONObject().put("user_id", SnowflakeUtil.asString(user)).put("action_type", action.toInt()).put("before", SnowflakeUtil.asString(before)).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 8 with IAuditLog

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

the class Guild method getAuditLog.

@Override
public CompletableFuture<IAuditLog> getAuditLog(IUser user, int limit) {
    CompletableFuture<IAuditLog> future = new CompletableFuture<>();
    JSONObject params = new JSONObject().put("user_id", SnowflakeUtil.asString(user)).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)

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