jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.22k stars 2.5k forks source link

[Bug Report] Forceremove doesn't work if user leaves voice channel #1249

Open alexandreteles opened 1 year ago

alexandreteles commented 1 year ago

Bug Description

If a user adds songs to the queue and then leaves the voice channel, forceremove will be unable to remove their songs, meaning that DJs are forced to use forceskip in each song they've added.

Steps to Reproduce

  1. User joins voice channel,
  2. User adds a song,
  3. User leaves voice channel,
  4. Use forceskip it will report Unable to find user

Expected Result

All user entries are deleted from the playlist.

Debug Output

System Properties:
  java.version = 17.0.5
  java.vm.name = Eclipse OpenJ9 VM
  java.vm.specification.version = 17
  java.runtime.name = IBM Semeru Runtime Open Edition
  java.runtime.version = 17.0.5+8
  java.specification.version = 17
  os.arch = aarch64
  os.name = Linux

JMusicBot Information:
  Version = 0.3.8
  Owner = 282584705218510848
  Prefix = /
  AltPrefix = !
  MaxSeconds = 0
  NPImages = false
  SongInStatus = false
  StayInChannel = false
  UseEval = false
  UpdateAlerts = true

Dependency Information:
  JDA Version = 4.4.0_352
  JDA-Utilities Version = 3.0.5
  Lavaplayer Version = 1.3.78

Runtime Information:
  Total Memory = 54
  Used Memory = 24

Discord Information:
  ID = 896191407692320829
  Guilds = 7
  Users = 10

Additional Info

Would be nice to be able to remove individual songs from other users as a DJ as well.

Checklist

alexandreteles commented 1 year ago

I believe that

/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java

User target;
        List<Member> found = FinderUtil.findMembers(event.getArgs(), event.getGuild());

        if(found.isEmpty())
        {
            event.replyError("Unable to find the user!");
            return;
        }
        else if(found.size()>1)
        {
        ...

Is the culprit here. Instead of searching for the user that way (which will result in no user found as the user isn't connected anymore) the command should look into the playlist for songs added by a given user (by ID or username) and remove it :)

MichailiK commented 1 year ago

Since JMusicBot no longer uses the members intent, we can not search by username anymore & have to rely on IDs & mentions instead.

alexandreteles commented 1 year ago

Since JMusicBot no longer uses the members intent, we can not search by username anymore & have to rely on IDs & mentions instead.

Mentions apparently do not work either, I've tried. Could we store the username in the playlist object so once forceremove @user is called we can check for the mentioned user and remove all entries containing his username? It would still fail if the user changed nicknames but I guess it's better than not being able to clean troll insertions.