menudocs / erela.js Goto Github PK
View Code? Open in Web Editor NEWAn easy-to-use Lavalink client for NodeJS.
License: Apache License 2.0
An easy-to-use Lavalink client for NodeJS.
License: Apache License 2.0
Sometimes one of my nodes encounters a network issue, and other nodes are working fine, so the search() waits forever for the response... there should be a timeout for search() and the promise should be rejected if the timeout is exceeded... Or maybe if another node is available, then search through that... ๐ค
Whenever bot has freshly connected to voice channel music plays but when queue ends and you try to queue another song, it will queue but not play.
I started erela client in on ready event of Discord bot
here is what it looks like
client.music = new ErelaClient(client, nodes)
.on("nodeError", console.log)
.on("nodeConnect", () => console.log("Successfully created a new Node."))
.on("queueEnd", player => {
player.textChannel.send("Queue has ended.")
return client.music.players.destroy(player.guild.id)
})
.on("trackStart", ({textChannel}, {title, duration}) => textChannel.send(`Now playing: **${title}** \`${Utils.formatTime(duration, true)}\``).then(m => m.delete(15000)));
but in my console log it looks like this
Hi, Azooid is now online and ready to server in 5 servers and serving 608 users!.
done saving serversettings.json // my other stuff
complete // my other stuff
Successfully created a new Node. // from here the erela client starts connecting node
Successfully created a new Node.
Successfully created a new Node.
Successfully created a new Node.
Successfully created a new Node.
Successfully created a new Node. // untill 5-7 min i can play music in bot but when it stops it wont play again
Node {
reconnectAttempts: 5,
calls: 1,
erela:
........... for full log i pasted it to paste bin
https://pastebin.com/vpbkQmCi - console log from node
When I updated the library to the latest version (v2.3.0), it started giving the following error in player.clearEQ();
Bands must be a non-empty object array containing 'band' and 'gain' properties.
Node "default" encountered an error: connect ECONNREFUSED My ip can't send here:2333.
When the milliseconds parameter is less than 60 seconds, it returns ss
, when it should return 00:ss
because when the milliseconds parameter is 60 seconds or more, it returns mm:ss
.
When i just get my bot to the play the first time, how can i make it so both the enqueuing message and the now playing doesn't show. So like i can have it so just the now playing message shows and then the enqueuing message shows when you add another song to the queue.
Hopefully this makes sense
Playlists seem to be erroring in the rewrite. This error pops up when playing playlists on Youtube, Soundcloud and Bandcamp:
TypeError: Cannot read property 'info' of undefined
at Manager.<anonymous> (/root/ear_tensifier/node_modules/@tetracyl/erela.js/dist/structures/Manager.js:108:49)
at Generator.next (<anonymous>)
at fulfilled (/root/ear_tensifier/node_modules/@tetracyl/erela.js/dist/structures/Manager.js:5:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
When i execute my play command to add another song to the queue while the bot is already playing the music is just stopped without and the bot disconnects.
Every now and again when using the search method it will return "No tracks were found." Yet if I search the same thing another 1 - 3 times it will give me results. It seems to be very random as when I try to recreate the issue I get varied results.
I've been really excited to use this library.
Today I decided to code a music category for my bot.
But unfortunately, When ever I tell a player to play the current queue.. It doesn't play the audio in the voice channel.
Here is my code:
const { voice } = message.member;
if(voice.channel){
var player = this.client.music.players.spawn({
textChannel: message.channel,
guild: message.guild,
voiceChannel: voice.channel
});
var searchResults = await this.client.music.search(args.query, message.author);
//console.log(searchResults);
player.queue.add(searchResults.tracks[0]);
console.log(player.queue);
player.play()
The track is added to the queue, everything works fine for now.. Till player.play()
is executed! It actually emit the event trackStart
but it doesn't play audio in the voice channel.
I've tried discord.js music code from the guides, It worked.
Note: I'm using discord-akairo
framework for my bot.
Thanks in advance. ;)
Add a pagination embed for the example queue command
Because i tried so hard to make one and failed horribly so if someone could make or help me make one i will be appreciated
Thank you for reading this.
Hi, I'm trying to use player.queue.remove(start, end)
.
Unfortunately, if I give the number 0 as the start, I get an error missing start parameter
. If I enter the number 1 instead of start, I get an error start parameter cannot be bigger then 0
.
I am doing something wrong?
Why can't I remove a range like this from start index 5 to end index 10, for example?
It throws the following error:
(node:34738) UnhandledPromiseRejectionWarning: TypeError: this.client.guilds.get is not a function
at ErelaClient.sendWS (/Users/simon/Documents/GitHub/AtlantaBotv5/node_modules/erela.js/dist/lib/ErelaClient.js:218:42)
at Map.spawn (/Users/simon/Documents/GitHub/AtlantaBotv5/node_modules/erela.js/dist/lib/stores/PlayerStore.js:34:20)
at module.exports.execute (/Users/simon/Documents/GitHub/AtlantaBotv5/src/commands/Music/play.js:18:50)
at Message.execute (/Users/simon/Documents/GitHub/AtlantaBotv5/src/events/message.js:161:21)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:34738) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:34738) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
when I try to spawn a player using the master branch of Discord.js. Discord.js now uses Managers and removed Datastores so we need to use client.guilds.cache.get
now. Please fix this ๐
When i play something (lets consider there's only 1 song added) and then i skip or stop which (player.stop()) and then if i add another song the "trackStart" even is emitted twice. and also the queueRepeat which is supposed to loop the queue gets ignored when you "skip" a song even when loop is enabled using the player.setQueueRepeat() method. Im using erelajs 2.3.0..
When loading the Spotify Erela addon (https://github.com/Solaris9/erela.js-spotify), erela.js crashes with the message in the title. After further code inspection, I found out the Spotify plugin constructor does in fact extend it (https://github.com/Solaris9/erela.js-spotify/blob/master/src/plugin.ts#L66) but it isn't correctly recognized as one by the plugin loader.
To counter this and try to find a solution, when commenting out this line: https://github.com/Solaris9/erela.js/blob/master/src/structures/Manager.ts#L259 it obviously does not throw an error - as expected - but the manager does not finish loading and the client.manager
property isn't populated.
This error may not be exclusive to the Spotify addon, it could also be affecting any other plugin, but I didn't check it.
Edit: code if needed
client.manager = new Erela.Manager({
nodes,
plugins: [
new Spotify({
clientID: `something`
clientSecret: `something`
})
],
send(id, payload) {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
},
})
The idea of stores is to enable the organization and management of players and nodes; however, stores are bloat to the library.
A playlist URL or a song URL triggers the SEARCH_RESULT when the player is playing.
The playlist tracks and the url track is loaded to the queue tho, but it also shows the playlist tracks as a search results and i can choose the result number. same as the single track url but the result is only one
Hi, why is song's duration undefined each time the player repeat that song even though my progress bar is still working?
Hey, today I wanted to take a look into the documentation of erela.js but the domain to the website doesn't work anymore. Looking around I found that you are working on a new version of erela.js and that you have a new website. Could you by any chance reupload the old erela documentation?
It seems when ever i set filters it sounds like earrape
For some strange reason if the doesn't use the music that often and the you try to use it again, it says No available Nodes
yet there is in both the Manager and the node is alive.
Would like to be able to issue skipto to jump queue to given track number of queue
Whenever you skip the last song in the queue the queueEnd event does not emit.
player.queue.clear(); Not Working
I'm trying to use 2 clients at the same time but I don't know why when I create a player in the second client it creates in the first, any idea?
I used the example in the docs to make it easier for you to understand but I tweak it a bit to accept 2 clients or more:
const { Client } = require("discord.js");
const { Manager } = require("erela.js");
const { tokens } = require('./tokens');
(async () => {
for (let token of tokens) {
const client = new Client();
await client.login(token);
client.manager = new Manager({
nodes: [
{
host: "localhost",
port: 41892,
password: "$2FOYMnktb4Zg0lF2kBuj%YgB@v!BS!CC9$NY!pOVNO95OELvG",
identifier: client.user.id // <-- I've tried to create an identifier to specify it when creating a player but I think the nodes are separated between the clients already
},
],
send(id, payload) {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
},
})
.on("nodeConnect", node => console.log(`Node ${node.options.identifier} connected`))
.on("nodeError", (node, error) => console.log(`Node ${node.options.identifier} had an error: ${error.message}`))
.on("trackStart", (player, track) => {
client.channels.cache
.get(player.textChannel)
.send(`Now playing: ${track.title}`);
})
.on("queueEnd", (player) => {
client.channels.cache
.get(player.textChannel)
.send("Queue has ended.");
player.destroy();
});
client.once("ready", () => {
console.log("I am ready!");
client.manager.init(client.user.id);
});
client.on("raw", (d) => client.manager.updateVoiceState(d));
client.on("message", async (message) => {
if (message.content.startsWith(client.user.id + "play")) {
const res = await client.manager.search(
message.content.slice(6),
message.author
);
const player = client.manager.create({
guild: message.guild.id,
voiceChannel: message.member.voice.channel.id,
textChannel: message.channel.id,
node: client.user.id // <-- here i'm trying to use the node
});
player.connect();
player.queue.add(res.tracks[0]);
message.channel.send(`Enqueuing track ${res.tracks[0].title}.`);
if (!player.playing && !player.paused && !player.queue.size)
player.play();
if (
!player.playing &&
!player.paused &&
player.queue.totalSize === res.tracks.length
)
player.play();
}
});
}
})();
however when i try to play something like 784823155860308038play happier
using the second client it runs in the first one:
<ref *1> Manager {
_events: [Object: null prototype] {
nodeConnect: [Function (anonymous)],
nodeError: [Function (anonymous)],
trackStart: [Function (anonymous)],
queueEnd: [Function (anonymous)]
},
_eventsCount: 4,
_maxListeners: undefined,
players: Collection(0) [Map] {},
nodes: Collection(1) [Map] {
'784823155860308038' => Node { // <-- look here the id of the second client
options: [Object],
socket: [WebSocket],
calls: 1,
reconnectAttempts: 1,
manager: [Circular *1],
stats: [Object]
}
},
initiated: true,
options: {
plugins: [],
nodes: [ [Object] ],
shards: 1,
autoPlay: true,
send: [Function: send],
clientId: '784823155860308038' // <-- look here the id of the second client
},
[Symbol(kCapture)]: false
}
but the one who played music is the first one with id 730472633388236831
So it spawns the bot and joins the voice channel without a problem and playing the song works too. But if you add a new song after the currently playing one has ended and the queue is empty it wont play anything. But if you add a new song while the one u added before was still playing it would just work fine, only way to make it work again is to destroy the player and add the song to the queue again. I used the example code from the readme file.
I need the epic documentation to learn how to use this.
When trying to connect to my node, I get this error:
Error: connect ECONNREFUSED 127.0.0.1:7000.
I "fixed" this error by making a server to run on https://localhost:7000.
Didn't actually fix it, I get this error now:
Error: Unexpected server response: 200.
my code seems fine, its just this:
this.music = new Manager({
nodes,
send: (id, payload) => {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
}
})
.on("nodeConnect", node => {
console.log(`Node "${node.options.identifier}" connected.`);
})
.on("nodeError", (node, error) => {
console.log(`Node "${node.options.identifier}" encountered an error: ${error}.`);
});
this.once('ready', () => {
console.log(`${this.user.tag} has logged in.`);
const server = require('../../server/server');
this.music.init(this.user.id);
});
'this' is a discord.js client.
(none of the tutorials I've watched have mentioned setting up a server with express, I just figured it might work)
I can't seem to figure out what's going on, lavalink.jar starts up fine, with a few warnings. It says this when it starts:
Started Launcher in 3.483 seconds (JVM running for 3.94)
but, it also says this:
Undertow started on port(s) 8080 (http) with context path ' '
My OS is Mac OS X.
if anyone can help I would appreciate it! Thanks!
The error returned in d.js is 400 (Bad request).
Lavalink returned the error where the identifier cannot be found.
This is my code
const search = await undefined.manager.search(`https://www.youtube.com/watch?v=${trackselected.id}`, msg.author);
return console.log(search);
//err
{
loadType: 'LOAD_FAILED',
exception: {
severity: 'SUSPICIOUS',
message: 'Received unexpected response from YouTube.'
},
tracks: []
}
EDIT: It was my lavalink.jar file (it was outdated) that was causing the issue
A reminder/note for the transfer over the coming days.
Update both homepage
and repository
links on the npm page so they resolve to this repo
Songs that are added after "skipping" the last song in the queue with player.stop() causes it to not play anything after that.
The playlist is not sorted by YouTube order.
Normally to get the duration of song is
const player = client.music.players.get(message.guild.id);
const { title, author, duration, thumbnail } = player.queue[0];
this line will simply give me total duration of current song but how can i get current duration of the song
example 1:12/4:24 here what i want to get is 1:12 which i will edit the last massage and edit the massage every 5 sec
Hi! I'm not sure If I'm reading it wrong or using it improperly, but I'm trying to let the users choose what track to remove from the queue and no matter what number the user replies with, it only removes the next track after the current one playing. It does not remove the specified track.
player.queue.remove(args[0])
is what I'm using, if you need more let me know!
Any ideas? (Using up to date version of erela.js)
Users should be able to configure and add third-party plugins to maximize customization if they desire.
conts AwesomePlugin = require('./my_plugin');
const client = new ErelaClient({
plugin: new AwesomePlugin()
});
I tried to play music but it's just not playing I console logged around the bot joins channel sends queue message adds the song to playlist it just is not playing anything
An empty player with no playing audio can be unpaused and will play nothing and player.playing will be true
This happens when a track is added to the queue while the player is not playing. When you resume the player gets stuck at that position since there is no way to find out from the player if it is playing audio or not... Player.playing returns true and player.queue.current returns the track that was added while the player was not playing.
This bug is linked to issue #27 . If you add a song to the queue, then loop the queue, then pause the queue, then add another song to the queue, erela.js will skip through everything in the queue. And since the song is looped, it will try to skip the same song over and over again, resulting in the trackStart event being emitted numerous times in the span of a couple of seconds.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.