-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
Implement invite targets #1628
Implement invite targets #1628
Conversation
Is this an actual planned feature of Discord? |
It is already implemented in the desktop app. |
The corresponding properties of the invite object and in the creation request are already in the docs |
Question: Why do you used boxed longs instead of native once? |
I thought it would be better to use them as they can be null and this property is not required |
This is also enabled on the official Poker Night server. |
JDA only implements features exposed in the discord public documentation. If this feature gets documented there then we can revisit this. Setting this PR on freezer until then. |
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/internal/handle/InviteCreateHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
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.
I'm definitely nervous about this API.
All of these setters implicitly set the TargetType based on tangentially related data passed in.
What happens when discord adds a TargetType 3
that also only needs a user?
Feels like something like setTarget(Target.STREAM.of(User))
and setTarget(Target.EMBEDDED_APPLICATION.of(long))
would be more likely to work further into the future.
Note: I don't like the above proposed builders, they were purely for example purposes. The point was the explicit targetting instead of the implicit targeting via tangential information
case STREAM: | ||
DataObject targetUserObject = content.getObject("target_user"); | ||
targetUser = getJDA().getEntityBuilder().createUser(targetUserObject); | ||
application = null; | ||
break; | ||
case EMBEDDED_APPLICATION: | ||
DataObject applicationObject = content.getObject("target_application"); | ||
application = new InviteImpl.EmbeddedApplicationImpl( | ||
applicationObject.getString("icon", null), applicationObject.getString("name"), applicationObject.getString("description"), | ||
applicationObject.getString("summary"), applicationObject.getLong("id"), applicationObject.getInt("max_participants", -1) | ||
); | ||
targetUser = null; | ||
break; | ||
default: | ||
application = null; | ||
targetUser = null; |
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.
case STREAM: | |
DataObject targetUserObject = content.getObject("target_user"); | |
targetUser = getJDA().getEntityBuilder().createUser(targetUserObject); | |
application = null; | |
break; | |
case EMBEDDED_APPLICATION: | |
DataObject applicationObject = content.getObject("target_application"); | |
application = new InviteImpl.EmbeddedApplicationImpl( | |
applicationObject.getString("icon", null), applicationObject.getString("name"), applicationObject.getString("description"), | |
applicationObject.getString("summary"), applicationObject.getLong("id"), applicationObject.getInt("max_participants", -1) | |
); | |
targetUser = null; | |
break; | |
default: | |
application = null; | |
targetUser = null; | |
case STREAM: | |
DataObject targetUserObject = content.getObject("target_user"); | |
targetUser = getJDA().getEntityBuilder().createUser(targetUserObject); | |
application = null; | |
break; | |
case EMBEDDED_APPLICATION: | |
DataObject applicationObject = content.getObject("target_application"); | |
application = new InviteImpl.EmbeddedApplicationImpl( | |
applicationObject.getString("icon", null), applicationObject.getString("name"), applicationObject.getString("description"), | |
applicationObject.getString("summary"), applicationObject.getLong("id"), applicationObject.getInt("max_participants", -1) | |
); | |
targetUser = null; | |
break; | |
default: | |
application = null; | |
targetUser = null; |
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.
I didn't indent these cases as they weren't indented in other switches I saw (eg in the EntityBuilder class) and the indent for them are set to false in the editorconfig. Does it make sense to indent them?
Maybe it would be better to use it like this:
|
I think it's ok the way it is now, if in the future new target types get introduced we could add an overload that accepts a target type parameter. Currently, this is not needed since you can only have one target type per user/application anyway. |
Any updates on this? I would love to use this feature |
@carstendachsbacher In the meantime you can use something like this |
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.
I think we can merge this. @DV8FromTheWorld any reason to still hold this up?
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.
Some questions
After all this time I still don't think that having
Theres also nothing that indicates to the users that |
My mistake |
@Xirado works for me |
My mistake |
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.
Sorry for the delay. We spoke internally and came up with some changes that should hopefully be acceptable to everyone.
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/requests/restaction/InviteAction.java
Outdated
Show resolved
Hide resolved
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.
Just a few more points, and then it should be ready to go
One thing I forgot, please also add |
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.
Thanks for your efforts! LGTM
How about creating an enum for that and allow it as a parameter for |
@DManstrator we don't want to provide an enum for undocumented and potentially temporary applications. If more applications exist in the future, we don't want to curate such a list either. |
Didn't knew it was still undocumented, makes sense then not to have that enum. Thank you. |
This reverts commit d2f3392.
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
This pr provides us with the functionality to create invites for applications and streams.
This allows us to use the discord together features.
The feature is currently only available in the desktop app and the web version.
The invites will show up as normal voice channel invites in the Android and iOS versions.
Examples
Embedded Applications
You can create an invite to an embedded application using
There are currently only a few applications you can use, i listed all I currently know with their application id, so you can try them out yourself if you want:
Stream Invites
You can create an invite to an user stream using
The user to whose stream the invite goes must be streaming in the channel on which the invite is being created.
Invite Properties
This pr also adds the following properties with the following getters to an Invite object
getTargetType(): Invite.TargetType
getTargetApplication(): Invite.EmbeddedApplication
getTargetUser(): User