shipgirlproject/Shoukaku

No nodes

Ascol14 opened this issue · 3 comments

Hello,
I have this problem :

        const nodes = [
            {
                url: 'server.com:80',
                name: '1',
                auth: 'Password',
            }
        ]

        Success(`✅ Bot started: ${client.user.tag}!\n`);
        client.user.setActivity("Nice stream", {type: "STREAMING"});

        client.manager = new Shoukaku(new Connectors.DiscordJS(client), nodes);
        console.log(client.manager)
        client.manager.on('error', (_, error) => console.error(error));

And when I console.log(client.manager) :

  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  connector: DiscordJS {
    client: Client {
      _events: [Object: null prototype],
      _eventsCount: 8,
      _maxListeners: undefined,
      options: [Object],
      rest: [REST],
      ws: [WebSocketManager],
      actions: [ActionsManager],
      voice: [ClientVoiceManager],
      shard: null,
      users: UserManager {},
      guilds: GuildManager {},
      channels: ChannelManager {},
      sweepers: [Sweepers],
      presence: [ClientPresence],
      user: [ClientUser],
      application: [ClientApplication],
      readyTimestamp: 1664711493249,
      commands: [Collection [Map]],
      language: Collection(0) [Map] {},
      buttons: [Collection [Map]],
      modals: Collection(0) [Map] {},
      manager: [Circular *1],
      [Symbol(kCapture)]: true
    },
    manager: [Circular *1]
  },
  options: {
    resume: false,
    resumeKey: 'Shoukaku@3.2.0(https://github.com/Deivu/Shoukaku)',
    resumeTimeout: 30000,
    resumeByLibrary: false,
    alwaysSendResumeKey: false,
    reconnectTries: 3,
    reconnectInterval: 5000,
    restTimeout: 60000,
    moveOnDisconnect: false,
    userAgent: 'shoukakubot/3.2.0 (https://github.com/Deivu/Shoukaku)',
    structures: {}
  },
  nodes: Map(0) {},
  id: null,
  [Symbol(kCapture)]: false
}```

Why I have 0 nodes ?
Thank for anwer.

Ascol57
Deivu commented

Please initialize shoukaku outside your client ready event

Sorry but it don't work :
My main code :

const client = new Client({ intents: 32767 });
const { Shoukaku, Connectors } = require('shoukaku');
const nodes = [
    {
        url: 'srv.server.tk:1265',
        name: '1',
        auth: 'password',
    },
    {
        url: 'srv.server.tk:2026',
        name: '2',
        auth: 'password',
    },
    {
        url: 'play.anotheserver.eu:1265',
        name: '3',
        auth: 'password',
    },
]
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), nodes);
console.log(shoukaku)
// ALWAYS handle error, logging it will do
shoukaku.on('error', (_, error) => console.error(error));

const { BOT_TOKEN } = require("./config.json");
const { Warning, Error, Success } = require("../utils/Logger");
const { promisify } = require("util");
const { glob } = require("glob");
const PG = promisify(glob);
const { AsciiTable3 } = require("ascii-table3");
const { connect } = require('mongoose');

//===========================================================

client.commands = new Collection();
client.language = new Collection();
client.buttons = new Collection();
client.modals = new Collection();

//===========================================================

["Event", "Commands", "Buttons", "Modal"].forEach(handler => {
    require(`./handlers/${handler}`)(client, PG, AsciiTable3);
});

connect('mongodb://srv.server.tk:2044/DB?retryWrites=true&w=majority');

//===========================================================

// Anti-Crash and more...
process.on("unhandledRejection", (reason, p) => { Warning(
    '=== unhandled Rejection ==='.toUpperCase(),
    'Reason: ' + reason.stack ? String(reason.stack) : String(reason),
    '==========================='.toUpperCase());
                                                });

process.on("uncaughtException", (err, origin) => { Error(
    '=== uncaught Exception ==='.toUpperCase(),
    'Exception: ' + err.stack ? err.stack : err,
    '==========================='.toUpperCase());
                                                 });

process.on('uncaughtExceptionMonitor', (err, origin) => { Error(
    '=== uncaught Exception Monitor ==='.toUpperCase());
                                                        });

process.on('beforeExit', (code) => { Warning(
    '======= before Exit ======='.toUpperCase(),
    'Code: ' + code,
    '==========================='.toUpperCase());
                                   });

process.on('warning', (code) => { Warning(
    '========= warning ========='.toUpperCase(),
    'Code: ' + code,
    '==========================='.toUpperCase());
                                });

process.on('exit', (code) => { Warning(
    '========== exit =========='.toUpperCase(), 
    'Code: ' + code,
    '=========================='.toUpperCase());
                             });

process.on('multipleResolves', (type, promise, reason) => { Warning(
    '==== multiple Resolves ===='.toUpperCase(),
    type, promise, reason,
    '==========================='.toUpperCase());
                                                          });

//===========================================================


client.login(BOT_TOKEN).catch(() => {
    Error("[BOT] Invalid Bot Login Token.");
    process.exit();
});

//===========================================================


process.on("SIGINT", () => { 
    Success("SIGINT detected, exiting..."); 
    process.exit(); 
});```

And I have no connect nodes ?
Deivu commented

This is most likely an initialization issue, not really an issue with the library, but on how you start shoukaku. Ask it at our Discord Server instead