Closed
Conversation
…ame templates due to overloading bug (`Webhook.edit()` -> `Webhook.editWebhook()`)
…e templates due to overloading bug (`Guild.edit()` -> `Guild.editGuild()`; `Guild.edit(GuildScheduledEvent)` -> `Guild.editGSE()`
…mand.editAC()` due to template overloading bug
…Client` is now a no-op.
…edit()` -> `Interaction.editInteraction()`; `GuildChannel.edit()` -> `GuildChannel.editChannel()`
Contributor
Author
|
Oops, didnt update the examples. I'll patch them |
91 tasks
Contributor
|
follow-up: #133 |
Owner
|
closing the pull request since theres a followup |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
implementation fixes
Some helpers were preventing code to compile because of bad implementation causing compiler errors. Those were fixed in this PR.
template renaming
Some helpers have been renamed because of overloading too much which was especially the case of the
editidentifier which confused the compiler sometimes.getClientandmainClientIn some Nim versions, users may encounter "client not found" or "client not registered" errors due to compiler bugs that have now been resolved. As a result, this feature works on recent versions of the compiler but not on older ones.
mainClientis now a no-op. We can reserve it for future versions of the library in case we need it again (reverting to the old behavior or implementing another solution mentioned down below). We can also deprecate it if we decide that it's no longer necessary.getClientnow works by finding the 's' symbol which is always available within event handlers or command handlers like indimscmd. It also checks if the 's' symbol is a Shard in case the user (for some obscure reason) decides to shadow it. This should work fine in older versions since it relies on less complex features of the language.However, this means we can no longer use the helpers outside of event or command handlers, for example after this patch it won't be possible to use helpers with a client that has
rest_mode = truebecause they cannot use event handlers. I decided the fix was worth it because it makes the most common use-cases more reliable.One idea I had to mitigate this problem is to modify
mainClientagain to generate a template that aliases the user's client, allowing us to use the real symbol by callinggetClientwithout relying on the old method again:Example usage:
Future work
Because nim templates are lazy we have to use them so that they are instantiated, the compiler cannot tell us if the template is good otherwise. So a CI/test-suite will follow-up this PR in order to test if they work correctly.