Search in sources :

Example 6 with TrackScheduler

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");
}
Also used : SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) TrackScheduler(net.kodehawa.mantarobot.commands.music.requester.TrackScheduler) Subscribe(com.google.common.eventbus.Subscribe)

Example 7 with TrackScheduler

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);
}
Also used : GuildMusicManager(net.kodehawa.mantarobot.commands.music.GuildMusicManager) TrackScheduler(net.kodehawa.mantarobot.commands.music.requester.TrackScheduler)

Aggregations

TrackScheduler (net.kodehawa.mantarobot.commands.music.requester.TrackScheduler)7 GuildMusicManager (net.kodehawa.mantarobot.commands.music.GuildMusicManager)5 GuildVoiceState (net.dv8tion.jda.core.entities.GuildVoiceState)3 TextChannel (net.dv8tion.jda.core.entities.TextChannel)3 Subscribe (com.google.common.eventbus.Subscribe)2 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)2 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)2 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 AudioLoader (net.kodehawa.mantarobot.commands.music.requester.AudioLoader)1