use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class MusicCmds method nextSong.
@Subscribe
public void nextSong(CommandRegistry cr) {
cr.register("ns", new SimpleCommand(Category.MUSIC) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
GuildMusicManager musicManager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
TrackScheduler scheduler = musicManager.getTrackScheduler();
AudioTrack next = scheduler.getQueue().peek();
if (next == null) {
event.getChannel().sendMessage(EmoteReference.TALKING + "Ow, there isn't any song next").queue();
} else {
event.getChannel().sendMessage(EmoteReference.MEGA + "Next song in queue: **" + next.getInfo().title + "** (" + Utils.getDurationMinutes(next.getDuration()) + ")" + " | *Total songs in queue: " + scheduler.getQueue().size() + "*").queue();
}
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return helpEmbed(event, "Next Song Command").addField("Description", "**Shows the next song in queue!**", false).build();
}
});
cr.registerAlias("ns", "nextsong");
}
use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class MantaroAudioManager method loadAndPlay.
public void loadAndPlay(GuildMessageReceivedEvent event, String trackUrl, boolean skipSelection, boolean addFirst) {
if (!AudioCmdUtils.connectToVoiceChannel(event))
return;
GuildMusicManager musicManager = getMusicManager(event.getGuild());
TrackScheduler scheduler = musicManager.getTrackScheduler();
scheduler.getAudioPlayer().setPaused(false);
if (scheduler.getQueue().isEmpty())
scheduler.setRepeatMode(null);
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoader(musicManager, event, skipSelection, addFirst));
}
use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class VoiceChannelListener method onLeave.
private void onLeave(VoiceChannel vc) {
GuildVoiceState vs = vc.getGuild().getSelfMember().getVoiceState();
if (validate(vs))
return;
if (isAlone(vc)) {
GuildMusicManager gmm = MantaroBot.getInstance().getAudioManager().getMusicManager(vc.getGuild());
if (gmm != null) {
TrackScheduler scheduler = gmm.getTrackScheduler();
if (scheduler != null && scheduler.getCurrentTrack() != null && scheduler.getRequestedChannelParsed() != null) {
TextChannel tc = scheduler.getRequestedChannelParsed();
if (tc.canTalk()) {
tc.sendMessage(EmoteReference.THINKING + "I'll leave **" + vc.getName() + "** in 2 minutes because I was left all alone :<").queue(m -> m.delete().queueAfter(30, TimeUnit.SECONDS));
}
}
gmm.setAwaitingDeath(true);
gmm.scheduleLeave();
gmm.getAudioPlayer().setPaused(true);
}
}
}
use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class VoiceChannelListener method onJoin.
private void onJoin(VoiceChannel vc) {
GuildVoiceState vs = vc.getGuild().getSelfMember().getVoiceState();
if (validate(vs))
return;
if (!isAlone(vc)) {
GuildMusicManager gmm = MantaroBot.getInstance().getAudioManager().getMusicManager(vc.getGuild());
if (gmm != null) {
TrackScheduler scheduler = gmm.getTrackScheduler();
if (scheduler.getCurrentTrack() != null) {
if (gmm.isAwaitingDeath()) {
TextChannel tc = scheduler.getRequestedChannelParsed();
if (tc.canTalk()) {
tc.sendMessage(EmoteReference.POPPER + "Resuming playback because someone joined!").queue();
}
}
}
gmm.cancelLeave();
gmm.setAwaitingDeath(false);
gmm.getAudioPlayer().setPaused(false);
}
}
}
use of net.kodehawa.mantarobot.commands.music.requester.TrackScheduler in project MantaroBot by Mantaro.
the class VoiceChannelListener method onGuildVoiceMute.
private void onGuildVoiceMute(GuildVoiceMuteEvent event) {
if (event.getMember().getUser().getIdLong() != event.getJDA().getSelfUser().getIdLong())
return;
GuildVoiceState vs = event.getVoiceState();
if (validate(vs))
return;
GuildMusicManager gmm = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
if (gmm != null) {
if (event.isMuted()) {
TrackScheduler scheduler = gmm.getTrackScheduler();
if (scheduler.getCurrentTrack() != null && scheduler.getRequestedChannelParsed() != null) {
TextChannel tc = scheduler.getRequestedChannelParsed();
if (tc.canTalk()) {
tc.sendMessage(EmoteReference.SAD + "Pausing player because I got muted :(").queue();
}
gmm.getAudioPlayer().setPaused(true);
}
} else {
if (!isAlone(vs.getChannel())) {
if (gmm.getTrackScheduler().getCurrentTrack() != null) {
gmm.getAudioPlayer().setPaused(false);
}
}
}
}
}
Aggregations