NanderTGA / msgroom-orm

A MsgRoom client.
https://nandertga.github.io/msgroom-orm/
MIT License
4 stars 0 forks source link

Command metadata #12

Closed NanderTGA closed 1 year ago

NanderTGA commented 1 year ago

We need some way to be able to tell users more about a command. My current idea is to put an object where you'd put a function (command handler) now. This object can contain aliases for a command, the handler and a description. The way to detect this is simple: from the moment a property called handler is defined, it's considered a command. I think we should also provide a class the user can instantiate for better code readability.

mybearworld commented 1 year ago

Possibly, as a spin on the current Nightly msgroom:

client.commands.ping = new Command(
  {
    description: "Lorem ipsum dolor sit amet",
    aliases: [],
    created: "2023-07-03", // for example
    // ... etc ...
  },
  () => {
    return "Pong";
  }
)
NanderTGA commented 1 year ago

Interesting. On one side this is the solution because I wouldn't need to worry about breaking changes, but on another side this feels weird since the command class is actually just a utility class incase you don't want to take the other approach, which looks like this:

client.commands.ping = {
  description: "Lorem ipsum dolor sit amet",
  aliases: [],
  handler: () => "Pong",
}

This feels weird because it would look a lot like that approach, and I might as well remove the Command class then, since it would only make a small difference. Combine this with the import issue and the Command class doesn't seem worth it anymore for me. Do we keep it or remove it?

mybearworld commented 1 year ago

Removing it does seem like the best way to go, as it would just lead to your code breaking everytime an update occurs.

msgroom-js-semantic-release[bot] commented 9 months ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: