Jellotin
Jellotin

Reputation: 9

How do I fix my Discord bot being offline?

I got recently interested in discord bots coding and I don't know what the problem is with this error, I tried different solutions I can find but all of them are not working and my bot is still offline on the server.

Error: Invalid transport, must be an object with a log method.
  at new LegacyTransportStream (C:\Users\redacted\Desktop\NinyaBot\node_modules\winston-transport\legacy.js:18:11)
  at DerivedLogger.add (C:\Users\redacted\Desktop\NinyaBot\node_modules\winston\lib\winston\logger.js:345:11)
  at Object.winston.<computed> [as add] (C:\Users\redacted\Desktop\NinyaBot\node_modules\winston\lib\winston.js:110:68)
  at Object.<anonymous> (C:\Users\redacted\Desktop\NinyaBot\bot.js:6:8)
  at Module._compile (internal/modules/cjs/loader.js:1133:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
  at Module.load (internal/modules/cjs/loader.js:977:32)
  at Function.Module._load (internal/modules/cjs/loader.js:877:14)
  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
  at internal/main/run_main_module.js:18:47

Upvotes: 0

Views: 16711

Answers (2)

Behemoth
Behemoth

Reputation: 9370

I recommend using discord.js https://discordjs.guide/creating-your-bot/#creating-the-bot-file Use this code and it works just fine:

const Discord = require('discord.js');
const client = new Discord.Client();

client.once('ready', () => {
    console.log('Ready!');
});

client.login('your-token-goes-here');

Upvotes: 0

ibsenleo
ibsenleo

Reputation: 140

The error showed in console is about line 6, however maybe is not what makes the bot appears offline.

logger.add(logger.transports.Console, {
    colorize: true
});

And should be fixed with something like

logger.add(new logger.transports.Console({
    format: winston.format.combine(
        winston.format.colorize(),
        winston.format.simple()
    )
}));

Watch to new word. Now transports require a new object to work and for colorize you can set it combining the formats.

Here you can find more info about it https://www.npmjs.com/package/winston#common-transport-options

Upvotes: 1

Related Questions