-
-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Invite to match Discord changes #2500
base: master
Are you sure you want to change the base?
Changes from all commits
c31055b
40d9e99
97d863c
fc3fb16
3d5f088
54db46a
226416b
5e67c36
1ee67fc
f8b14ed
5f16289
31f2f94
37c6187
575ee0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -156,7 +156,7 @@ static RestAction<Invite> resolve(@Nonnull final JDA api, @Nonnull final String | |||||
* An {@link Invite.Channel Invite.Channel} object | ||||||
* containing information about this invite's origin channel. | ||||||
* | ||||||
* @return Information about this invite's origin channel or null in case of a group invite | ||||||
* @return Information about this invite's origin channel or null in case of a non-guild invite | ||||||
* | ||||||
* @see Invite.Channel | ||||||
*/ | ||||||
|
@@ -167,7 +167,7 @@ static RestAction<Invite> resolve(@Nonnull final JDA api, @Nonnull final String | |||||
* An {@link Invite.Group Invite.Group} object | ||||||
* containing information about this invite's origin group. | ||||||
* | ||||||
* @return Information about this invite's origin group or null in case of a guild invite | ||||||
* @return Information about this invite's origin group or null in case of a non-group invite | ||||||
* | ||||||
* @see Invite.Group | ||||||
*/ | ||||||
|
@@ -210,17 +210,17 @@ default String getUrl() | |||||
* An {@link Invite.Guild Invite.Guild} object | ||||||
* containing information about this invite's origin guild. | ||||||
* | ||||||
* @return Information about this invite's origin guild or null in case of a group invite | ||||||
* @return Information about this invite's origin guild or null in case of a non-guild invite | ||||||
* | ||||||
* @see Invite.Guild | ||||||
*/ | ||||||
@Nullable | ||||||
Guild getGuild(); | ||||||
|
||||||
/** | ||||||
* The user who created this invite. For not expanded invites this may be null. | ||||||
* The user who created this invite. For a non-expanded invite, this may be null. | ||||||
* | ||||||
* @return The user who created this invite | ||||||
* @return The user who created this invite. If this is a {@link Invite.InviteType#FRIEND Friend invite} this is the target. | ||||||
*/ | ||||||
@Nullable | ||||||
User getInviter(); | ||||||
|
@@ -249,18 +249,15 @@ default String getUrl() | |||||
int getMaxAge(); | ||||||
|
||||||
/** | ||||||
* The max uses of this invite. If there is no limit thus will return {@code 0}. | ||||||
* | ||||||
* <p>This works only for expanded invites and will throw a {@link IllegalStateException} otherwise! | ||||||
* | ||||||
* @throws IllegalStateException | ||||||
* if this invite is not expanded | ||||||
* | ||||||
* @return The max uses of this invite or {@code 0} if there is no limit | ||||||
* | ||||||
* @see #expand() | ||||||
* @see #isExpanded() | ||||||
*/ | ||||||
* The max uses of this invite. | ||||||
* If there is no limit this will return {@code 0}. | ||||||
* | ||||||
* <p>This works only for expanded invites, and will throw a {@link java.lang.IllegalStateException} otherwise!</p> | ||||||
* | ||||||
* @throws java.lang.IllegalStateException | ||||||
* if this is not an expanded invite | ||||||
* @return The max uses of this invite or {@code 0} if there is no limit | ||||||
*/ | ||||||
int getMaxUses(); | ||||||
|
||||||
/** | ||||||
|
@@ -279,16 +276,23 @@ default String getUrl() | |||||
@Nonnull | ||||||
OffsetDateTime getTimeCreated(); | ||||||
|
||||||
/** | ||||||
* Returns the expiration date of this invite, if it expires | ||||||
* | ||||||
* @return The expiration date of this invite, or null if it doesn't expire | ||||||
*/ | ||||||
@Nullable | ||||||
OffsetDateTime getTimeExpires(); | ||||||
|
||||||
/** | ||||||
* How often this invite has been used. | ||||||
* | ||||||
* <p>This works only for expanded invites and will throw a {@link IllegalStateException} otherwise! | ||||||
* | ||||||
* @throws IllegalStateException | ||||||
* @throws java.lang.IllegalStateException | ||||||
* if this invite is not expanded | ||||||
* | ||||||
* @return The uses of this invite | ||||||
* | ||||||
* @see #expand() | ||||||
* @see #isExpanded() | ||||||
*/ | ||||||
|
@@ -312,13 +316,12 @@ default String getUrl() | |||||
/** | ||||||
* Whether this Invite grants only temporary access or not. | ||||||
* | ||||||
* <p>This works only for expanded invites and will throw a {@link IllegalStateException} otherwise! | ||||||
* <p>This works only for expanded invites and will throw a {@link IllegalStateException} otherwise!</p> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @throws IllegalStateException | ||||||
* if this invite is not expanded | ||||||
* | ||||||
* @return Whether this invite is temporary or not | ||||||
* | ||||||
* @see #expand() | ||||||
* @see #isExpanded() | ||||||
*/ | ||||||
|
@@ -689,7 +692,22 @@ enum InviteType | |||||
{ | ||||||
GUILD, | ||||||
GROUP, | ||||||
UNKNOWN | ||||||
FRIEND, | ||||||
UNKNOWN; | ||||||
|
||||||
/** | ||||||
* Static accessor for retrieving a invite type based on its Discord id key. | ||||||
* | ||||||
* @param id | ||||||
* The id key of the requested invite type. | ||||||
* | ||||||
* @return The InviteType that is referred to by the provided key. If the id key is unknown, {@link #UNKNOWN} is returned. | ||||||
*/ | ||||||
@Nonnull | ||||||
public static InviteType fromId(int id) | ||||||
{ | ||||||
return id < UNKNOWN.ordinal() ? values()[id] : UNKNOWN; | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,6 +36,15 @@ | |||||
*/ | ||||||
public interface InviteAction extends AuditableRestAction<Invite> | ||||||
{ | ||||||
/** | ||||||
* The maximum age, 30 days, in seconds, for a restricted invite. | ||||||
* | ||||||
* <p>A restricted invite is an invite that is created in a non-community server</p> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @see #hasCommunityRestrictions() | ||||||
*/ | ||||||
int MAX_RESTRICTED_AGE = 2592000; | ||||||
|
||||||
@Nonnull | ||||||
@Override | ||||||
InviteAction setCheck(@Nullable BooleanSupplier checks); | ||||||
|
@@ -48,17 +57,28 @@ public interface InviteAction extends AuditableRestAction<Invite> | |||||
@Override | ||||||
InviteAction deadline(long timestamp); | ||||||
|
||||||
/** | ||||||
* Invites created in non-community servers are not allowed to be permanent, | ||||||
* and are restricted to a maximum age of 30 days. | ||||||
* | ||||||
* @see #MAX_RESTRICTED_AGE | ||||||
*/ | ||||||
boolean hasCommunityRestrictions(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||||||
|
||||||
/** | ||||||
* Sets the max age in seconds for the invite. Set this to {@code 0} if the invite should never expire. Default is {@code 86400} (24 hours). | ||||||
* {@code null} will reset this to the default value. | ||||||
* | ||||||
* <p>Invites in non-community servers are not allowed to be permanent, with an allowed range of {@code 1} (1 second) to {@code 2592000} (30 days). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* | ||||||
* @param maxAge | ||||||
* The max age for this invite or {@code null} to use the default value. | ||||||
* | ||||||
* @throws IllegalArgumentException | ||||||
* If maxAge is negative. | ||||||
* If maxAge is negative, or if the guild is not a community guild and maxAge is not in the allowed range. | ||||||
* | ||||||
* @return The current InviteAction for chaining. | ||||||
* @see #hasCommunityRestrictions() | ||||||
*/ | ||||||
@Nonnull | ||||||
@CheckReturnValue | ||||||
|
@@ -68,15 +88,20 @@ public interface InviteAction extends AuditableRestAction<Invite> | |||||
* Sets the max age for the invite. Set this to {@code 0} if the invite should never expire. Default is {@code 86400} (24 hours). | ||||||
* {@code null} will reset this to the default value. | ||||||
* | ||||||
* <p>Invites in non-community servers are not allowed to be permanent, with an allowed range from 1 second to 30 days. | ||||||
* | ||||||
* @param maxAge | ||||||
* The max age for this invite or {@code null} to use the default value. | ||||||
* @param timeUnit | ||||||
* The {@link java.util.concurrent.TimeUnit TimeUnit} type of {@code maxAge}. | ||||||
* | ||||||
* @throws IllegalArgumentException | ||||||
* If maxAge is negative or maxAge is positive and timeUnit is null. | ||||||
* If maxAge is negative, | ||||||
* timeUnit is null, | ||||||
* or if the guild is not a community guild and maxAge is not in the allowed range. | ||||||
* | ||||||
* @return The current InviteAction for chaining. | ||||||
* @see #hasCommunityRestrictions() | ||||||
*/ | ||||||
@Nonnull | ||||||
@CheckReturnValue | ||||||
|
@@ -235,5 +260,4 @@ default InviteAction setTargetStream(@Nonnull final Member member) | |||||
Checks.notNull(member, "Member"); | ||||||
return setTargetStream(member.getIdLong()); | ||||||
} | ||||||
|
||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs changes here seem unrelated to the rest of this PR, please revert them.