Tomato6966 / lavalink-client

Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.
https://tomato6966.github.io/lavalink-client/
MIT License
48 stars 13 forks source link

error connecting a bot to lavalink server when the bot's name has some special characters #26

Closed ByAhri closed 5 months ago

ByAhri commented 5 months ago

https://github.com/Tomato6966/lavalink-client/blob/3e65b4fa716864fc5d14a747632404efaf6b924d/dist/cjs/structures/Node.js#L225

in this part of the connect function lavalink-client sets the client name for lavalink as the bot's username or a default "Lavalink-Client" string, when the bot has characters not appropriate for the request in the headers it gives error and it won't connect. for me i just remove the part that sets the bot name and only left it as "Lavalink-Client". i referenced the code above and it's also in the esm folder of the source code. it would be nice if it could filter names better before sending the request or something to avoid this issue and not having to modify the package after i install it with npm. it seems a very easy fix i hope it can be done thank u <3

Tomato6966 commented 5 months ago

when providing the username property of the lavalinkclient, you need to ensure it meets the username aka clientname requirements from lavalink Aka no special chars which can't be uri encoded. I don't wanna perform actions on your custom configuration hence the client also works for lavalink forks which may or may not require special chars.

ByAhri commented 4 months ago

Owner

you mean in the manager constructor? because i'm setting the username to "bot" and still getting that error. so what can i do in my end?

client.lava = new LavalinkManager({
            nodes,
            sendToShard: (id, payload) => {
                client.guilds.fetch(id).then(g => g.shard.send(payload)).catch(error => { });
            },
            autoSkip: true,
            client: {
                id: clientId,
                username: "bot"
            },
            playerOptions: {
                clientBasedPositionUpdateInterval: 150,
                defaultSearchPlatform: process.env.ENGINE,
                onDisconnect: {
                    autoReconnect: false,
                    destroyPlayer: true
                }
            }
        });

image

and when i read lavalink console, the client names appears as the bot username instead of the one specified in lavalink manager (this is an extra bot with a valid username for testing) image