|
28 | 28 | import net.dv8tion.jda.core.utils.cache.SnowflakeCacheView;
|
29 | 29 |
|
30 | 30 | import javax.annotation.CheckReturnValue;
|
| 31 | +import javax.annotation.Nonnull; |
31 | 32 | import javax.annotation.Nullable;
|
32 | 33 | import java.util.Collection;
|
33 | 34 | import java.util.List;
|
@@ -785,10 +786,41 @@ default List<Emote> getEmotesByName(String name, boolean ignoreCase)
|
785 | 786 | *
|
786 | 787 | * @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: {@literal List<}{@link net.dv8tion.jda.core.entities.User User}{@literal >}
|
787 | 788 | * <br>An unmodifiable list of all users currently banned from this Guild
|
| 789 | + * |
| 790 | + * @deprecated |
| 791 | + * Use {@link #getBanList()} instead |
788 | 792 | */
|
| 793 | + @Deprecated |
789 | 794 | @CheckReturnValue
|
790 | 795 | RestAction<List<User>> getBans();
|
791 | 796 |
|
| 797 | + /** |
| 798 | + * Gets an unmodifiable list of the currently banned {@link net.dv8tion.jda.core.entities.User Users}. |
| 799 | + * <br>If you wish to ban or unban a user, please {@link GuildController#ban(User, int) GuildController.ban(User, int)} or |
| 800 | + * {@link GuildController#unban(User) GuildController.ban(User)}. |
| 801 | + * |
| 802 | + * <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by |
| 803 | + * the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following: |
| 804 | + * <ul> |
| 805 | + * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS} |
| 806 | + * <br>The ban list cannot be fetched due to a permission discrepancy</li> |
| 807 | + * |
| 808 | + * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} |
| 809 | + * <br>We were removed from the Guild before finishing the task</li> |
| 810 | + * </ul> |
| 811 | + * |
| 812 | + * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException |
| 813 | + * If the logged in account does not have the {@link net.dv8tion.jda.core.Permission#BAN_MEMBERS} permission. |
| 814 | + * @throws net.dv8tion.jda.core.exceptions.GuildUnavailableException |
| 815 | + * If the guild is temporarily not {@link #isAvailable() available} |
| 816 | + * |
| 817 | + * @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: {@literal List<}{@link net.dv8tion.jda.core.entities.Guild.Ban Ban}{@literal >} |
| 818 | + * <br>An unmodifiable list of all users currently banned from this Guild |
| 819 | + */ |
| 820 | + @Nonnull |
| 821 | + @CheckReturnValue |
| 822 | + RestAction<List<Ban>> getBanList(); |
| 823 | + |
792 | 824 | /**
|
793 | 825 | * The method calculates the amount of Members that would be pruned if {@link GuildController#prune(int)} was executed.
|
794 | 826 | * Prunability is determined by a Member being offline for at least <i>days</i> days.
|
@@ -1373,4 +1405,50 @@ public static ExplicitContentLevel fromKey(int key)
|
1373 | 1405 | return UNKNOWN;
|
1374 | 1406 | }
|
1375 | 1407 | }
|
| 1408 | + |
| 1409 | + /** |
| 1410 | + * Represents a Ban object. |
| 1411 | + * |
| 1412 | + * @see #getBanList() |
| 1413 | + * @see <a href="https://discordapp.com/developers/docs/resources/guild#ban-object" target="_blank">Discord Docs: Ban Object</a> |
| 1414 | + */ |
| 1415 | + class Ban |
| 1416 | + { |
| 1417 | + protected final User user; |
| 1418 | + protected final String reason; |
| 1419 | + |
| 1420 | + public Ban(User user, String reason) |
| 1421 | + { |
| 1422 | + this.user = user; |
| 1423 | + this.reason = reason; |
| 1424 | + } |
| 1425 | + |
| 1426 | + /** |
| 1427 | + * The {@link net.dv8tion.jda.core.entities.User User} that was banned |
| 1428 | + * |
| 1429 | + * @return The banned User |
| 1430 | + */ |
| 1431 | + @Nonnull |
| 1432 | + public User getUser() |
| 1433 | + { |
| 1434 | + return user; |
| 1435 | + } |
| 1436 | + |
| 1437 | + /** |
| 1438 | + * The reason why this user was banned |
| 1439 | + * |
| 1440 | + * @return The reason for this ban, or {@code null} |
| 1441 | + */ |
| 1442 | + @Nullable |
| 1443 | + public String getReason() |
| 1444 | + { |
| 1445 | + return reason; |
| 1446 | + } |
| 1447 | + |
| 1448 | + @Override |
| 1449 | + public String toString() |
| 1450 | + { |
| 1451 | + return "GuildBan:" + user + (reason == null ? "" : '(' + reason + ')'); |
| 1452 | + } |
| 1453 | + } |
1376 | 1454 | }
|
0 commit comments