Search in sources :

Example 11 with GuildMusic

use of me.shadorc.shadbot.music.GuildMusic in project Shadbot by Shadorc.

the class BackwardCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
    GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(context.getGuild().getLongID());
    if (guildMusic == null || guildMusic.getScheduler().isStopped()) {
        BotUtils.sendMessage(TextUtils.NO_PLAYING_MUSIC, context.getChannel());
        return;
    }
    if (!context.hasArg()) {
        throw new MissingArgumentException();
    }
    Long num = CastUtils.asPositiveLong(context.getArg());
    if (num == null) {
        try {
            num = TimeUtils.parseTime(context.getArg());
        } catch (IllegalArgumentException err) {
            throw new IllegalCmdArgumentException(String.format("`%s` is not a valid number / time.", context.getArg()));
        }
    }
    long newPosition = guildMusic.getScheduler().changePosition(-TimeUnit.SECONDS.toMillis(num));
    BotUtils.sendMessage(String.format(Emoji.CHECK_MARK + " New position: **%s**", FormatUtils.formatShortDuration(newPosition)), context.getChannel());
}
Also used : IllegalCmdArgumentException(me.shadorc.shadbot.exception.IllegalCmdArgumentException) MissingArgumentException(me.shadorc.shadbot.exception.MissingArgumentException) GuildMusic(me.shadorc.shadbot.music.GuildMusic)

Example 12 with GuildMusic

use of me.shadorc.shadbot.music.GuildMusic in project Shadbot by Shadorc.

the class ClearCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException {
    GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(context.getGuild().getLongID());
    if (guildMusic == null || guildMusic.getScheduler().isStopped()) {
        BotUtils.sendMessage(TextUtils.NO_PLAYING_MUSIC, context.getChannel());
        return;
    }
    guildMusic.getScheduler().clearPlaylist();
    BotUtils.sendMessage(Emoji.CHECK_MARK + " Playlist cleared.", context.getChannel());
}
Also used : GuildMusic(me.shadorc.shadbot.music.GuildMusic)

Example 13 with GuildMusic

use of me.shadorc.shadbot.music.GuildMusic in project Shadbot by Shadorc.

the class ForwardCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException, IllegalCmdArgumentException {
    GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(context.getGuild().getLongID());
    if (guildMusic == null || guildMusic.getScheduler().isStopped()) {
        BotUtils.sendMessage(TextUtils.NO_PLAYING_MUSIC, context.getChannel());
        return;
    }
    if (!context.hasArg()) {
        throw new MissingArgumentException();
    }
    Long num = CastUtils.asPositiveLong(context.getArg());
    if (num == null) {
        try {
            num = TimeUtils.parseTime(context.getArg());
        } catch (IllegalArgumentException err) {
            throw new IllegalCmdArgumentException(String.format("`%s` is not a valid number / time.", context.getArg()));
        }
    }
    long newPosition = guildMusic.getScheduler().changePosition(TimeUnit.SECONDS.toMillis(num));
    BotUtils.sendMessage(String.format(Emoji.CHECK_MARK + " New position: **%s**", FormatUtils.formatShortDuration(newPosition)), context.getChannel());
}
Also used : IllegalCmdArgumentException(me.shadorc.shadbot.exception.IllegalCmdArgumentException) MissingArgumentException(me.shadorc.shadbot.exception.MissingArgumentException) GuildMusic(me.shadorc.shadbot.music.GuildMusic)

Example 14 with GuildMusic

use of me.shadorc.shadbot.music.GuildMusic in project Shadbot by Shadorc.

the class PauseCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException {
    GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(context.getGuild().getLongID());
    if (guildMusic == null || guildMusic.getScheduler().isStopped()) {
        BotUtils.sendMessage(TextUtils.NO_PLAYING_MUSIC, context.getChannel());
        return;
    }
    AudioPlayer audioPlayer = guildMusic.getScheduler().getAudioPlayer();
    audioPlayer.setPaused(!audioPlayer.isPaused());
    if (audioPlayer.isPaused()) {
        BotUtils.sendMessage(String.format(Emoji.PAUSE + " Music paused by **%s**.", context.getAuthorName()), context.getChannel());
    } else {
        BotUtils.sendMessage(String.format(Emoji.PLAY + " Music resumed by **%s**.", context.getAuthorName()), context.getChannel());
    }
}
Also used : AudioPlayer(com.sedmelluq.discord.lavaplayer.player.AudioPlayer) GuildMusic(me.shadorc.shadbot.music.GuildMusic)

Example 15 with GuildMusic

use of me.shadorc.shadbot.music.GuildMusic in project Shadbot by Shadorc.

the class PlaylistCmd method execute.

@Override
public void execute(Context context) throws MissingArgumentException {
    GuildMusic guildMusic = GuildMusicManager.GUILD_MUSIC_MAP.get(context.getGuild().getLongID());
    if (guildMusic == null || guildMusic.getScheduler().isStopped()) {
        BotUtils.sendMessage(TextUtils.NO_PLAYING_MUSIC, context.getChannel());
        return;
    }
    EmbedBuilder embed = EmbedUtils.getDefaultEmbed().withAuthorName("Playlist").withThumbnail("http://icons.iconarchive.com/icons/dtafalonso/yosemite-flat/512/Music-icon.png").appendDescription(this.formatPlaylist(guildMusic.getScheduler().getPlaylist()));
    BotUtils.sendMessage(embed.build(), context.getChannel());
}
Also used : EmbedBuilder(sx.blah.discord.util.EmbedBuilder) GuildMusic(me.shadorc.shadbot.music.GuildMusic)

Aggregations

GuildMusic (me.shadorc.shadbot.music.GuildMusic)15 IllegalCmdArgumentException (me.shadorc.shadbot.exception.IllegalCmdArgumentException)6 MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)5 TrackScheduler (me.shadorc.shadbot.music.TrackScheduler)2 IVoiceChannel (sx.blah.discord.handle.obj.IVoiceChannel)2 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)1 AudioLoadResultListener (me.shadorc.shadbot.listener.music.AudioLoadResultListener)1 RepeatMode (me.shadorc.shadbot.music.RepeatMode)1 IGuild (sx.blah.discord.handle.obj.IGuild)1 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)1