Skip to content

fix: propagate parent module attributes to child commands#3258

Merged
Misha-133 merged 1 commit into
discord-net:devfrom
Sim-hu:fix/nested-attribute-inheritance
May 4, 2026
Merged

fix: propagate parent module attributes to child commands#3258
Misha-133 merged 1 commit into
discord-net:devfrom
Sim-hu:fix/nested-attribute-inheritance

Conversation

@Sim-hu

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

Copy link
Copy Markdown
Contributor

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.
@Misha-133 Misha-133 requested a review from Cenngo April 20, 2026 08:47
@Misha-133 Misha-133 merged commit cbc61d9 into discord-net:dev May 4, 2026
2 checks passed
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

3 participants