Skip to content
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

Merged
merged 22 commits into from
Apr 30, 2021
Merged

Document APIv9. #2855

merged 22 commits into from
Apr 30, 2021

Conversation

ajpalkovic
Copy link
Contributor

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.

@queer queer mentioned this pull request Apr 28, 2021
@HamoodiHajjiri

This comment has been minimized.

@i0bs

This comment has been minimized.

docs/topics/Threads.md Outdated Show resolved Hide resolved
@discord discord deleted a comment from flav-code Apr 28, 2021
@discord discord deleted a comment from Zet0x0 Apr 28, 2021
@discord discord deleted a comment from joseywoermann Apr 28, 2021
docs/topics/Permissions.md Outdated Show resolved Hide resolved
@xSke
Copy link

xSke commented Apr 28, 2021

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.

docs/topics/Gateway.md Outdated Show resolved Hide resolved
@discord discord locked as too heated and limited conversation to collaborators Apr 28, 2021
@devsnek
Copy link
Contributor

devsnek commented Apr 28, 2021

Locking for a bit... will unlock when things cool off.

@FedorLap2006
Copy link
Contributor

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.

As far as I understood there will be, they're having some sort of allowlist for that. Hoping to get there :)

Copy link
Contributor

@A5rocks A5rocks left a 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...

docs/Change_Log.md Show resolved Hide resolved
docs/Reference.md Show resolved Hide resolved

###### Channel Types

> warn
> Type 10, 11 and 12 are only available in API v9.
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Comment on lines 31 to 32
| 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 |
Copy link
Contributor

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...)

Copy link
Contributor Author

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.

Comment on lines +218 to +220
"archived": false,
"archiver_id": "41771983423143937",
Copy link
Contributor

@A5rocks A5rocks Apr 28, 2021

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)

Copy link
Contributor Author

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.
Copy link
Contributor

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...)

Copy link
Contributor

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?

docs/resources/Channel.md Outdated Show resolved Hide resolved
docs/resources/Channel.md Outdated Show resolved Hide resolved
docs/topics/Gateway.md Outdated Show resolved Hide resolved

#### Thread List Sync

Sent when the current user _gains_ access to a channel.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's listed below :)

@Lulalaby
Copy link
Contributor

Good work!

docs/resources/Channel.md Outdated Show resolved Hide resolved
docs/topics/Permissions.md Outdated Show resolved Hide resolved
@@ -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 |
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, only in Guilds

docs/resources/Channel.md Outdated Show resolved Hide resolved
docs/resources/Channel.md Show resolved Hide resolved
docs/resources/Channel.md Show resolved Hide resolved
docs/resources/Channel.md Outdated Show resolved Hide resolved
- 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.
Copy link
Member

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?

Copy link
Contributor Author

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!

| 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 |
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

| 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 |
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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!

docs/topics/Opcodes_and_Status_Codes.md Outdated Show resolved Hide resolved

### 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.
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link

@sayantan300 sayantan300 left a 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 👏

@ajpalkovic
Copy link
Contributor Author

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.

@ajpalkovic ajpalkovic merged commit 478af37 into master Apr 30, 2021
@ajpalkovic ajpalkovic deleted the threads branch April 30, 2021 23:23
Cryptex-github added a commit to Cryptex-github/discord-api-docs that referenced this pull request May 1, 2021
@Aericio
Copy link

Aericio commented May 1, 2021

@ajpalkovic hope it's okay to comment here, just found an inconsistency.

Start Public Thread
Start a private thread

image

Probably Start Private Thread instead?

Copy link

@benkaday3218 benkaday3218 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave the user

Copy link

@Assassin-1234 Assassin-1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyped 🔥

@ghost
Copy link

ghost commented May 14, 2021

hyped 🔥

yup

7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jun 5, 2021
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.
7596ff pushed a commit to 7596ff/twilight that referenced this pull request Jun 27, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jun 29, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jun 29, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jul 1, 2021
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.
arqunis pushed a commit to serenity-rs/serenity that referenced this pull request Jul 4, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jul 4, 2021
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.
HarmoGlace added a commit to HarmoGlace/serenity that referenced this pull request Jul 4, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jul 20, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jul 20, 2021
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.
7596ff pushed a commit to twilight-rs/twilight that referenced this pull request Jul 21, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet