Skip to content
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

Global and Local Inheritance #11

Merged
merged 6 commits into from
Jan 20, 2023
Merged

Conversation

ShindouMihou
Copy link
Owner

Adds support for global and local inheritance which will help reduce code duplication by enabling commands to inherit properties from a parent, for example, when you want all commands to be disabled in private messages then you can just write up a global command properties such as:

object GlobalCommandProperties {
   val enabledInDms = false;
}

And add the following line to your configuration:

Nexus.configure {
    this.global.inheritance = GlobalCommandProperties
}

All commands should then inherit the enabledInDms property.

This also includes support for @Share properties which will allow interceptors (middlewares, afterware) to be able to access the property. You can also write up the inheritance to only a specific command by including the @Inherits annotation, such as example:

@Inherits(GlobalCommandProperties::class)
object SomeCommand {
   val name = "ping"
   val description = "Hello"

   fun onEvent(event: NexusCommandEvent) {}
}

It should make the command disabled for private messages as well.

@ShindouMihou ShindouMihou self-assigned this Jan 20, 2023
@ShindouMihou ShindouMihou merged commit 0db39d1 into 1.0.0-beta Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant