use of me.shadorc.shadbot.music.TrackScheduler 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());
}
use of me.shadorc.shadbot.music.TrackScheduler in project Shadbot by Shadorc.
the class VolumeCmd 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;
}
TrackScheduler scheduler = guildMusic.getScheduler();
if (!context.hasArg()) {
BotUtils.sendMessage(String.format(Emoji.SOUND + " Current volume level: **%d%%**", scheduler.getAudioPlayer().getVolume()), context.getChannel());
return;
}
Integer volume = CastUtils.asPositiveInt(context.getArg());
if (volume == null) {
throw new IllegalCmdArgumentException(String.format("`%s` is not a valid volume.", context.getArg()));
}
scheduler.setVolume(volume);
BotUtils.sendMessage(String.format(Emoji.SOUND + " Volume level set to **%s%%**", scheduler.getAudioPlayer().getVolume()), context.getChannel());
}
Aggregations