Search in sources :

Example 1 with RepeatMode

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

the class RepeatCmd 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;
    }
    RepeatMode mode = Utils.getValueOrNull(RepeatMode.class, context.getArg());
    if (context.hasArg() && !RepeatMode.PLAYLIST.equals(mode)) {
        throw new MissingArgumentException();
    }
    // By default, modification are made on song repeat mode
    if (mode == null) {
        mode = RepeatMode.SONG;
    }
    TrackScheduler scheduler = guildMusic.getScheduler();
    scheduler.setRepeatMode(scheduler.getRepeatMode().equals(mode) ? RepeatMode.NONE : mode);
    BotUtils.sendMessage(String.format("%s %sRepetition %s", scheduler.getRepeatMode().equals(RepeatMode.NONE) ? Emoji.PLAY : Emoji.REPEAT, RepeatMode.PLAYLIST.equals(mode) ? "Playlist " : "", scheduler.getRepeatMode().equals(RepeatMode.NONE) ? "disabled" : "enabled"), context.getChannel());
}
Also used : RepeatMode(me.shadorc.shadbot.music.RepeatMode) MissingArgumentException(me.shadorc.shadbot.exception.MissingArgumentException) GuildMusic(me.shadorc.shadbot.music.GuildMusic) TrackScheduler(me.shadorc.shadbot.music.TrackScheduler)

Aggregations

MissingArgumentException (me.shadorc.shadbot.exception.MissingArgumentException)1 GuildMusic (me.shadorc.shadbot.music.GuildMusic)1 RepeatMode (me.shadorc.shadbot.music.RepeatMode)1 TrackScheduler (me.shadorc.shadbot.music.TrackScheduler)1