#No Sound from Bot

1 messages · Page 1 of 1 (latest)

quiet iris
#
    handleMessage(message) {

        console.log(message.op)
        switch (message.op) {
            case 'event':
                this.emit(message.type, message);
                break;
                case 'playerUpdate':
                console.log(message)
                this.emit('playerUpdate', message);
                break;
            case 'stats':
                this.emit('stats', message);
                break;
            case 'ready':
                this.emit('ready', message);
                this.sessionId = message.sessionId;
                break;
            default:
                console.warn('Unhandled operation:', message.op);
        }
    }

    handleRaw(packet) {
        if (packet.t === 'VOICE_STATE_UPDATE' && packet.d.user_id === this.client.user.id) {
            const player = this.players.get(packet.d.guild_id);
            if (player) player.updateVoiceState(packet.d);
        } else if (packet.t === 'VOICE_SERVER_UPDATE' && packet.d.user_id === this.client.user.id) {
            const player = this.players.get(packet.d.guild_id);
            if (player) player.updateVoiceServer(packet.d);
        }
    }

    createPlayer(guildId, voiceChannelId) {
        const player = new Player(this, guildId, voiceChannelId);
        this.players.set(guildId, player);
        return player;
    }

    getPlayer(guildId) {
        return this.players.get(guildId);
    }

    send(payload) {
        this.ws.send(JSON.stringify(payload));
    }
}

module.exports = { Manager };
#
const { EventEmitter } = require('events');

class Player extends EventEmitter {
    constructor(manager, guildId, voiceChannelId) {
        super();
        this.manager = manager;
        this.guildId = guildId;
        this.voiceChannelId = voiceChannelId;
        this.sessionId = null;
        this.token = null;
        this.endpoint = null;
    }

    connect() {
        this.manager.send({
            op: 4,
            d: {
                guild_id: this.guildId,
                channel_id: this.voiceChannelId,
                self_mute: false,
                self_deaf: true
            }
        });

        this.manager.send({
            op: 'voiceUpdate',
            guildId: this.guildId,
            sessionId: this.sessionId,
            event: {
                token: this.token,
                endpoint: this.endpoint,
                guild_id: this.guildId
            }
        });
    }

    updateVoiceState(data) {
        this.sessionId = data.session_id;
        this.connect();
    }

    updateVoiceServer(data) {
        this.token = data.token;
        this.endpoint = data.endpoint;
        this.connect();
    }

    async search(query) {
        const node = this.manager.nodes[0];
        const res = await fetch(`http://${node.host}:${node.port}/v4/loadtracks?identifier=${encodeURIComponent(`spsearch:` + query)}`, {
            headers: {
                Authorization: node.password
            }
        });

        if (!res.ok) {
            console.error('An error occurred while searching for the track:', await res.text());
            return;
        }

        return await res.json();
    }

#
    async play(track) {
        const node = this.manager.nodes[0];
        const res = await fetch(`http://${node.host}:${node.port}/v4/sessions/${this.manager.sessionId}/players/${this.guildId}?noReplace=false`, {
            method: 'PATCH',
            headers: {
                Authorization: node.password,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                op: 'play',
                guildId: this.guildId,
                track: track,
                startTime: 0,
                volume: 100
            })
        });

        if (!res.ok) {
            console.error('Error playing track:', await res.text());
            return;
        }

        // console.log('Play response:', await res.text());
        console.log('Playing Track:', track.info.title);
        return track;
    }
}

module.exports = { Player };
patent bramble
#

nooo

#

not a code support

quiet iris
#

So basically I tried to make the client, I manage to make the bot to connect the voice channel

patent bramble
#

just lavalink

quiet iris
#

Oh wrong section?

#

damn

patent bramble
#

and btw

#

why make a entire client?

#

when theres like 10+

quiet iris
patent bramble
quiet iris
patent bramble
#

diff

#

u have to update ur bot to use a newer client

#

im assuming ur previous client is erela lol?

quiet iris
quiet iris
patent bramble
#

and if u truly dnt wanna update ur bot code lol u can try some v4 clients that are based of erela

quiet iris
#

There was one time the problem was my Lavalink Server, I tried to change the application.yml but still not working, but I tried with public lavalink its work

patent bramble
#

u can take up issues with the clients here

#

but

#

honestly if ur having the same issue between clients

#

then its prob

#

ur bot code

quiet iris
patent bramble
#

not a client

quiet iris
patent bramble
#

if ur having the issue across multiple clients

#

then its prob ur bot code

quiet iris
patent bramble
quiet iris
#

If i'm code normal bots, it just normal

quiet iris
patent bramble
#

honestly if ur lookin something

#

as simlar is erela

#

which honestly i dont recommend

#

there are clients that are based of erela

quiet iris
#

no luck

#

but just out of curiousity tho

#

i'll give you my application.yml

#

is it my lavalink configuration or what

#

wait

patent bramble
#

please read post guidelines

patent bramble
#

i truly doubt 3 clients

#

all have the same issue

#

its prob

#

ur code

quiet iris
#

The current client that I use is Lavalink Client I believe its was #ts_lavalink-client

patent bramble
#

any questions regrading clients should be asked in the clients channels

#

this support thread

quiet iris
#

Okay

patent bramble
#

is solely for lavalink related issues

quaint roverBOT
#

Please make sure to read and follow the post guidelines before opening your post.
This will help you get the best possible answers to your questions while minimizing the questions we have to ask you.
Thanks!

quiet iris
#

I'm going to ask about the lavalink, the application.yml is lavalink configuration, that is related to lavalink right

quiet iris
#

My question is that the problem probably was on my configuration, because sometimes when I'm using my own Lavalink server, there was no audio coming out from the bot, but when I'm using somebody else Lavalink Server (Public) its working fine

patent bramble
#

but without

#

logs

#

and application files we cannot help you

#

check ur logs

#

and then

quaint roverBOT
#

Please make sure to read and follow the post guidelines before opening your post.
This will help you get the best possible answers to your questions while minimizing the questions we have to ask you.
Thanks!

patent bramble
#

before making a new post about that issue

quiet iris
patent bramble
#

so u can be helped with the correct issue

quiet iris
#

Okay bet, I'll make another post about it.