-
-
Notifications
You must be signed in to change notification settings - Fork 737
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
Use GetMethods instead of DeclaredMethods to allow for inherited commands #1521
Merged
Conversation
This file contains 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
foxbot
approved these changes
Jun 18, 2020
Thanks! |
SubZero0
pushed a commit
that referenced
this pull request
Feb 10, 2021
Fix breaking change introduced by #1521
SubZero0
added a commit
to SubZero0/Discord.Net
that referenced
this pull request
Feb 11, 2021
* fix: limit request members batch size Discord is actually enforcing v8 limits on v6 according to discord/discord-api-docs#2184 * fix: Missing AddReactions permission for DM channels. (discord-net#1244) Co-authored-by: Samuel <33796679+Samrux@users.noreply.github.com> * fix: GuildEmbed.ChannelId as nullable per API documentation (discord-net#1532) * (ifcbrk) feature: Add includeRoleIds to PruneUsersAsync (discord-net#1581) * Implemented include_roles for guilds/id/prune get&post * Unnecessary using Co-authored-by: Paulo <pnmanjos@hotmail.com> * feature: Add "View Guild Insights" to GuildPermission (discord-net#1619) * feature: Add "View Guild Insights" permission * Add missing summary Co-authored-by: Paulo <pnmanjos@hotmail.com> * fix: Audio stream dispose (discord-net#1667) * Fix audio dispose * Missed a few * feature: Add INVITE_CREATE and INVITE_DELETE events (discord-net#1491) * Add invite events (create and delete) * Removed unused using * Fixing IInviteMetadata properties * Add two new fields to the gateway event * Better event summary and remarks * Change how to assign to target variable Co-Authored-By: Joe4evr <jii.geugten@gmail.com> * Applying suggested changes to TargetUserType * Renaming NotDefined to Undefined * Fixing xml docs * Changed the summary style format Co-authored-by: Joe4evr <jii.geugten@gmail.com> * feature: Add missing application properties (including Teams) (discord-net#1604) * Add missing application properties Add IsBotPublic, BotRequiresCodeGrant, and Team properties to IApplication * To immutable list * Change list to array * feature: Add GetStreams to AudioClient (discord-net#1588) * Added GetStreams * Change return type * Change return type on the interface Co-authored-by: Paulo <pnmanjos@hotmail.com> * fix: Crosspost throwing InvalidOperationException (discord-net#1671) * Add INewsChannel * Renaming variable to match the new type * fix: Discord sends null when there's no team * fix: Team is nullable, not optional (discord-net#1672) * misc: Change ratelimit messages (discord-net#1678) * misc: Missing summary tag * fix: Emoji url encode (discord-net#1681) * feature: Add missing properties to Guild and deprecate GuildEmbed (discord-net#1573) * Add missing properties to Guild, related methods, and deprecate GuildEmbed endpoints - Add missing guild properties: `discovery_splash`, `widget_enabled`, `widget_channel_id`, `rules_channel_id`, `max_presences`, `max_presences`, `max_members`, `public_updates_channel_id`, `max_video_channel_users`, `approximate_member_count`, `approximate_presence_count` - Update guild properties: `embed_enabled`, `embed_channel_id` - Add `GetGuildDiscoverySplashUrl` to `CDN` - Add classes related to the guild widget - Add `withCounts` parameter to `GetGuild(s)Async` - Make GuildEmbed related methods obsolete with a message redirecting to widget ones * Change xml docs and PremiumSubscriptionCount type * Changed some xml docs * fix: Revert PremiumSubscriptionCount type (discord-net#1686) * feature: Implement gateway ratelimit (discord-net#1537) * Implement gateway ratelimit * Remove unused code * Share WebSocketRequestQueue between clients * Add global limit and a way to change gateway limits * Refactoring variable to fit lib standards * Update xml docs * Update xml docs * Move warning to remarks * Remove specific RequestQueue for WebSocket and other changes The only account limit is for identify that is dealt in a different way (exclusive semaphore), so websocket queues can be shared with REST and don't need to be shared between clients anymore. Also added the ratelimit for presence updates. * Add summary to IdentifySemaphoreName * Fix spacing * Add max_concurrency and other fixes - Add session_start_limit to GetBotGatewayResponse - Add GetBotGatewayAsync to IDiscordClient - Add master/slave semaphores to enable concurrency - Not store semaphore name as static - Clone GatewayLimits when cloning the Config * Add missing RequestQueue parameter and wrong nullable * Add RequeueQueue paramater to Webhook * Better xml documentation * Remove GatewayLimits class and other changes - Remove GatewayLimits - Transfer a few properties to DiscordSocketConfig - Remove unnecessary usings * Remove unnecessary using and wording * Remove more unnecessary usings * Change named Semaphores to SemaphoreSlim * Remove unused using * Update branch * Fix merge conflicts and update to new ratelimit * Fixing merge, ignore limit for heartbeat, and dispose * Missed one place and better xml docs. * Wait identify before opening the connection * Only request identify ticket when needed * Move identify control to sharded client * Better description for IdentifyMaxConcurrency * Add lock to InvalidSession * feature: Send presence on Identify payload (discord-net#1688) * Send presence on identify * Change CurrentUser presence * feature: Add inline replies (discord-net#1659) * Add inline replies * Missed a few things * Change xml docs, IUserMessage, and other changes * Missed one when changing * Fix referencedMessage author * fix: Possible NullReferenceException when receiving InvalidSession (discord-net#1695) * fix: UserMentions throwing NullRef * fix: Wrong author for SocketUserMessage.ReferencedMessage * fix: Rollback Activities to Game (discord-net#1702) * docs: Update summary of SocketVoiceChannel.Users (discord-net#1714) The inherited summary incorrectly stated that all users who _see_ the channel are returned when in reality only the ones _connected_ are. * feature: Add max bitrate value to SocketGuild * Update SocketGuild.cs * Fix returns value docs Signed-off-by: Still Hsu <dev@stillu.cc> Co-authored-by: Still Hsu <dev@stillu.cc> * fix: SocketGuild.HasAllMembers is false if a user left a guild (discord-net#1683) * Fix: HasAllMembers is false if a user left * Fix: Correct boolean logic * Add new method of role ID copy Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com> * Add missing asset Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com> * Resolve inheritdocs warning * Move bulk deletes remarks from <summary> to <remarks> * Mark null as a specific langword in summary * Cleanup GatewayReconnectException docs * Update Docfx.Plugins.LastModified to v1.2.4 Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com> * Add updated libraries for LastModified Signed-off-by: Still Hsu <5843208+Still34@users.noreply.github.com> * Update project link * Add initial StyleCops style enforcement * Update framework version for tests to Core 3.1 to comply with LTS * docs: Fix MaxWaitBetweenGuildAvailablesBeforeReady docs string Signed-off-by: Still Hsu <dev@stillu.cc> * docs: Add minor tweaks to DiscordSocketConfig docs strings * docs: Fix the missing "In This Article" section * Temporarily disable StyleCops until all the fixes are impl'd * fix: Invite and InviteMetadata properties (discord-net#1639) * fixes discord-net#1495 * keep obsolete properties and return types for compatibility * missing properties for SocketInvite * Restore xml docs and change obsolete message Co-authored-by: Paulo <pnmanjos@hotmail.com> * docs: Add alternative documentation link * fix: IMessage.Embeds docs remarks * fix: Move and fix internal AllowedMentions object (discord-net#1727) * misc: VoiceRegions and related changes (discord-net#1720) * feature: Add role tags (discord-net#1721) * feature: Add user public flags (discord-net#1722) * feature: Add MessageFlags and AllowedMentions to message modify (discord-net#1724) * feature: Add MessageFlags and AllowedMentions to Modify * Change exception message * feature: Add GuildUser IsPending property (discord-net#1731) * Implemented Pending property * Implemented changes * fix: Missing MessageReference when sending files * meta: 2.3.0 * meta: Bump version to 2.3.1-dev * fix: Deadlock in DiscordShardedClient when Ready is never received (discord-net#1761) * fixed a deadlock in DiscordShardedClient during a failed Identify due to InvalidSession * fixed log * Don't wait ready before releasing semaphore Co-authored-by: Paulo <pnmanjos@hotmail.com> * fix: Private methods aren't added as commands (discord-net#1773) Fix breaking change introduced by discord-net#1521 Co-authored-by: Samuel <33796679+orchidalloy@users.noreply.github.com> Co-authored-by: Samuel <33796679+Samrux@users.noreply.github.com> Co-authored-by: Matt Smith <me@mattthedev.codes> Co-authored-by: Radka Gustavsson <radka.janek@redhat.com> Co-authored-by: bakabaka.bunbun <54648150+bakabun@users.noreply.github.com> Co-authored-by: Joe4evr <jii.geugten@gmail.com> Co-authored-by: Jack Fox <0xdeadbeef1@gmail.com> Co-authored-by: Joel Liechti <52202086+Joelius300@users.noreply.github.com> Co-authored-by: vrachv <52053491+vrachv@users.noreply.github.com> Co-authored-by: Still Hsu <dev@stillu.cc> Co-authored-by: Daniel Baynton <49287178+230Daniel@users.noreply.github.com> Co-authored-by: Still Hsu <5843208+Still34@users.noreply.github.com> Co-authored-by: Fyers <Fyers@web.de> Co-authored-by: quinchs <49576606+quinchs@users.noreply.github.com> Co-authored-by: Yeba <31899118+yebafan@users.noreply.github.com> Co-authored-by: Antonio Zdravkov Nikolov <antonioznikolov@gmail.com>
This was referenced Mar 11, 2021
anonymousheadless
pushed a commit
to anonymousheadless/Discord.Net
that referenced
this pull request
Mar 29, 2021
anonymousheadless
pushed a commit
to anonymousheadless/Discord.Net
that referenced
this pull request
Mar 29, 2021
Fix breaking change introduced by discord-net#1521
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.
Summary
This change allows modules to inherit Commands, as currently there is no easy way to do this.
It makes a lot of logical sense for this to happen, as classes can be inherited, and most modules are classes. It also means you have to write less code in some cases, which is always nice.
Changes
Using the GetMethods method instead of the DeclaredMethods property when getting all methods within a module. This includes inherited members.
Issues
Very slightly impacts performance of
ModuleClassBuilder
, as built in methodsToString
,GetHashCode
,GetType
andEquals
are also included withGetMethods
and have to be checked. But unless you have thousands of modules this will likely not be an issue.Improvements
Some sort of
[InheritCommandsAttribute(bool)]
could be added, but it doesn't seem necessary.Example use case
My use case is adding CRUD methods to a database. Instead of having to create each of these methods for every entity I add to the database, I can have just one abstract module that I inherit for every entity, significantly reducing the amount of work I need to do.