use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class MusicCmds method forceskip.
@Subscribe
public void forceskip(CommandRegistry cr) {
cr.register("forceskip", new SimpleCommand(Category.MUSIC, CommandPermission.ADMIN) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
if (!isInConditionTo(event))
return;
TrackScheduler scheduler = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild()).getTrackScheduler();
event.getChannel().sendMessage(EmoteReference.CORRECT + "An Admin or Bot Commander decided to skip the current song.").queue();
scheduler.nextTrack(true, true);
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return helpEmbed(event, "Force skip").setDescription("Well, administrators should be able to forceskip, shouldn't they?\n" + "`~>skip` has the same effect if you're a DJ.").build();
}
});
cr.registerAlias("forceskip", "fs");
}
use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class MusicCmds method stop.
/**
* This only fires on manual stop!
*
* @param event event context of what guild to use to stop it
*/
private void stop(GuildMessageReceivedEvent event) {
GuildMusicManager musicManager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
TrackScheduler trackScheduler = musicManager.getTrackScheduler();
if (trackScheduler.getAudioPlayer().getPlayingTrack() != null && !trackScheduler.getAudioPlayer().isPaused()) {
trackScheduler.getAudioPlayer().getPlayingTrack().stop();
}
int TEMP_QUEUE_LENGTH = trackScheduler.getQueue().size();
trackScheduler.getQueue().clear();
if (TEMP_QUEUE_LENGTH > 0) {
event.getChannel().sendMessage(EmoteReference.OK + "Removed **" + TEMP_QUEUE_LENGTH + " songs** from the queue.").queue();
}
// This ends up calling TrackScheduler#onTrackStart -> currentTrack == null -> TrackScheduler#onStop!
// Beware to not close the connection twice...
trackScheduler.nextTrack(true, true);
}
Aggregations