简体   繁体   中英

There is a problem in my code on line 5 stating “Missing '()' invoking a constructor” and i don't know how to debug that

var Discord = require('discord.io');
var logger = require('nugget#2115');
var auth = require('./auth.json');
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
    colorize: true
});
logger.level = 'debug';
var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});
bot.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0];

        args = args.splice(1);
        switch(cmd) {
            case 'ping':
                bot.sendMessage({
                    to: channelID,
                    message: 'Pong!'
                });
            break;
        }
     }
});

The rest of the code has no errors apart from Line 5: "Missing '()' invoking a constructor" I've tried adding '()' but they just won't work.

Just a guess, your code says new logger.transports.Console . That's a constructor invocation with new but without the parantheses.

Change it to: new logger.transports.Console()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM