Skip to content

Bug fix to allow the calls to webhook APIs to succeed when using GuildThread.#351

Open
AraHaan wants to merge 3 commits into
NetCordDev:alphafrom
AraHaan:fixes/fix-guild-thread-webhook-api-calls
Open

Bug fix to allow the calls to webhook APIs to succeed when using GuildThread.#351
AraHaan wants to merge 3 commits into
NetCordDev:alphafrom
AraHaan:fixes/fix-guild-thread-webhook-api-calls

Conversation

@AraHaan
Copy link
Copy Markdown

@AraHaan AraHaan commented May 26, 2026

This fixes a bug where when using classes based on GuildThread (ones that most likely inherits from it), because GuildThread inherits from TextGuildChannel the inherited CreateWebhookAsync and the GetChannelWebhooksAsync methods would pass in only the Id (which for normal channels works), but for threads this would always fail as the thread Id would be used as a channel Id and Discord's API does not consider them to be valid channels. As such it is better to attempt to use ParentId (if not null), otherwise use Id (if ParentId is null).

…dThread.

This fixes a bug where when using classes based on GuildThread (ones
that most likely inherits from it), because GuildThread inherits from
TextGuildChannel the inherited CreateWebhookAsync and the
GetChannelWebhooksAsync methods would pass in only the Id (which for
normal channels works), but for threads this would always fail as the
thread Id would be used as a channel Id and Discord's API does not
consider them to be valid channels. As such it is better to attempt
to use ParentId (if not null), otherwise use Id (if ParentId is null).

Signed-off-by: AraHaan <seandhunt_7@yahoo.com>
Comment thread NetCord/Rest/RestClient.Webhook.cs Outdated
@KubaZ2
Copy link
Copy Markdown
Member

KubaZ2 commented May 26, 2026

That is more like a Discord API quirk and I am not sure invoking these methods for the thread parent is a good idea. It introduces a confusing behavior and moves logic to autogenerated methods.

@jedrek0429
Copy link
Copy Markdown

Well, maybe this method simply shouldn't exist on channels where it would always return 404 and instead of introducing logic for passing the parent ID within NetCord, the developer can decide on what to do (notice the method doesn't exist and use it explicitly on the parent channel).

@KubaZ2
Copy link
Copy Markdown
Member

KubaZ2 commented May 26, 2026

Well, maybe this method simply shouldn't exist on channels where it would always return 404 and instead of introducing logic for passing the parent ID within NetCord, the developer can decide on what to do (notice the method doesn't exist and use it explicitly on the parent channel).

Since GuildThread is TextGuildChannel, it is not possible for it not to have these methods. Of course it would be possible to introduce some different structure but there are so many cases that I doubt it would make sense, but maybe? Also there are always methods that will fail in some cases, for example channel modification requires a certain permission, an 404 error for a specific channel type is not an real issue but I agree it would be better if it didn't happen.

A few years ago I had an idea of flattening the channel structure into just something like

class Channel;
class GuildChannel : Channel;

I think it would make the structure clearer but at the same time it would introduce lots of null/useless property values and basically every channel would have all possible channel-related methods so it would only make this issue worse.

AraHaan added 2 commits May 26, 2026 14:09
…l untouched.

Instead we hjide them by generating these methods in GuildThread.
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.

3 participants