-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Document APIv9. #2855
Document APIv9. #2855
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Will there be a way to test out threads before this officially ships? A lot of these changes seem fairly complex (especially with the new layer of channel nesting and complexities there) and at the moment it's not trivial to conceptualize how threads even work (much less bug-hunt with them) without being able to play with it in action. |
Locking for a bit... will unlock when things cool off. |
As far as I understood there will be, they're having some sort of allowlist for that. Hoping to get there :) |
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 couple questions on my part...
|
||
###### Channel Types | ||
|
||
> warn | ||
> Type 10, 11 and 12 are only available in API v9. |
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.
Does this mean you cannot preform actions on them with REST API v8, or is it just that you don't get events for them. (also, 10, 11, and 12
instead of 10, 11 and 12
for oxford comma)
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 REST API will work fine, I didn't really think there were any backwards compatibility issues there, it's mostly for gateway events that the issues happen.
docs/resources/Channel.md
Outdated
| message_count? | integer | an approximate count of messages in a thread, caps at 50 | | ||
| member_count? | integer | an approximate count of users in a thread, caps at 50 | |
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.
Is there any reason this isn't in the metadata too? (given other important information like archived
is there too...)
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 figured these were things that were potentially valuable for other types of channels in the future, but the thread_metadata things are basically never going to be valuable outside of threads.
"archived": false, | ||
"archiver_id": "41771983423143937", |
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.
... an archiver for a channel that isn't archived? (Just a confusing attribute name imo, my bad)
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.
Yeah, in this case it would be the person that unarchived the thread then.
@@ -422,6 +452,37 @@ Since message references are a generic attribution to a previous message, there | |||
|
|||
\* `channel_id` is optional when creating a reply, but will always be present when receiving an event/response that includes this data model. | |||
|
|||
#### Message Types | |||
|
|||
There are multiple message types that have a message_reference object. Since message references are generic attribution to a previous message, there will be more types of messages which have this information in the future. |
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 use a different word than "type" for this? (as a message has a type
attribute...)
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.
Multiple variations / multiple kinds, perhaps?
|
||
#### Thread List Sync | ||
|
||
Sent when the current user _gains_ access to a channel. |
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.
Does this have no payload? Perhaps saying which channel was joined would be more useful?
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's listed below :)
Good work! |
docs/resources/Channel.md
Outdated
@@ -40,6 +47,9 @@ Represents a guild or DM channel within Discord. | |||
| GUILD_CATEGORY | 4 | an [organizational category](https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101) that contains up to 50 channels | | |||
| GUILD_NEWS | 5 | a channel that [users can follow and crosspost into their own server](https://support.discord.com/hc/en-us/articles/360032008192) | | |||
| GUILD_STORE | 6 | a channel in which game developers can [sell their game on Discord](https://discord.com/developers/docs/game-and-server-management/special-channels) | | |||
| NEWS_THREAD | 10 | a temporary sub-channel within a GUILD_NEWS channel | | |||
| PUBLIC_THREAD | 11 | a temporary sub-channel within a GUILD_TEXT channel | | |||
| PRIVATE_THREAD | 12 | a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission | |
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.
Is it expected that threads will only ever be supported in Guilds? Not Groups or DMs?
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.
Correct, only in Guilds
- Clients use _their own_ [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) to calculate read states and notification settings. This is largely irrelevant for bots though, but is the reason for some of the syncing complexity detailed here. | ||
- Knowing everyone that is in a thread. | ||
|
||
Membership is tracked in an array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects. These have four fields, `id` (the thread id), `user_id`, `join_timestamp`, and `flags`. Currently the only `flags` are for notification settings, but others may be added in future updates. |
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.
If a thread member
loses "access" by way of the removal of SEND_MESSAGES
, or USE_PUBLIC/PRIVATE_THREADS
are they removed from this array?
If not, are they removed if READ_MESSAGES
is removed?
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.
No, we don't remove people when losing access to a channel.
One reason is a moderator may make a mistake or temporarily want to hide a channel, and it would be a bad experience to kick everyone out of a thread then!
docs/topics/Gateway.md
Outdated
| Field | Type | Description | | ||
|--------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------| | ||
| guild_id | snowflake | the id of the guild | | ||
| channel_ids? | array of snowflakes | the parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire 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.
When would thread lists be synced for the entire guild? On joining 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.
Hmm. So for non-bots, we send this message when you first click on a guild, effectively lazy loading threads. But for bots, we hide this and send you all that data in guild_create. So, yeah, in practice for bots, it's probably always provided.
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.
Oh, actually there is one other case, when someone becomes owner of a guild we re-sync everything, but that's hopefully not an issue for bots too
docs/topics/Gateway.md
Outdated
| guild_id | snowflake | the id of the guild | | ||
| channel_ids? | array of snowflakes | the parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild | | ||
| threads | array of [channel](#DOCS_RESOURCES_CHANNEL/channel-object) objects | all active threads in the given channels that the current user can access | | ||
| members | array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects | all thread member objects from the synced threads for the current user, indicating which threads the current user has been added to | |
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.
To be clear, the channel_ids
and members
information is available in a nested format inside of the threads
array, correct? (threads[*].parentId
and threads[*].member
)
Are these root-level properties just for making certain access patterns easier or is there a specific reason for them?
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.
Check out the Thread Membership
section and if you still have questions or concerns about it, let me know, but it talks about 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.
Also channel_ids
can't be inferred from the returned threads.
I expect the algorithm bots should use here is:
- Remove all threads that have a parent_id that is in the channel_ids set
- Add all threads from the threads array
Because a channel might not have any active threads in it, so we're signaling that to you here as well!
|
||
### Syncing for the current user | ||
|
||
- A [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) Gateway Event is always sent when the current user is added to or removed from a thread. |
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.
Is this only fired if a user is explicitly removed? (Self removal or removed by an Admin)
Or is this also triggered by implicit access lost via the revocation of READ_MESSAGES
on the parent channel?
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's sent when someone is added or removed.
Permission changes will not remove you from a thread
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.
Nice work discord team 👏
Hey all, I'm going to merge and deploy this, if you have other concerns though, feel free to open Issues or PRs as you would normally. |
This reverts commit 478af37.
@ajpalkovic hope it's okay to comment here, just found an inconsistency.
Probably Start Private Thread instead? |
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.
Leave the user
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.
hyped 🔥
yup |
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of twilight-rs#799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This commit adds support to guild threads channels, see discord/discord-api-docs#2855. It also bumps the Discord API version and gateway to v9.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This commit adds support to guild threads channels, see discord/discord-api-docs#2855. It also bumps the Discord API version and gateway to v9.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
This PR implements the models for threads, including gateway payloads and cache updating (first time working with the Twilight's gateway + cache, so scrutinise my code). Still todo / caveats: - Make the NumericEnumVisitor work with multiple types. There's a lot of commented code in `model/src/visitor.rs`. - Update intents comments - I left ThreadMember's `flags` field as a u64. Discord's documentation only says `any user-thread settings, currently only used for notifications`, so we'll have to leave it as in integer for now. - Might've missed some tests? Not sure - HTTP (obviously) Docs PR: discord/discord-api-docs#2855 Address part of #799.
To make migration easier, there is a guide in
docs/topics/Threads.md
that aggregates all the information about threads in one place for you!We wanted to give app developers at least 2 months heads up so you all can update your bots and be ready to go whenever we do ship threads. Please keep in mind that bots on older API versions will receive NO gateway events for threads, or messages in threads, so updating is important!
I'll be around for questions today, and I plan to keep this open for ~24 hours and then merge tomorrow afternoon and update the docs website.