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

feat(ForumChannels): Support Forum Channels #1452

Merged
merged 85 commits into from
Feb 7, 2024

Conversation

conorwastakenwastaken
Copy link
Contributor

@conorwastakenwastaken conorwastakenwastaken commented Apr 26, 2023

Support Forum Channels (finally)

To do:

  • Add missing ForumChannel functions/properties
  • Add createThread function to client
  • Update existing createThread functions/docs to match Discords documentation (the current function is missing some properties)
  • Update THREAD_UPDATE event with newer properties
  • Typings

Additions:

  • ForumChannel structure
  • Ability to create/update forum channels. Added all Create Channel & Modify Channel JSON params to the relevant functions
  • Client#createThread function. This is basically the same as Client#createThreadWithoutMessage(), but with forum channel options (to send a message into the newly created thread). This function is also callable from the TextChannel and ForumChannel structures
  • ChannelFlags (supports PINNED (type 2, thread channels only) & REQUIRE_TAG (type 16, forum channels only))
  • appliedTags & flags properties to the old thread channel whenever a thread gets updated. Discord gives you the ability to change both of these options
  • totalMessagesSent prop to ThreadChannel struct
  • appliedTags prop to ThreadChannel struct
  • options.rateLimitPerUser args to all functions which create threads
  • options.reason args to all functions which create threads
  • options.autoArchiveDuration is now optional in all functions which create threads

Deprecations:

This PR deprecates the createThreadWithoutMessage function in favour of createThread. Both functions use the same endpoint which expects the same payload. If you use createThread on a normal channel rather than a forum channel, you can supply the type option to choose what type of thread you want to create. Using createThread on a forum channel will create a public thread regardless. I'm going to make this more obvious in the docs.

I'm open to feedback if anyone disagrees with me and thinks we should keep both functions 🤷

@AirplanegoBrr
Copy link

ETA? Would be epic to have this!

@conorwastakenwastaken
Copy link
Contributor Author

ETA? Would be epic to have this!

No ETA

@bsian03 bsian03 linked an issue Jan 10, 2024 that may be closed by this pull request
@conorwastakenwastaken conorwastakenwastaken mentioned this pull request Jan 16, 2024
32 tasks
* Makes `[options.autoArchiveDuration]` optional
* Adds `[options.rateLimitPerUser]`
* Adds `[options.reason]`

Adds all of the above to `createThreadWithMessage` and `createThreadWithoutMessage` across all structures and the Client

* Specifies that `[options.type]` wont always be optional within `createThreadWithoutMessage`
* Document that `createThreadWithoutMessage` can return `NewsThreadChannel` and `PublicThreadChannel` rather than only `PrivateThreadChannel`, if the developer specifies a thread type
@conorwastakenwastaken
Copy link
Contributor Author

Working on this again. It's still a wip and I'll update the ts docs when Im finished with everything else. Yes I'm aware that some properties/functions are incorrect - I started this when forums first came out and Discord has changed a lot of stuff around since then

@conorwastakenwastaken
Copy link
Contributor Author

Is it worth adding a getter for the channel's threads?

Added, if you change your mind then I can remove it just as easily. Lmk if the way I've done it is okay! It'll list all archived threads too afaik.

Copy link
Collaborator

@bsian03 bsian03 left a comment

Choose a reason for hiding this comment

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

Is it worth adding a getter for the channel's threads?

Added, if you change your mind then I can remove it just as easily. Lmk if the way I've done it is okay! It'll list all archived threads too afaik.

Should be fine. Thread channel data is cached when the following happens:

  • Active accessible threads on connection
  • Bot joins a thread
  • Archived thread which wasn't cached previously becomes active

The only time a thread is removed from cache is when the thread itself gets deleted. If the bot gets removed from the thread or the thread gets archived, the thread will still be cached

lib/Client.js Show resolved Hide resolved
lib/structures/Guild.js Show resolved Hide resolved
lib/structures/TextChannel.js Outdated Show resolved Hide resolved
lib/structures/ThreadChannel.js Outdated Show resolved Hide resolved
lib/structures/ForumChannel.js Outdated Show resolved Hide resolved
lib/gateway/Shard.js Outdated Show resolved Hide resolved
lib/gateway/Shard.js Outdated Show resolved Hide resolved
lib/gateway/Shard.js Outdated Show resolved Hide resolved
lib/structures/Channel.js Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Show resolved Hide resolved
lib/structures/PublicThreadChannel.js Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
index.d.ts Show resolved Hide resolved
lib/Constants.js Show resolved Hide resolved
lib/gateway/Shard.js Show resolved Hide resolved
@bsian03 bsian03 merged commit 6084d6a into abalabahaha:dev Feb 7, 2024
@conorwastakenwastaken conorwastakenwastaken deleted the forum-channels branch July 11, 2024 15:41
CaptainM777 pushed a commit to CaptainM777/eris that referenced this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forum channels
5 participants