Katrix / AckCord

A Discord library for Scala using Akka
https://ackcord.katsstuff.net/
MIT License
114 stars 15 forks source link

[Suggestion?] A Higher-leveled /modular command framework for AckCord #15

Closed vatsman closed 5 years ago

vatsman commented 5 years ago

Other Discord libraries feature command frameworks that provide utilities that abstract over implementation details and/or boilerplate (usually using a decorator, annotation or some kind of off-handing mechanism) for example: [discord.py's commands extension] (https://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html) which provides an easier and cleaner interface with the library.

In AckCord, The ping command is in itself quite verbose.

  def registerParsedCommand[F[_] : Monad : Streamable](commands: CommandsHelper[F]): Unit = {
    commands.registerCmd[NotUsed, Id](
      refiner = CmdInfo[F](prefix = GeneralCommands, aliases = Seq("ping"), filters = Seq(CmdFilter.NonBot, CmdFilter.InGuild)),
      description = Some(CmdDescription("Ping", "Check if the bot is alive"))
    ) { cmd: ParsedCmd[F, NotUsed] =>
      println(s"Received ping command")
    }

where-as using something such as an annotation macro (to avoid the using runtime-reflection) allows the implementation to be quite clean and concise (this is just an example).

@Command(aliases = Seq("ping"), desc = "Check if the bot is alive")
def ping(/* some context parameter */) =
    println("Recieved ping command")

which would generate code similar to the former without any of the verbosity.

I am not experienced in writing libraries that wrap around APIs but I do appreciate the work that is being put on AckCord and do not bear any ill will towards anyone working on the project but it is rather difficult to write all that when using vim/vsc (IntelliJ also has problems resolving methods such as channel#sendMessage) :p

vatsman commented 5 years ago

Oops, looks like I opened up a duplicate. My apologies.