use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class DJ method removeStar.
public void removeStar(IMessage message, IUser user) throws CommandStateException, CommandPermissionException {
if (message == null || user == null || !trackMessages.containsKey(message))
throw new CommandStateException("That track can not be found.");
AudioTrack track = trackMessages.get(message);
Playlist playlist = MusicModule.getPlaylistManager().getSelectedPlaylist(user.getLongID());
if (playlist == null)
throw new CommandStateException("You must have a selected playlist to unsave a song!");
playlist.removeSong(user, track);
}
use of com.discordbolt.boltbot.modules.music.playlists.Playlist in project BoltBot by DiscordBolt.
the class VoiceManager method queue.
public void queue(IGuild guild, IUser requester, String songID) throws CommandPermissionException, CommandRuntimeException, CommandStateException {
if (songID.toLowerCase().contains("twitch.tv") && !MusicModule.hasAdminPermissions(requester, guild))
throw new CommandPermissionException("You must be a \"" + MusicModule.ADMIN_ROLE + "\" to add Twitch.tv live streams!");
if (requester.getVoiceStateForGuild(guild).getChannel() == null)
throw new CommandStateException("You must be connected to a voice channel to execute this command!");
if (getDJ(guild).getVoiceChannel() != null && !requester.getVoiceStateForGuild(guild).getChannel().equals(getDJ(guild).getVoiceChannel()))
throw new CommandStateException("You must be in my voice channel to control the music!");
DJ dj = getDJ(guild);
if ((dj.getPlaying() != null && songID.contains(dj.getPlaying().getIdentifier())) || dj.getQueue().stream().anyMatch(t -> songID.contains(t.getIdentifier()))) {
throw new CommandStateException("That song is already in the queue!");
}
playerManager.loadItemOrdered(dj, songID, new AudioLoadResultHandler() {
@Override
public void trackLoaded(AudioTrack track) {
dj.queue(requester, track);
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
for (AudioTrack track : playlist.getTracks()) {
dj.queue(requester, track);
}
}
@Override
public void noMatches() {
throw new CommandRuntimeException("Sorry, I was unable to find the song you specified.");
}
@Override
public void loadFailed(FriendlyException exception) {
if (exception.severity == FriendlyException.Severity.COMMON)
throw new CommandRuntimeException(exception.getMessage());
throw new CommandRuntimeException("Sorry, an error occurred while loading your song. Please try again later.");
}
});
}
Aggregations