Search in sources :

Example 11 with Playlist

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);
}
Also used : Playlist(com.discordbolt.boltbot.modules.music.playlists.Playlist) CommandStateException(com.discordbolt.api.command.exceptions.CommandStateException) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Example 12 with Playlist

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.");
        }
    });
}
Also used : ExceptionMessage(com.discordbolt.boltbot.utils.ExceptionMessage) com.discordbolt.api.command.exceptions(com.discordbolt.api.command.exceptions) HashMap(java.util.HashMap) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) MissingPermissionsException(sx.blah.discord.util.MissingPermissionsException) ReactionRemoveEvent(sx.blah.discord.handle.impl.events.guild.channel.message.reaction.ReactionRemoveEvent) IVoiceChannel(sx.blah.discord.handle.obj.IVoiceChannel) IMessage(sx.blah.discord.handle.obj.IMessage) IUser(sx.blah.discord.handle.obj.IUser) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) DefaultAudioPlayerManager(com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager) Semaphore(java.util.concurrent.Semaphore) ReactionAddEvent(sx.blah.discord.handle.impl.events.guild.channel.message.reaction.ReactionAddEvent) EventSubscriber(sx.blah.discord.api.events.EventSubscriber) Playlist(com.discordbolt.boltbot.modules.music.playlists.Playlist) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) AudioConfiguration(com.sedmelluq.discord.lavaplayer.player.AudioConfiguration) AudioPlayerManager(com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager) ChannelUtil(com.discordbolt.boltbot.utils.ChannelUtil) IGuild(sx.blah.discord.handle.obj.IGuild) List(java.util.List) MusicModule(com.discordbolt.boltbot.modules.music.MusicModule) AudioSourceManagers(com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) StandardAudioDataFormats(com.sedmelluq.discord.lavaplayer.format.StandardAudioDataFormats) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException)

Aggregations

Playlist (com.discordbolt.boltbot.modules.music.playlists.Playlist)12 BotCommand (com.discordbolt.api.command.BotCommand)9 CommandStateException (com.discordbolt.api.command.exceptions.CommandStateException)8 CommandArgumentException (com.discordbolt.api.command.exceptions.CommandArgumentException)4 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)2 IUser (sx.blah.discord.handle.obj.IUser)2 com.discordbolt.api.command.exceptions (com.discordbolt.api.command.exceptions)1 MusicModule (com.discordbolt.boltbot.modules.music.MusicModule)1 ChannelUtil (com.discordbolt.boltbot.utils.ChannelUtil)1 ExceptionMessage (com.discordbolt.boltbot.utils.ExceptionMessage)1 StandardAudioDataFormats (com.sedmelluq.discord.lavaplayer.format.StandardAudioDataFormats)1 AudioConfiguration (com.sedmelluq.discord.lavaplayer.player.AudioConfiguration)1 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)1 AudioPlayerManager (com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager)1 DefaultAudioPlayerManager (com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager)1 AudioSourceManagers (com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers)1 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)1 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)1 HashMap (java.util.HashMap)1 List (java.util.List)1