<commit_before>package listener;

import main.Main;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.util.audio.events.TrackFinishEvent;

public class TrackFinishedListener implements IListener<TrackFinishEvent> {

  @Override
  public void handle(TrackFinishEvent event) {

    /*
     Wait a few ms to fix 'java.net.SocketException: Socket is closed'.
     (Audio-packet length is 20ms, use 21ms)
      */
    try {
      Thread.sleep(21);
    } catch (InterruptedException ignored) {
    }
  
    // Leave current channel after audio finished
    Main.getInstance().leaveVoiceChannel(event.getPlayer().getGuild());

    System.out.println("Left voice channel.");

    // Update stats
    Main.getInstance().played++;
    Main.getInstance().saveStats();

    System.out.println("Increased 'played' and saved stats.");
  }
}
<commit_msg>Manually fixed memory leak by manually cleaning AudioPlayer. See comment for issue on github.<commit_after>package listener;

import main.Main;
import sx.blah.discord.api.events.IListener;
import sx.blah.discord.util.audio.events.TrackFinishEvent;

public class TrackFinishedListener implements IListener<TrackFinishEvent> {

  @Override
  public void handle(TrackFinishEvent event) {

    /*
     Wait a few ms to fix 'java.net.SocketException: Socket is closed'.
     (Audio-packet length is 20ms, use 21ms)
      */
    try {
      Thread.sleep(21);
    } catch (InterruptedException ignored) {
    }

    // Leave current channel after audio finished
    Main.getInstance().leaveVoiceChannel(event.getPlayer().getGuild());

    // Clean memory to countermeasure memory leak
    // https://github.com/austinv11/Discord4J/issues/191)
    event.getPlayer().clean();

    System.out.println("Left voice channel.");

    // Update stats
    Main.getInstance().played++;
    Main.getInstance().saveStats();

    System.out.println("Increased 'played' and saved stats.");
  }
}

{'fraction_non_alphanumeric': 0.11594202898550725, 'fraction_numerical': 0.009316770186335404, 'mean_word_length': 3.5163551401869158, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5994280', 'n_tokens_mistral': 587, 'n_tokens_neox': 548, 'n_words': 137}