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

Application Refactor #5

Merged
merged 3 commits into from
Apr 8, 2024
Merged

Application Refactor #5

merged 3 commits into from
Apr 8, 2024

Conversation

lcox74
Copy link
Contributor

@lcox74 lcox74 commented Apr 8, 2024

The configuration and management of Applications and Application Rules were previously complex and somewhat cumbersome for feature development. Additionally, it was burdensome to have to code all application callbacks, even when they were not needed (NOP).

To simplify this process, we've reorganized all Application types under the applications directory. The specific application type is now determined by what is returned in the app.GetType() AppType function. The application types are as follows:

// AppTypeNOP is a command that does nothing and is used as a
// routing placeholder for parent containers for their sub applications.
framework.AppTypeNOP

// AppTypeCommand is an discord application command that is executed by a
// user and handled by the OnCommand() handler. You will also need to implement
// the GetDefinition() method to return the discordgo.ApplicationCommand
// definition for the command
framework.AppTypeCommand
    Implement: OnCommand(ctx framework.CommandContext)
               GetDefinition() *discordgo.ApplicationCommand

// AppTypeCommand is an discord application command that is executed by a
// user and handled by the OnCommand() handler
framework.AppTypeSubCommand
    Implement: OnCommand(ctx framework.CommandContext)

// AppTypeEvent is an event based application which handles user
// interactions with the OnEvent() handler
// message components or modals
framework.AppTypeEvent
    Implement: OnEvent(ctx framework.EventContext, eventType discordgo.InteractionType)

// AppTypeMessage is an application which runs on messages, handled by the
// OnMessage() handler
framework.AppTypeMessage
    Implement: OnMessage(ctx framework.MessageContext)

// AppTypeReaction is an application which runs on reactions, handled by the
// OnReaction() handler
framework.AppTypeReaction
    Implement: OnReaction(ctx framework.ReactionContext)

// AppTypeMountable is an application which requires something to run when the
// application is mounted after the discord session is made. Handled by the
// OnMount() handler
framework.AppTypeMountable
    Implement: OnMount(ctx framework.MountContext)

Application types can be mixed to suit your application's needs using the | operator, except for the combination of AppTypeCommand | AppTypeSubCommand, as command structures and routing are specifically managed to avoid issues with the Discord API.

For guidance on how to use these types and integrate applications effectively, refer to the examples provided with the currently implemented applications.

@lcox74 lcox74 merged commit 039b491 into main Apr 8, 2024
@lcox74 lcox74 deleted the application_rework branch April 8, 2024 01:41
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.

1 participant