owengombas / discord.ts

🤖 Create your discord bot by using TypeScript and decorators!
https://owencalvin.github.io/discord.ts/
325 stars 40 forks source link

@Command breaks @On('message') #11

Closed sk-1982 closed 4 years ago

sk-1982 commented 4 years ago

Version 4.0.6 Adding a message event listener works as expected:

@Discord('<')
export abstract class AppDiscord {
  @On("message")
  private async onMessage(
    [message]: ArgsOf<"message">,
    client: Client
  ) {
    console.log(message.content);
  }
}

But when a Command is defined, all message event listeners break

@Discord('<')
export abstract class AppDiscord {
  @On("message")
  private async onMessage(
    [message]: ArgsOf<"message">,
    client: Client
  ) {
    console.log(message.content);
  }

  @Command('command')
  private async command(message: CommandMessage, client: Client) {
      console.log('command');
  }
}

Expected: message.content and 'command' logged when <command typed in chat and message.content logged for other messages Actual: onMessage is never called and message.content is never logged

The command doesn't need to be defined in the same class; @Command annotations anywhere immediately break all other @On('message') annotations in the project.

owengombas commented 4 years ago

Thank's for reporting the issue, I'm working on it, It will be fixed very soon ! (You can join the Discord server to follow the process)

owengombas commented 4 years ago

Fixed (v4.0.7) ! You can run npm upgrade Thank's for you contribution