Search in sources :

Example 21 with AudioTrackInfo

use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project Ardent by adamint.

the class TrackScheduler method onTrackStart.

@Override
public void onTrackStart(AudioPlayer player, AudioTrack track) {
    if (manager.isShouldAnnounce()) {
        if (manager.getLastAnnouncementId() != null) {
            try {
                manager.getChannel().getMessageById(manager.getLastAnnouncementId()).queue(message -> message.delete().queue());
            } catch (Exception ignored) {
            }
        }
        User me = manager.getChannel().getGuild().getSelfMember().getUser();
        AudioTrackInfo info = track.getInfo();
        EmbedBuilder builder = MessageUtils.getDefaultEmbed(me);
        builder.setAuthor("Now playing " + info.title, "https://ardentbot.tk", "https://s-media-cache-ak0.pinimg" + ".com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.setThumbnail("https://s-media-cache-ak0.pinimg.com/736x/69/96/5c/69965c2849ec9b7148a5547ce6714735.jpg");
        builder.addField("Title", info.title, true).addField("Author", info.author, true).addField("Duration", Music.getDuration(track), true).addField("URL", info.uri, true).addField("Is Stream", String.valueOf(info.isStream), true);
        Message m = GuildUtils.getShard(manager.getChannel().getJDA()).help.sendEmbed(builder, manager.getChannel(), me);
        manager.setLastAnnouncementId(m.getId());
    }
}
Also used : EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) User(net.dv8tion.jda.core.entities.User) Message(net.dv8tion.jda.core.entities.Message) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) BotException(tk.ardentbot.core.misc.logging.BotException)

Example 22 with AudioTrackInfo

use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo 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)

Aggregations

AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)22 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)7 MediaContainerDetectionResult (com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult)6 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)6 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)5 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)3 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)3 JsonBrowser (com.sedmelluq.discord.lavaplayer.tools.JsonBrowser)2 List (java.util.List)2 Optional (java.util.Optional)2 TimeUnit (java.util.concurrent.TimeUnit)2 Slf4j (lombok.extern.slf4j.Slf4j)2 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)2 Message (net.dv8tion.jda.core.entities.Message)2 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)2 MantaroData (net.kodehawa.mantarobot.data.MantaroData)2 DBGuild (net.kodehawa.mantarobot.data.entities.DBGuild)2 GuildData (net.kodehawa.mantarobot.data.entities.helpers.GuildData)2 DiscordUtils (net.kodehawa.mantarobot.utils.DiscordUtils)2 Utils (net.kodehawa.mantarobot.utils.Utils)2