-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add support for threads #1613
Add support for threads #1613
Conversation
Currently this encapsulates only the most minimalist pass on being able to construct entities for threads and the happy path of recieving messages in threads. Only "supports" receiving messages via the GenericMessageEvent and MessageReceivedEvent
/** | ||
* TODO docs | https://discord.com/developers/docs/resources/channel#channel-object-channel-types | ||
*/ | ||
GUILD_NEWS_THREAD(10, -1,true), //TODO confirm handling of sort bucket. |
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.
It seems like you can't sort threads so this sort bucket value is irrelevant
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.
What even is a news thread anyway?
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.
GUILD_NEWS_THREAD(10, -1,true), //TODO confirm handling of sort bucket. | |
GUILD_NEWS_THREAD(10, -1, true), |
// - getMembers //TODO might not need this as we'll have getThreadMembers() | ||
|
||
//TODO pick a better name (or use getParent once we break from GuildChannel interface?) | ||
GuildChannel getParentChannel(); |
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.
Maybe just MessageChannel getAncestor()
for now, you can only create threads on message channels anyway.
int getMemberCount(); | ||
|
||
//TODO | This name is bad. Looking for alternatives. | ||
boolean isSubscribedToThread(); |
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.
How about isJoined()
?
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.
isJoined sounds, odd to me.
isSubscribed or hasJoined sound better imo
@@ -108,6 +111,11 @@ | |||
*/ | |||
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING(17), | |||
|
|||
/** | |||
* TODO docs | https://discord.com/developers/docs/topics/threads#new-message-types |
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.
* TODO docs | https://discord.com/developers/docs/topics/threads#new-message-types | |
* Message which indicates that a {@link net.dv8tion.jda.api.entities.GuildThread GuildThread} has been created. |
{ | ||
throw new IllegalStateException("This message was not sent in a guild"); | ||
} |
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.
{ | |
throw new IllegalStateException("This message was not sent in a guild"); | |
} | |
throw new IllegalStateException("This message was not sent in a guild"); |
public class GuildThreadImpl extends AbstractChannelImpl<GuildThread, GuildThreadImpl> implements GuildThread | ||
{ | ||
//TODO this same pattern is used in MemberImpl. Might want to consider centralizing? dunno. | ||
private static final ZoneOffset OFFSET = ZoneOffset.of("+00:00"); |
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.
We could move this to Helpers
@Override | ||
public int getPosition() | ||
{ | ||
throw new UnsupportedOperationException("Thread do not have a concept of position"); |
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.
How does the client order them? Can we not just use the same ordering?
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.
It is either based on join date or creation date. Will need to test, but yeah, it does have an implicit ordering. That being said, it isn't an explicit one and it would change when you leave/join threads, so I'm really on the fence about supporting this.
Really this method only exists on threads because of the interfaces implemented. Providing a position here doesn't make sense especially since position historically implies something that you can modify like with other channels. There's no actionable information for bots here.
@@ -0,0 +1,107 @@ | |||
package net.dv8tion.jda.internal.entities; |
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.
Copyright
return this; | ||
} | ||
|
||
GuildThreadMemberImpl setFlags(long flags) |
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.
Should these be public?
{ | ||
throw new IllegalStateException("This message was not sent in a guild"); | ||
} |
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.
{ | |
throw new IllegalStateException("This message was not sent in a guild"); | |
} | |
throw new IllegalStateException("This message was not sent in a guild"); |
# Conflicts: # src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
@Nullable | ||
String getArchivingMemberId(); | ||
|
||
long getArchivingMemberIdLong(); |
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.
When I receive a THREAD_UPDATE event it doesn't include the member who archived the channel. (I've the GUILD_MEMBERS intent)
Am I misunderstanding what this method is supposed to do or?
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.
You would get this information regardless of the GUILD_MEMBERS intent. However, this property can be null
(for the String version) or 0
(for the long version) when the thread was auto-archived by Discord based on inactivity duration.
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.
{
"op" : 0,
"s" : 8,
"t" : "THREAD_UPDATE",
"d" : {
"last_message_id" : "860587045402968105",
"audience" : {
"parent_id" : "859388924278734868",
"channel_type" : 11
},
"parent_id" : "859388924278734868",
"owner_id" : "823709352509833256",
"name" : "wa",
"guild_id" : "859165430752870400",
"thread_metadata" : {
"archived" : true,
"archive_timestamp" : "2021-07-02T18:25:43.757579+00:00",
"locked" : true,
"auto_archive_duration" : 1440
},
"id" : "859390106968129587",
"type" : 11,
"member_count" : 2,
"message_count" : 8
}
When manually archiving a thread, am I doing something wrong or missing something? (using latest features/threads branch)
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.
@DV8FromTheWorld I'm probably doing something wrong, but just bumping it to make sure.
Is there a checklist whats missing here? |
Are there any updates on this? Discord is forcefulling enabling threads on all guilds on 9/9 and JDA still doesn't support them (which is bad for moderation and logging bots). |
Threads require changes to the channel hierarchy to be properly implemented, so they'll be JDA 5 |
This PR isn't what we're going to move forward with for Threads in JDA. I'm hoping to publish a list of "what needs to happen to get to Threads" soon. We've been in a transitionary period for the project, moving from having a single core developer to trying to move to more community involvement, but that comes with some bumps along the way. Threads have not been forgotten. |
JDA v5.0.0-alpha.1 is released and has support for threads. |
The Threads api is currently in open beta and can only be used in small testing guilds
Currently this encapsulates only the most minimalist pass on being able to construct entities for threads and the happy path of receiving messages in threads.
Only "supports" receiving messages via the GenericMessageEvent and MessageReceivedEvent
This PR will be in a draft state for quite a while and is here for collaboration. Expect incredibly breaking changes as we prepare for threads.