Skip to content

Commit

Permalink
Add getting ban from event
Browse files Browse the repository at this point in the history
  • Loading branch information
BartArys committed Jul 7, 2020
1 parent 2307c5c commit 2b48992
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.5.7

## Additions

* Added `BanAddEvent#getBan` to get the full ban object.

# 0.5.6

## Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.gitlab.kordlib.common.entity.Snowflake
import com.gitlab.kordlib.common.exception.RequestException
import com.gitlab.kordlib.core.Kord
import com.gitlab.kordlib.core.behavior.GuildBehavior
import com.gitlab.kordlib.core.entity.Ban
import com.gitlab.kordlib.core.entity.Guild
import com.gitlab.kordlib.core.entity.Strategizable
import com.gitlab.kordlib.core.entity.User
Expand All @@ -27,7 +28,7 @@ class BanAddEvent(
* Requests to get the [Guild] this ban happened in.
*
* @throws [RequestException] if anything went wrong during the request.
* @throws [EntityNotFoundException] if the wasn't present.
* @throws [EntityNotFoundException] if the guild wasn't present.
*/
suspend fun getGuild(): Guild = supplier.getGuild(guildId)

Expand All @@ -39,6 +40,22 @@ class BanAddEvent(
*/
suspend fun getGuildOrNull(): Guild? = supplier.getGuildOrNull(guildId)

/**
* Requests to get the [Ban] entity this event represents.
*
* @throws [RequestException] if anything went wrong during the request.
* @throws [EntityNotFoundException] if the ban wasn't present.
*/
suspend fun getBan(): Ban = supplier.getGuildBan(guildId, user.id)

/**
* Requests to get the [Ban] entity this event represents.
*
* @throws [RequestException] if anything went wrong during the request.
* @throws [EntityNotFoundException] if the ban wasn't present.
*/
suspend fun getBanOrNull(): Ban? = supplier.getGuildBanOrNull(guildId, user.id)

override fun withStrategy(strategy: EntitySupplyStrategy<*>): BanAddEvent =
BanAddEvent(user, guildId, shard, strategy.supply(kord))
}

0 comments on commit 2b48992

Please sign in to comment.