Search in sources :

Example 1 with TrackScheduler

use of toby.lavaplayer.TrackScheduler in project toby-bot by ml404.

the class ShuffleCommand method handle.

@Override
public void handle(CommandContext ctx, String prefix, UserDto requestingUserDto, Integer deleteDelay) {
    ICommand.deleteAfter(ctx.getMessage(), deleteDelay);
    final TextChannel channel = ctx.getChannel();
    if (requestingUserDto.hasMusicPermission()) {
        if (IMusicCommand.isInvalidChannelStateForCommand(ctx, channel, deleteDelay))
            return;
        Guild guild = ctx.getGuild();
        TrackScheduler trackScheduler = PlayerManager.getInstance().getMusicManager(guild).getScheduler();
        BlockingQueue<AudioTrack> queue = trackScheduler.getQueue();
        if (queue.size() == 0) {
            channel.sendMessage("I can't shuffle a queue that doesn't exist").queue(message -> ICommand.deleteAfter(message, deleteDelay));
            return;
        }
        LinkedBlockingQueue<AudioTrack> shuffledAudioTracks = shuffleAudioTracks(queue);
        trackScheduler.setQueue(shuffledAudioTracks);
        channel.sendMessage("The queue has been shuffled 🦧").queue(message -> ICommand.deleteAfter(message, deleteDelay));
    }
}
Also used : TextChannel(net.dv8tion.jda.api.entities.TextChannel) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) Guild(net.dv8tion.jda.api.entities.Guild) TrackScheduler(toby.lavaplayer.TrackScheduler)

Example 2 with TrackScheduler

use of toby.lavaplayer.TrackScheduler in project toby-bot by ml404.

the class LoopCommand method handle.

@Override
public void handle(CommandContext ctx, String prefix, UserDto requestingUserDto, Integer deleteDelay) {
    ICommand.deleteAfter(ctx.getMessage(), deleteDelay);
    final TextChannel channel = ctx.getChannel();
    if (!requestingUserDto.hasMusicPermission()) {
        sendErrorMessage(ctx, channel, deleteDelay);
        return;
    }
    if (IMusicCommand.isInvalidChannelStateForCommand(ctx, channel, deleteDelay))
        return;
    GuildMusicManager musicManager = PlayerManager.getInstance().getMusicManager(ctx.getGuild());
    TrackScheduler scheduler = musicManager.getScheduler();
    boolean newIsRepeating = !scheduler.isLooping();
    scheduler.setLooping(newIsRepeating);
    channel.sendMessageFormat("The Player has been set to **%s**", newIsRepeating ? "looping" : "not looping").queue(message -> ICommand.deleteAfter(message, deleteDelay));
}
Also used : TextChannel(net.dv8tion.jda.api.entities.TextChannel) GuildMusicManager(toby.lavaplayer.GuildMusicManager) TrackScheduler(toby.lavaplayer.TrackScheduler)

Aggregations

TextChannel (net.dv8tion.jda.api.entities.TextChannel)2 TrackScheduler (toby.lavaplayer.TrackScheduler)2 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 Guild (net.dv8tion.jda.api.entities.Guild)1 GuildMusicManager (toby.lavaplayer.GuildMusicManager)1