<commit_before>package com.bwfcwalshy.flarebot.commands.music;

import com.bwfcwalshy.flarebot.FlareBot;
import com.bwfcwalshy.flarebot.MessageUtils;
import com.bwfcwalshy.flarebot.commands.Command;
import com.bwfcwalshy.flarebot.commands.CommandType;
import com.bwfcwalshy.flarebot.music.MusicManager;
import com.bwfcwalshy.flarebot.scheduler.FlarebotTask;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IUser;

import java.util.HashMap;
import java.util.Map;

public class SkipCommand implements Command {

    private MusicManager musicManager;
    private Map<String, Map<String, Vote>> votes = new HashMap<>();

    public SkipCommand(FlareBot bot) {
        this.musicManager = bot.getMusicManager();
    }

    @Override
    public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
        if (channel.getGuild().getConnectedVoiceChannel() == null || !musicManager.hasPlayer(channel.getGuild().getID())
                || musicManager.getPlayer(channel.getGuild().getID()).getCurrentTrack() == null) {
            MessageUtils.sendMessage(channel, "I am not streaming!");
            return;
        }
        if (!sender.getConnectedVoiceChannels().contains(channel.getGuild().getConnectedVoiceChannel())) {
            MessageUtils.sendMessage(channel, "You must be in the channel in order to skip songs!");
        }
        if (args.length != 1) {
            if (votes.containsKey(channel.getGuild().getID())) {
                MessageUtils.sendMessage(channel, "Can't start a vote right now! " +
                        "Another one in progress! Please use _skip YES|NO to vote!");
                return;
            }
        }
        Map<String, Vote> mvotes = this.votes.computeIfAbsent(channel.getGuild().getID(), s -> {
            new FlarebotTask("Vote " + s) {

                @Override
                public void run() {
                    String res = "";
                    boolean skip = votes.get(s).entrySet().stream()
                            .filter(e -> e.getValue() == Vote.YES)
                            .count() > (votes.size() / 2.0f);
                    MessageUtils.sendMessage(channel, "The votes are in!!!\nResult: " + (skip ? "Skip!" : "Keep!"));
                    if (skip)
                        musicManager.skip(s);
                    votes.remove(s);
                }
            }.delay(20000);
            MessageUtils.sendMessage(channel, "The vote to skip **" +
                    musicManager.getPlayer(channel.getGuild().getID()).getCurrentTrack().getMetadata().get("name")
                    + "** has started!\nUse _skip YES|NO to vote!");
            return new HashMap<>();
        });
        if (mvotes.containsKey(sender.getID())) {
            MessageUtils.sendMessage(channel, "You already voted!");
            return;
        }
        if (args.length == 1)
            try {
                Vote vote = Vote.valueOf(args[0].toUpperCase());
                mvotes.put(sender.getID(), vote);
            } catch (IllegalArgumentException e) {
                MessageUtils.sendMessage(channel, "Please use yes or no!");
            }
    }

    @Override
    public String getCommand() {
        return "skip";
    }

    @Override
    public String getDescription() {
        return "Skip the current song playing, or if specified #NUMBER for the song under NUMBER or just NUMBER for next NUMBER songs.";
    }

    @Override
    public CommandType getType() {
        return CommandType.MUSIC;
    }

    @Override
    public String getPermission() {
        return "flarebot.skip";
    }

    private enum Vote {
        YES,
        NO
    }
}<commit_msg>Update SkipCommand.java<commit_after>package com.bwfcwalshy.flarebot.commands.music;

import com.bwfcwalshy.flarebot.FlareBot;
import com.bwfcwalshy.flarebot.MessageUtils;
import com.bwfcwalshy.flarebot.commands.Command;
import com.bwfcwalshy.flarebot.commands.CommandType;
import com.bwfcwalshy.flarebot.music.MusicManager;
import com.bwfcwalshy.flarebot.scheduler.FlarebotTask;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IMessage;
import sx.blah.discord.handle.obj.IUser;

import java.util.HashMap;
import java.util.Map;

public class SkipCommand implements Command {

    private MusicManager musicManager;
    private Map<String, Map<String, Vote>> votes = new HashMap<>();

    public SkipCommand(FlareBot bot) {
        this.musicManager = bot.getMusicManager();
    }

    @Override
    public void onCommand(IUser sender, IChannel channel, IMessage message, String[] args) {
        if (channel.getGuild().getConnectedVoiceChannel() == null || !musicManager.hasPlayer(channel.getGuild().getID())
                || musicManager.getPlayer(channel.getGuild().getID()).getCurrentTrack() == null) {
            MessageUtils.sendMessage(channel, "I am not streaming!");
            return;
        }
        if (!sender.getConnectedVoiceChannels().contains(channel.getGuild().getConnectedVoiceChannel())) {
            MessageUtils.sendMessage(channel, "You must be in the channel in order to skip songs!");
        }
        if (args.length != 1) {
            if (votes.containsKey(channel.getGuild().getID())) {
                MessageUtils.sendMessage(channel, "Can't start a vote right now! " +
                        "Another one in progress! Please use _skip YES|NO to vote!");
                return;
            }
        }
        Map<String, Vote> mvotes = this.votes.computeIfAbsent(channel.getGuild().getID(), s -> {
            new FlarebotTask("Vote " + s) {

                @Override
                public void run() {
                    String res = "";
                    boolean skip = votes.get(s).entrySet().stream()
                            .filter(e -> e.getValue() == Vote.YES)
                            .count() > (votes.size() / 2.0f);
                    MessageUtils.sendMessage(channel, "The votes are in!!!\nResult: " + (skip ? "Skip!" : "Keep!"));
                    if (skip)
                        musicManager.skip(s);
                    votes.remove(s);
                }
            }.delay(20000);
            MessageUtils.sendMessage(channel, "The vote to skip **" +
                    musicManager.getPlayer(channel.getGuild().getID()).getCurrentTrack().getMetadata().get("name")
                    + "** has started!\nUse _skip YES|NO to vote!");
            return new HashMap<>();
        });
        if (mvotes.containsKey(sender.getID())) {
            MessageUtils.sendMessage(channel, "You already voted!");
            return;
        }
        if (args.length == 1)
            try {
                Vote vote = Vote.valueOf(args[0].toUpperCase());
                mvotes.put(sender.getID(), vote);
            } catch (IllegalArgumentException e) {
                MessageUtils.sendMessage(channel, "Please use yes or no!");
            }
    }

    @Override
    public String getCommand() {
        return "skip";
    }

    @Override
    public String getDescription() {
        return "Starts a skip voting, or if one is happening, marks a vote. _skip YES|NO to pass a vote.";
    }

    @Override
    public CommandType getType() {
        return CommandType.MUSIC;
    }

    @Override
    public String getPermission() {
        return "flarebot.skip";
    }

    private enum Vote {
        YES,
        NO
    }
}
{'fraction_non_alphanumeric': 0.12064809855382967, 'fraction_numerical': 0.002678093197643278, 'mean_word_length': 2.118580375782881, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, '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': '259345', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2052, 'n_words': 456}