mineral-dart / core

🧡 The neuralgic heart of the application, this module gathers all the functionalities of the framework.
https://mineral-foundation.org
MIT License
27 stars 8 forks source link

Implement slash commands domain #156

Closed LeadcodeDev closed 4 months ago

LeadcodeDev commented 4 months ago

Context

Slash commands are a mainstay of Discord. The principle of slash commands is to combine the actions of a user to interact with other users or with themselves only.

Proposal

Image

The websocket will interact with mineral core to have an event queue, find the final developer handle and use it. The principal actor are the websocket for receiving interaction create event, and the api for send the result

Code

final class MyComand implements ServerCommand {
  Future<void> handle(CommandContext ctx, { required String str }) async {
    ctx.reply(content: str);

    ctx.metadata.name;
    ctx.metadata.description;    
  }
}

// domain

final Function handler;

Function.call(handler, [ctx], { 'str': 'Hello World' });