Skip to content

fix: propagate parent module attributes to child commands#3258

Open
Sim-hu wants to merge 1 commit intodiscord-net:devfrom
Sim-hu:fix/nested-attribute-inheritance
Open

fix: propagate parent module attributes to child commands#3258
Sim-hu wants to merge 1 commit intodiscord-net:devfrom
Sim-hu:fix/nested-attribute-inheritance

Conversation

@Sim-hu
Copy link
Copy Markdown
Contributor

@Sim-hu Sim-hu commented Mar 24, 2026

Fixes #2875

When attributes like [EnabledInDm(false)] are placed on a parent module class, child commands still allowed DM execution because the module builder never copied these values from the parent.

The internal ModuleBuilder constructor now inherits DefaultPermission, IsEnabledInDm, IsNsfw, DefaultMemberPermissions, ContextTypes, and IntegrationTypes from the parent builder when one is provided. Child modules can still override any of these via their own attributes since BuildModule processes attributes after construction.

When a sub-module is nested inside a parent module, attributes like
EnabledInDm, DefaultPermission, IsNsfw, DefaultMemberPermissions,
ContextTypes, and IntegrationTypes are now inherited from the parent
module builder. Child modules can still override these values with
their own attributes.

Previously, nested modules would always use default values instead
of inheriting from their parent, causing attributes like
EnabledInDm(false) on a parent module to have no effect on commands
within child modules.
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.

[Bug]: Nested attributes are not passed down to commands

1 participant