forked from Javacord/Javacord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d752eed
commit 989d8d5
Showing
5 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
javacord-api/src/main/java/org/javacord/api/entity/server/BulkBanResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.javacord.api.entity.server; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* The response of a bulk ban request. | ||
*/ | ||
public interface BulkBanResponse { | ||
|
||
/** | ||
* Gets the user ids that were banned successfully. | ||
* | ||
* @return The banned user ids. | ||
*/ | ||
Collection<Long> getBannedUserIds(); | ||
|
||
/** | ||
* Gets the user ids that could not be banned. | ||
* | ||
* @return The failed user ids. | ||
*/ | ||
Collection<Long> getFailedUserIds(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
javacord-core/src/main/java/org/javacord/core/entity/server/BulkBanResponseImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.javacord.core.entity.server; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.javacord.api.entity.server.BulkBanResponse; | ||
import java.util.Collection; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
public class BulkBanResponseImpl implements BulkBanResponse { | ||
|
||
/** | ||
* The user ids that were banned successfully. | ||
*/ | ||
private final Set<Long> bannedUserIds = new LinkedHashSet<>(); | ||
|
||
/** | ||
* The user ids that could not be banned. | ||
*/ | ||
private final Set<Long> failedUserIds = new LinkedHashSet<>(); | ||
|
||
/** | ||
* Create a new BulkBanResponseImpl. | ||
* | ||
* @param data The json data about this response. | ||
*/ | ||
public BulkBanResponseImpl(JsonNode data) { | ||
data.get("banned_users").forEach(bannedUser -> bannedUserIds.add(bannedUser.asLong())); | ||
data.get("failed_users").forEach(failedUser -> failedUserIds.add(failedUser.asLong())); | ||
} | ||
|
||
@Override | ||
public Collection<Long> getBannedUserIds() { | ||
return bannedUserIds; | ||
} | ||
|
||
@Override | ||
public Collection<Long> getFailedUserIds() { | ||
return failedUserIds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters