0

I am building a discord bot in TypeScript, but when i try to run it is failing to run even when the typescript compiler succeeds without errors

This is the error i am getting is

C:\Users\tigog\PhpstormProjects\Jace-DiscordJS\build\commands\utilities\botinfo.js:55
        return _super.call(this, client, {
                      ^

TypeError: Class constructor Command cannot be invoked without 'new'
    at new botinfo (C:\Users\tigog\PhpstormProjects\Jace-DiscordJS\build\commands\utilities\botinfo.js:55:23)
    at CommandRegistry.registerCommands (C:\Users\tigog\PhpstormProjects\Jace-DiscordJS\node_modules\discord.js-commando\src\registry.js:118:48)
    at CommandRegistry.registerCommandsIn (C:\Users\tigog\PhpstormProjects\Jace-DiscordJS\node_modules\discord.js-commando\src\registry.js:173:15)
    at Object.<anonymous> (C:\Users\tigog\PhpstormProjects\Jace-DiscordJS\build\index.js:37:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)

What i have tried so far is putting new in front of the constructor, tried another command (same result).

I think personally that the problem is related in the code written below.

export = class Help extends Commando.Command {
    constructor(client: Commando.CommandoClient) {
        super(client, {
            name: 'help',
            memberName: 'help',
            group: 'utilities',
            description: 'Get the help menu',
            guildOnly: false,
        });
    }

What i was expecting was that the TypeScript compiler would throw a notice or an error or that the JS application would run as per usual.

if you need more code to help me, just ask.

HeroOnSocks
  • 21
  • 1
  • 5
  • 2
    Possible duplicate of [Javascript ES6 TypeError: Class constructor Client cannot be invoked without 'new'](https://stackoverflow.com/questions/51860043/javascript-es6-typeerror-class-constructor-client-cannot-be-invoked-without-ne) – p.s.w.g Apr 15 '19 at 21:45
  • As weird as it would sound your link to the another thread actually helped me. I was using ES5 and switched it to ES6 multiple times. Only to find out nodemon did not like it. – HeroOnSocks Apr 15 '19 at 21:53
  • He posted that link to help you and it did - not weird at all! – Rayee Roded Apr 16 '19 at 00:56

0 Answers0