shipgirlproject / Shoukaku

A stable, powerful and updated wrapper around Lavalink
https://guide.shoukaku.shipgirl.moe/
MIT License
274 stars 84 forks source link

TypeError: ShoukakuRest is not a constructor #14

Closed nik9play closed 4 years ago

nik9play commented 4 years ago

Following code

const { Client } = require('discord.js')
const { Shoukaku, ShoukakuRest } = require('shoukaku')
const client = new Client()
const LavalinkServer = [{ name: 'Localhost', host: 'localhost', port: 2333, auth: 'pass' }]
const ShoukakuOptions = { moveOnDisconnect: false, resumable: false, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 }
const shoukaku = new Shoukaku(client, LavalinkServer, ShoukakuOptions)
const rest = new ShoukakuRest("localhost", 2333, "pass", 10000)

client.login("token")

throws an error:

const rest = new ShoukakuRest("127.0.0.1", 2333, "youshallnotpass", 10000)
             ^

TypeError: ShoukakuRest is not a constructor
    at Object.<anonymous> (C:\Projects\test ds bot\index.js:11:14)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Why? Shoukaku 1.4.2 and discordjs 12.2.0

harusame3144 commented 4 years ago

As far as i know ShoukakuRest is internal constructor, you can use ShoukakuSocket#rest

Example Code (Modification of your issue's code)

const { Client } = require('discord.js')
const { Shoukaku, ShoukakuRest } = require('shoukaku')
const client = new Client()
const LavalinkServer = [{ name: 'Localhost', host: 'localhost', port: 2333, auth: 'pass' }]
const ShoukakuOptions = { moveOnDisconnect: false, resumable: false, resumableTimeout: 30, reconnectTries: 2, restTimeout: 10000 }
const shoukaku = new Shoukaku(client, LavalinkServer, ShoukakuOptions)
const rest = shoukaku.nodes.get('Localhost').rest

client.login("token")
nik9play commented 4 years ago

Thanks!