Giter VIP home page Giter VIP logo

Comments (6)

t3ned avatar t3ned commented on August 20, 2024

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.

pab14567 avatar pab14567 commented on August 20, 2024

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.

Solaris9 avatar Solaris9 commented on August 20, 2024

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.

redfer13 avatar redfer13 commented on August 20, 2024

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.

pab14567 avatar pab14567 commented on August 20, 2024

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.

Solaris9 avatar Solaris9 commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.