Comments (6)
The queue#remove
method is working perfectly. Note the current playing track is not included when removing tracks from the queue (written in CAPS in the documentation). Queue index starts at 0. Hope this helps!
from erela.js.
Yeah!
args[0] is whatever the user inputs and i've been putting higher than 0 and there's 12 songs on the queue. I'm trying to remove the 6th song in the queue, but no matter what number i put into the remove() method, it only removes the first track on the queue.
from erela.js.
Doing some tests it seems like providing undefined
which you are most likely doing will remove only the first element in the array, this is because JavaScript treats all falsy values as the number 0 literally. You will probably say you're not giving undefined
but JavaScript doesn't care what you do if you try to access a undefined
(no value defined) value, this includes array elements and properties. You should check what the user is providing beforehand, if it exists, if it's a number, if it's in range of the queue, if all of those don't fail then remove it from the queue. Another good solution for long time would be to use TypeScript as it will catch basically all these errors and hint towards better code.
from erela.js.
I would like to point out that args[0] is probably a string. Try convert it before you remove it. Something like this
const index = Number(args[0]) || 0
player.queue.remove(index)
Note that the the ||
was added incase it failed to convert
from erela.js.
I actually just realized my mistake, I'm an idiot.
I wasn't getting the track correctly, and it was returning the first track in the queue, rather than the track I was removing.
Thanks for the help! Sorry for the bother
from erela.js.
I would like to point out that args[0] is probably a string. Try convert it before you remove it. Something like this
const index = Number(args[0]) || 0
player.queue.remove(index)
Note that the the||
was added incase it failed to convert
It being a number does not matter with JavaScript, however I will be adding more strict types so this won't be an issue.
from erela.js.
Related Issues (20)
- Feature Request: ytmsearch
- Weird Queue Problem HOT 4
- defaultSearchPlatform does not work HOT 3
- I donβt understand anything anymore
- Broken with nodejs 18.6 HOT 2
- updateVoiceState on the client issue HOT 2
- Error: Cannot read properties of undefined (reading 'track')
- Unexpected token in JSON at position 0 HOT 2
- Add queue/player events
- Cannot read properties of undefined (reading 'map') : Manager.js:155:36 HOT 1
- Update HOT 6
- Init bug HOT 8
- petitio causing a lot of errors HOT 25
- petitio: unexpected token in json HOT 4
- Plugin Issues HOT 1
- Unexpected token in JSON at position 0 HOT 3
- SyntaxError: Unexpected token in JSON at position 0 on Linux. HOT 1
- Some plugins does not work after latest update HOT 2
- Cannot read properties of undefined (reading 'map'): Manager.js:161:36
- TypeError: finalQuery.match is not a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from erela.js.