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