Search in sources :

Example 1 with SkipToCommand

use of main.commands.prefixcommands.audio.SkipToCommand in project Robertify-Bot by bombies.

the class SkipSlashCommand method onSlashCommand.

@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
    if (!nameCheck(event))
        return;
    if (!banCheck(event))
        return;
    if (!restrictedChannelCheck(event))
        return;
    event.deferReply().queue();
    final var selfVoiceState = event.getGuild().getSelfMember().getVoiceState();
    final var memberVoiceState = event.getMember().getVoiceState();
    if (!musicCommandDJCheck(event)) {
        if (!selfVoiceState.inVoiceChannel()) {
            event.getHook().sendMessageEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "I must be in a voice channel before this command can be executed!").build()).setEphemeral(true).queue();
            return;
        }
        if (selfVoiceState.getChannel().getMembers().size() != 2) {
            MessageEmbed embed = new SkipCommand().handleVoteSkip(event.getTextChannel(), selfVoiceState, memberVoiceState);
            if (embed != null) {
                event.getHook().sendMessageEmbeds(embed).setEphemeral(false).queue();
            } else {
                event.getHook().sendMessageEmbeds(RobertifyEmbedUtils.embedMessage(event.getGuild(), "Started a vote skip!").build()).setEphemeral(true).queue();
            }
            sendRandomMessage(event);
            return;
        }
    }
    if (event.getOptions().isEmpty()) {
        event.getHook().sendMessageEmbeds(new SkipCommand().handleSkip(selfVoiceState, memberVoiceState)).setEphemeral(false).queue();
    } else {
        final var musicManager = RobertifyAudioManager.getInstance().getMusicManager(event.getGuild());
        final ConcurrentLinkedQueue<AudioTrack> queue = musicManager.getScheduler().queue;
        final int tracksToSkip = GeneralUtils.longToInt(event.getOption("trackstoskip").getAsLong());
        event.getHook().sendMessageEmbeds(new SkipToCommand().handleSkip(event.getUser(), queue, musicManager, tracksToSkip).build()).setEphemeral(false).queue();
    }
    sendRandomMessage(event);
}
Also used : MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) SkipCommand(main.commands.prefixcommands.audio.SkipCommand) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) SkipToCommand(main.commands.prefixcommands.audio.SkipToCommand)

Aggregations

AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 SkipCommand (main.commands.prefixcommands.audio.SkipCommand)1 SkipToCommand (main.commands.prefixcommands.audio.SkipToCommand)1 MessageEmbed (net.dv8tion.jda.api.entities.MessageEmbed)1