Merge pull request #131 from DjDeveloperr/refactor

fix: Command.onError
This commit is contained in:
DjDeveloper 2021-04-17 13:12:37 +05:30 committed by GitHub
commit 8d08378413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -362,9 +362,11 @@ export class CommandClient extends Client implements CommandClientOptions {
const result = await command.execute(ctx)
await command.afterExecute(ctx, result)
} catch (e) {
await command
.onError(ctx, e)
.catch((e: Error) => this.emit('commandError', ctx, e))
try {
await command.onError(ctx, e)
} catch (e) {
this.emit('commandError', ctx, e)
}
this.emit('commandError', ctx, e)
}
}