Search in sources :

Example 11 with AudioManager

use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.

the class Resume method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    AudioManager audioManager = guild.getAudioManager();
    Member member = guild.getMember(user);
    if (UserUtils.hasManageServerOrStaff(member) || UserUtils.isBotCommander(member)) {
        if (audioManager.isConnected()) {
            GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
            if (manager.player.isPaused()) {
                sendTranslatedMessage("Resumed music playback", sendTo(channel, guild), user);
                manager.player.setPaused(false);
            } else {
                sendTranslatedMessage("The player isn't paused", channel, user);
            }
        } else
            sendTranslatedMessage("I'm not in a voice channel!", channel, user);
    } else
        sendTranslatedMessage("You need the Manage Server permission to do this", channel, user);
}
Also used : AudioManager(net.dv8tion.jda.core.managers.AudioManager)

Example 12 with AudioManager

use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.

the class Shuffle method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    AudioManager audioManager = guild.getAudioManager();
    Member member = guild.getMember(user);
    if (UserUtils.hasManageServerOrStaff(member) || UserUtils.isBotCommander(member) || (audioManager.isConnected() && audioManager.getConnectedChannel().getMembers().size() == 2)) {
        if (audioManager.isConnected()) {
            GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
            manager.scheduler.manager.shuffle();
            sendTranslatedMessage("Shuffled the queue!", sendTo(channel, guild), user);
        } else
            sendTranslatedMessage("I'm not in a voice channel!", channel, user);
    } else
        sendTranslatedMessage("You need the Manage Server permission to do this", channel, user);
}
Also used : AudioManager(net.dv8tion.jda.core.managers.AudioManager)

Example 13 with AudioManager

use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.

the class Skip method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    AudioManager audioManager = guild.getAudioManager();
    Member member = guild.getMember(user);
    if (audioManager.isConnected()) {
        GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
        ArdentMusicManager ardentMusicManager = manager.scheduler.manager;
        ArdentTrack track = ardentMusicManager.getCurrentlyPlaying();
        if (track != null) {
            String ownerId = track.getAuthor();
            if (ownerId == null)
                ownerId = "";
            if (UserUtils.hasManageServerOrStaff(member) || UserUtils.isBotCommander(member) || user.getId().equalsIgnoreCase(ownerId)) {
                ardentMusicManager.nextTrack();
                sendTranslatedMessage("Skipped the playing song", sendTo(channel, guild), user);
            } else {
                sendTranslatedMessage("You need to have queued the song or have the Manage Server permission", sendTo(channel, guild), user);
            }
        }
    } else
        sendTranslatedMessage("I'm not in a voice channel!", channel, user);
}
Also used : AudioManager(net.dv8tion.jda.core.managers.AudioManager)

Example 14 with AudioManager

use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.

the class GetUrl method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    AudioManager audioManager = guild.getAudioManager();
    if (audioManager.isConnected()) {
        try {
            GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
            BlockingQueue<ArdentTrack> queue = manager.scheduler.manager.getQueue();
            if (args.length > 1) {
                int numberToRemove = Integer.parseInt(args[1]) - 1;
                if (numberToRemove >= queue.size() || numberToRemove < 0)
                    sendTranslatedMessage("Invalid arguments", channel, user);
                else {
                    Iterator<ArdentTrack> iterator = queue.iterator();
                    int current = 0;
                    while (iterator.hasNext()) {
                        ArdentTrack ardentTrack = iterator.next();
                        AudioTrack track = ardentTrack.getTrack();
                        AudioTrackInfo info = track.getInfo();
                        String name = info.title;
                        if (current == numberToRemove) {
                            sendTranslatedMessage("The streaming link for {0} is {1}".replace("{0}", info.title).replace("{1}", info.uri), channel, user);
                            return;
                        }
                        current++;
                    }
                }
            } else {
                ArdentMusicManager musicManager = manager.scheduler.manager;
                ArdentTrack track = musicManager.getCurrentlyPlaying();
                if (track != null) {
                    AudioTrackInfo info = track.getTrack().getInfo();
                    sendTranslatedMessage("The streaming link for {0} is {1}".replace("{0}", info.title).replace("{1}", info.uri), channel, user);
                } else {
                    sendTranslatedMessage("I'm not playing anything right now!", channel, user);
                }
            }
        } catch (NumberFormatException ex) {
            sendTranslatedMessage("Invalid arguments", channel, user);
        }
    } else
        sendTranslatedMessage("I'm not in a voice channel!", channel, user);
}
Also used : AudioManager(net.dv8tion.jda.core.managers.AudioManager) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 15 with AudioManager

use of net.dv8tion.jda.core.managers.AudioManager in project Ardent by adamint.

the class ClearQueue method noArgs.

@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
    AudioManager audioManager = guild.getAudioManager();
    Member member = guild.getMember(user);
    if (UserUtils.hasManageServerOrStaff(member) || (audioManager.isConnected() && audioManager.getConnectedChannel().getMembers().size() == 2)) {
        if (audioManager.isConnected()) {
            GuildMusicManager manager = getGuildAudioPlayer(guild, channel);
            manager.scheduler.manager.resetQueue();
            sendTranslatedMessage("Cleared all songs from the queue", channel, user);
        } else
            sendTranslatedMessage("I'm not in a voice channel!", channel, user);
    } else
        sendTranslatedMessage("You need the Manage Server permission to do this", channel, user);
}
Also used : AudioManager(net.dv8tion.jda.core.managers.AudioManager)

Aggregations

AudioManager (net.dv8tion.jda.core.managers.AudioManager)17 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)4 net.dv8tion.jda.core.entities (net.dv8tion.jda.core.entities)3 Command (tk.ardentbot.core.executor.Command)3 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)2 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)2 ArrayList (java.util.ArrayList)2 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)2 PermissionException (net.dv8tion.jda.core.exceptions.PermissionException)2 Music (tk.ardentbot.commands.music.Music)2 Music.getGuildAudioPlayer (tk.ardentbot.commands.music.Music.getGuildAudioPlayer)2 GuildUtils (tk.ardentbot.utils.discord.GuildUtils)2 AudioEventAdapter (com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter)1 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)1 AudioTrackEndReason (com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason)1 AudioTrackState (com.sedmelluq.discord.lavaplayer.track.AudioTrackState)1 RecommendationsRequest (com.wrapper.spotify.methods.RecommendationsRequest)1 TrackSearchRequest (com.wrapper.spotify.methods.TrackSearchRequest)1 Track (com.wrapper.spotify.models.Track)1 Collections (java.util.Collections)1