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);
}
Aggregations