Skip to content

Conversation

@GnomedDev
Copy link
Member

@GnomedDev GnomedDev commented Nov 12, 2024

This fixes #2991, via the solution voted for on the serenity discord.

@github-actions github-actions bot added model Related to the `model` module. builder Related to the `builder` module. cache Related to the `cache`-feature. http Related to the `http` module. utils Related to the `utils` module. gateway Related to the `gateway` module. examples Related to Serenity's examples. labels Nov 12, 2024
@GnomedDev GnomedDev force-pushed the thread-split branch 4 times, most recently from d87a2db to 037c2d6 Compare November 14, 2024 01:23
@GnomedDev GnomedDev force-pushed the thread-split branch 6 times, most recently from 16cc66c to f400ac4 Compare November 17, 2024 21:36
@GnomedDev GnomedDev marked this pull request as ready for review November 17, 2024 21:38
@GnomedDev
Copy link
Member Author

GnomedDev commented Nov 17, 2024

This is ready for review, the main changes are:

  • GuildChannel is now:

    • BaseGuildChannel (shared fields)
    • GuildChannel (channel-exclusive)
    • GuildThread (thread-exclusive)
    • GenericGuildChannelRef (an enum over references to both)
  • PartialChannel is now:

    • BaseInteractionChannel (shared fields)
    • InteractionChannel (channel-exclusive)
    • InteractionThread (thread-exclusive)
    • GenericInteractionChannel (an enum over the both)
  • ChannelId is now:

    • GenericChannelId (shared purpose/methods)
    • ChannelId (channel-exclusive)
    • ThreadId (thread-exclusive)

The IDs have methods to convert between, such as:

  • GenericChannelId::expect_channel and GenericChannelId::expect_thread which casts the ID types without touching the value
  • GenericChannelId::split which calls both and returns both for when something needs to handle both cases
  • ThreadId::widen and Channelid::widen which cast to GenericChannelId for when you have a specific ID and need to "widen" the number of methods you can call.

GenericGuildChannelRef is returned from the new Guild::channel method, which looks the GenericChannelId up in both Guild::channels and Guild::threads.

@arqunis arqunis added enhancement An improvement to Serenity. breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users labels Nov 17, 2024
Copy link
Member

@jamesbt365 jamesbt365 left a comment

Choose a reason for hiding this comment

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

This looks really good, not 100% sure if I like the name changes for PartialChannel, but I can't think of anything better right now so I think its passable.

@peanutbother
Copy link

I also think the naming could be improved since we are explicitly talking about channels and threads.
My proposal in discord was the following:

How about

enum MessageOrigin {
    Channel(ChannelId),
    Thread(ThreadId)
}

seems a better naming to me since I see Threads as their own thing so I would not name a message's origin a channel

In that naming scheme I would name Base* rather Origin* and in some contexts append or prepend Message* or Interaction* accordingly.

@GnomedDev
Copy link
Member Author

@peanutbother I don't fully understand how this "origin" naming improves things? From how I processed that I think you are saying OriginGuildChannel which doesn't make too much sense, and we already have prepended Interaction where possible (as the other types are truly generically used everywhere).

@peanutbother
Copy link

peanutbother commented Nov 19, 2024

I mean something like MessageOrigin and InteractionOrigin as base names instead of the chosen base names as for e.g. threads and channels the base name is still channel.

@GnomedDev GnomedDev merged commit 243c5b2 into serenity-rs:next Apr 12, 2025
24 checks passed
GnomedDev added a commit that referenced this pull request Apr 28, 2025
GnomedDev added a commit that referenced this pull request May 19, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jun 30, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jun 30, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jun 30, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jul 28, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Jul 28, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users builder Related to the `builder` module. cache Related to the `cache`-feature. collector Related to the `collector` module. enhancement An improvement to Serenity. examples Related to Serenity's examples. gateway Related to the `gateway` module. http Related to the `http` module. model Related to the `model` module. utils Related to the `utils` module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants