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

Simplify commands handlers #1

Closed
l7ssha opened this issue Oct 16, 2018 · 3 comments
Closed

Simplify commands handlers #1

l7ssha opened this issue Oct 16, 2018 · 3 comments

Comments

@l7ssha
Copy link

l7ssha commented Oct 16, 2018

Hi, You can simplify your commands handlers to single method form:

Now:

@command.Module("player")
class PlayerCommand extends command.CommandContext {
  @command.Command(main: true)
  @command.Help("player", usage: "!gb_player playerName")
  Future run(@command.Remainder() String argument) async {
    if (argument == "") {
      return await reply(content: "Merci de préciser un joueur");
    }
    await reply(content: gdp.getGamesForUser(argument));
  }
}

After:

  @command.Command(name: "player")
  @command.Help("player", usage: "!gb_player playerName")
  Future run(command.CommandContext ctx, @command.Remainder() String argument) async {
    if (argument == "") {
      return await ctx.reply(content: "Merci de préciser un joueur");
    }
    await ctx.reply(content: gdp.getGamesForUser(argument));
  }

This is much cleaner than having single command modules.

@Outpox
Copy link
Owner

Outpox commented Oct 16, 2018

Hey, awesome!
I'll update my code once I'm back from work, thanks you for opening this issue and letting me know :D

@Outpox
Copy link
Owner

Outpox commented Oct 16, 2018

@l7ssha
So I've rewrote my code using the new format but it seems that there is a regression in the logs:

[FINE]  {CommandsFramework} - 16.10.2018 18:56:37:436 -- Command [mp] has been registered
[FINE]  {CommandsFramework} - 16.10.2018 18:56:37:438 -- Command [player] has been registered
[FINE]  {CommandsFramework} - 16.10.2018 18:56:37:438 -- Command [update] has been registered
[FINE]  {CommandsFramework} - 16.10.2018 18:56:37:438 -- Command [doodle] has been registered
[FINE]  {CommandsFramework} - 16.10.2018 18:56:37:438 -- Command [game] has been registered
false, true
[INFO]  {Websocket} - 16.10.2018 18:56:38:208 -- Shard [0] connected
[INFO]  {Client} - 16.10.2018 18:56:38:427 -- Connected and ready!
Ready!
[FINE]  {CommandsFramework} - 16.10.2018 18:56:43:30 -- Command [] executed

Command [] executed was logged after I sent !gb_update when with the previous version it properly displayed Command [update] executed.

Do you want me to open a PR on the Nyxx repository?

Outpox added a commit that referenced this issue Oct 16, 2018
@l7ssha
Copy link
Author

l7ssha commented Oct 16, 2018

Sure

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

No branches or pull requests

2 participants