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