Skip to content

Commit

Permalink
Fix InviteCreateEvent.getExpiration impl after #1099
Browse files Browse the repository at this point in the history
  • Loading branch information
quanticc committed Mar 20, 2023
1 parent 7912be1 commit ad64fcd
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public int getMaxAge() {
}

/**
* Gets whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role).
* Gets whether this invite only grants temporary membership.
*
* @return Whether or not the invite is temporary.
* @return {@code true} if this invite only grants temporary membership
*/
public boolean isTemporary() {
return temporary;
Expand All @@ -162,10 +162,7 @@ public Instant getCreation() {
* @return The instant this invite expires, if possible.
*/
public Optional<Instant> getExpiration() {
final boolean temporary = isTemporary();
final int maxAge = getMaxAge();

return temporary ? Optional.of(getCreation().plus(maxAge, ChronoUnit.SECONDS)) : Optional.empty();
return maxAge > 0 ? Optional.of(getCreation().plus(maxAge, ChronoUnit.SECONDS)): Optional.empty();
}

/**
Expand Down

0 comments on commit ad64fcd

Please sign in to comment.