diff --git a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java index 4fde208..d1bc9b4 100644 --- a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java +++ b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java @@ -1,9 +1,13 @@ package net.Broken.Tools; +import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import net.Broken.MainBot; +import net.Broken.audio.UserAudioTrack; import net.Broken.audio.Youtube.SearchResult; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.User; import java.awt.*; import java.io.FileNotFoundException; @@ -17,22 +21,52 @@ import java.util.Map; public class EmbedMessageUtils { public static EmbedBuilder getError(String message) { - EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message); + EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error!").setColor(Color.red).setDescription(message); return temp; } public static MessageEmbed getMusicError(String message) { - return new EmbedBuilder().setTitle(":warning: Musique Error :warning:").setDescription(":arrow_right: " + message).setFooter("'//help music' for more info.", MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).setColor(Color.red).setFooter(MainBot.url, MainBot.jda.getSelfUser().getAvatarUrl()).build(); + return new EmbedBuilder().setTitle(":warning: Musique Error").setDescription(":arrow_right: " + message).setFooter("'//help music' for more info.", MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).setColor(Color.red).setFooter(MainBot.url, MainBot.jda.getSelfUser().getAvatarUrl()).build(); } public static MessageEmbed getMusicOk(String message) { - EmbedBuilder temp = new EmbedBuilder().setTitle(":loud_sound: Music :loud_sound:").setDescription(message).setColor(Color.green); +// TODO better display for different action (add icon ?) + EmbedBuilder temp = new EmbedBuilder().setTitle(":loud_sound: " + message).setColor(Color.green); + return buildStandar(temp); + } + + public static MessageEmbed getMusicInfo(AudioTrackInfo info, UserAudioTrack userAudioTrack) { + EmbedBuilder temp = new EmbedBuilder().setTitle(":loud_sound: Currently playing") + .addField("Title", info.title, false) + .addField("Author", info.author, false) + .addField("URL", info.uri, false) + .addField("Submitted by", userAudioTrack.getSubmittedUser().getName(), false) + .setThumbnail("https://img.youtube.com/vi/" + info.identifier + "/hqdefault.jpg") + .setColor(Color.green); + return buildStandar(temp); + } + + public static MessageEmbed getMusicAdded(AudioTrackInfo info, Member member, int playlistSize){ + EmbedBuilder temp = new EmbedBuilder() + .addField("Title", info.title, false) + .addField("Author", info.author, false) + .addField("Submitted by", member.getEffectiveName(), true) + .setThumbnail("https://img.youtube.com/vi/" + info.identifier + "/hqdefault.jpg") + .setColor(Color.green); + if(playlistSize != -1){ + temp.addField("Loaded tracks", Integer.toString(playlistSize), true) + .setTitle(":loud_sound: Playlist added to queue"); + } + else { + temp.setTitle(":loud_sound: Track added to queue"); + } + temp.addField("URL", info.uri, false); return buildStandar(temp); } public static MessageEmbed getFlushError(String message) { - return buildStandar(new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red)); + return buildStandar(new EmbedBuilder().setTitle(":warning: Flush Error").setDescription(message).setColor(Color.red)); } @@ -57,7 +91,7 @@ public class EmbedMessageUtils { } public static MessageEmbed getReportUsersError() { - return new EmbedBuilder().setTitle(":warning: Command error :warning: ").setDescription("").setColor(Color.red).setFooter("'//help move' for more info.", MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).build(); + return new EmbedBuilder().setTitle(":warning: Command error").setDescription("").setColor(Color.red).setFooter("'//help move' for more info.", MainBot.jda.getSelfUser().getAvatarUrl()).setTimestamp(Instant.now()).build(); } diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/audio/AudioM.java index 3d922d9..3fe8426 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/audio/AudioM.java @@ -11,6 +11,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import net.Broken.MainBot; import net.Broken.RestApi.Data.UserAudioTrackData; import net.Broken.Tools.EmbedMessageUtils; +import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Message; @@ -86,7 +87,9 @@ public class AudioM { public void trackLoaded(AudioTrack track) { logger.info("[" + guild + "] Single Track detected!"); UserAudioTrack uat = new UserAudioTrack(event.getUser(), track); - Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Add " + track.getInfo().title + " to playlist")).build(); + Message message = new MessageBuilder() + .setEmbeds(EmbedMessageUtils.getMusicAdded(track.getInfo(), event.getMember(), -1)) + .build(); event.getHook().sendMessage(message).queue(); play(guild, voiceChannel, musicManager, uat, onHead); } @@ -95,7 +98,10 @@ public class AudioM { public void playlistLoaded(AudioPlaylist playlist) { logger.info("[" + guild + "] Playlist detected! Limit: " + playlistLimit); AudioTrack firstTrack = playlist.getSelectedTrack(); - Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk("Add " + firstTrack.getInfo().title + " and 30 first videos to playlist !")).build(); + int size = Math.min(playlist.getTracks().size(), playlistLimit); + Message message = new MessageBuilder() + .setEmbeds(EmbedMessageUtils.getMusicAdded(firstTrack.getInfo(), event.getMember(), size)) + .build(); event.getHook().sendMessage(message).queue(); playListLoader(playlist, playlistLimit, event.getUser(), onHead); } @@ -247,7 +253,7 @@ public class AudioM { GuildMusicManager musicManager = getGuildAudioPlayer(); AudioTrackInfo info = musicManager.scheduler.getInfo(); UserAudioTrack userAudioTrack = musicManager.scheduler.getCurrentPlayingTrack(); - Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicOk(info.title + "\n" + info.uri + "\nSubmitted by: " + userAudioTrack.getSubmittedUser().getName())).build(); + Message message = new MessageBuilder().setEmbeds(EmbedMessageUtils.getMusicInfo(info, userAudioTrack)).build(); event.getHook().sendMessage(message).queue(); }