Search in sources :

Example 26 with GuildPlayer

use of fredboat.audio.player.GuildPlayer in project FredBoat by Frederikam.

the class RestartCommand method onInvoke.

@Override
public void onInvoke(@Nonnull CommandContext context) {
    GuildPlayer player = Launcher.getBotController().getPlayerRegistry().getExisting(context.guild);
    if (player != null && !player.isQueueEmpty()) {
        if (player.getPlayingTrack() == null) {
            player.play();
        }
        player.seekTo(player.getPlayingTrack().getStartPosition());
        context.reply(context.i18nFormat("restartSuccess", TextUtils.escapeAndDefuse(player.getPlayingTrack().getEffectiveTitle())));
    } else {
        context.replyWithName(context.i18n("queueEmpty"));
    }
}
Also used : GuildPlayer(fredboat.audio.player.GuildPlayer)

Example 27 with GuildPlayer

use of fredboat.audio.player.GuildPlayer in project FredBoat by Frederikam.

the class LeaveCommand method onInvoke.

@Override
public void onInvoke(@Nonnull CommandContext context) {
    try {
        GuildPlayer player = Launcher.getBotController().getPlayerRegistry().getExisting(context.guild);
        if (player != null) {
            player.pause();
            player.leaveVoiceChannelRequest(context, false);
        }
    } catch (Exception e) {
        log.error("Something caused us to not properly leave a voice channel!", e);
        Launcher.getBotController().getAudioConnectionFacade().closeConnection(context.guild);
    }
}
Also used : GuildPlayer(fredboat.audio.player.GuildPlayer)

Example 28 with GuildPlayer

use of fredboat.audio.player.GuildPlayer in project FredBoat by Frederikam.

the class PlaySplitCommand method onInvoke.

@Override
public void onInvoke(@Nonnull CommandContext context) {
    if (!context.hasArguments()) {
        HelpCommand.sendFormattedCommandHelp(context);
        return;
    }
    PlayerRegistry playerRegistry = Launcher.getBotController().getPlayerRegistry();
    if (!playerLimiter.checkLimitResponsive(context, playerRegistry))
        return;
    IdentifierContext ic = new IdentifierContext(Launcher.getBotController().getJdaEntityProvider(), context.args[0], context.channel, context.invoker);
    ic.setSplit(true);
    GuildPlayer player = playerRegistry.getOrCreate(context.guild);
    player.queue(ic);
    player.setPause(false);
    context.deleteMessage();
}
Also used : GuildPlayer(fredboat.audio.player.GuildPlayer) PlayerRegistry(fredboat.audio.player.PlayerRegistry) IdentifierContext(fredboat.audio.queue.IdentifierContext)

Example 29 with GuildPlayer

use of fredboat.audio.player.GuildPlayer in project FredBoat by Frederikam.

the class ReshuffleCommand method onInvoke.

@Override
public void onInvoke(@Nonnull CommandContext context) {
    GuildPlayer player = Launcher.getBotController().getPlayerRegistry().getExisting(context.guild);
    if (player == null || !player.isShuffle()) {
        context.replyWithName(context.i18n("reshufflePlayerNotShuffling"));
        return;
    }
    player.reshuffle();
    context.reply(context.i18n("reshufflePlaylist"));
}
Also used : GuildPlayer(fredboat.audio.player.GuildPlayer)

Aggregations

GuildPlayer (fredboat.audio.player.GuildPlayer)29 AudioTrackContext (fredboat.audio.queue.AudioTrackContext)9 ArrayList (java.util.ArrayList)5 Member (net.dv8tion.jda.core.entities.Member)5 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)5 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)4 TextChannel (net.dv8tion.jda.core.entities.TextChannel)4 Command (fredboat.commandmeta.abs.Command)3 CommandContext (fredboat.commandmeta.abs.CommandContext)3 Launcher (fredboat.main.Launcher)3 Context (fredboat.messaging.internal.Context)3 TextUtils (fredboat.util.TextUtils)3 Nonnull (javax.annotation.Nonnull)3 Guild (net.dv8tion.jda.core.entities.Guild)3 JSONObject (org.json.JSONObject)3 PlayerRegistry (fredboat.audio.player.PlayerRegistry)2 SplitAudioTrackContext (fredboat.audio.queue.SplitAudioTrackContext)2 MessagingException (fredboat.commandmeta.MessagingException)2 ICommandRestricted (fredboat.commandmeta.abs.ICommandRestricted)2 PermissionLevel (fredboat.definitions.PermissionLevel)2