Skip to content

Query string overhaul, add wait=true for webhooks

Mateusz Brawański requested to merge github/fork/uwx/patch-132 into master

Created by: uwx

Summary

This supercedes #440.

Details

I modified Allan's PR and introduced QueryUriBuilder class instead of the dictionary mess. In addition, that dictionary mess was incredibly inconsistent - there were loads of places in the lib where query strings were hardwired. I replaced all these with QueryUriBuilder usages, which for the most part just makes them more readable. It also saves quite a few Dictionary allocations for the webhook endpoints.

The only places where hardcoded query strings still remain are when the library simply returns a link, say, to an image. For instance:

https://github.com/DSharpPlus/DSharpPlus/blob/5d0fc812ed31b5f5cdab0d1c6e6d55057c43f3b4/DSharpPlus/Entities/DiscordGuild.cs#L841-L842

I left these as-is since there are so many of them and they seem to be very purposefully hardcoded. If you want these to use the query URI builder, let me know.

Additionally, I fixed a bug in GetCurrentUserGuildsAsync where the rest ratelimit bucket was dependant on the query parameters. I don't know if the original behavior was intentional, please let me know if so.

I want to hear your opinions, so I'm leaving this PR as a draft for now.

Changes proposed

  • Create QueryUriBuilder
  • Patch up hardcoded query URIs into the nicer, cleaner builder format
  • Make the parameters of GetCurrentUserGuildsAsync not part of the ratelimit bucket

Notes

Credits to @Kiritsu for doing the hard part.

Merge request reports

Loading