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 };
#No Sound from Bot
1 messages · Page 1 of 1 (latest)
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 };
So basically I tried to make the client, I manage to make the bot to connect the voice channel
just lavalink
ye
and btw
why make a entire client?
when theres like 10+
I tried 2 of them, not compatible with my bot :<
recommend building ur bot around one rather then a client
I did, it was working fine before the v4 coming out, and now yep not working
yeah cause v4
diff
u have to update ur bot to use a newer client
im assuming ur previous client is erela lol?
I did, I tried to fix my bot, but still had error like no sound coming out from my bot
yes, I change to lavalink-client and moonlink still not working
u gotta take that up with client devs
and if u truly dnt wanna update ur bot code lol u can try some v4 clients that are based of erela
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
diff lavalink versions probb erela isnt comptiable with lavalink v4
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
I tried using moonlink and lavalink-client, they're v4 right?
not a client
ye
Yeah my server was v4, still had the same issue
Yes, because my bot approach is little bit different, thats why I tried making my own lavalink tbh
u can take up any issues in their respected channels https://discord.com/channels/1082302532421943407/1141774661940682855 and https://discord.com/channels/1082302532421943407/1084993535574544474
If i'm code normal bots, it just normal
I tried contact moonlink devs, but sadly they don't have the answer, they say my bot seems to be okay
🤷♂️
honestly if ur lookin something
as simlar is erela
which honestly i dont recommend
there are clients that are based of erela
I tried install three of them
no luck
but just out of curiousity tho
i'll give you my application.yml
is it my lavalink configuration or what
wait
please read post guidelines
like i said before
i truly doubt 3 clients
all have the same issue
its prob
ur code
oh yeah i forgot to tell
The current client that I use is Lavalink Client I believe its was #ts_lavalink-client
any questions regrading clients should be asked in the clients channels
this support thread
Okay
is solely for lavalink related issues
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!
yes, but i'm not going to ask about the client right now
I'm going to ask about the lavalink, the application.yml is lavalink configuration, that is related to lavalink right
yeah
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
well maybe its that
but without
logs
and application files we cannot help you
check ur logs
and then
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!
before making a new post about that issue
I tried to, but you said to read post guidelines before :<
u should gather ur logs, and application yml then make a correct post
so u can be helped with the correct issue
Okay bet, I'll make another post about it.