use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.
the class QueueCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().isEmpty()) {
embedBuilder.setTitle("Nothing Queued", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (arguments != null && !arguments.isEmpty()) {
try {
int index = (Integer.parseInt(arguments.get(0)) - 1);
if (index > DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() || index < 0) {
throw new NumberFormatException();
}
Audio audio = DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().get(index);
embedBuilder.setColor(DiscordUtil.SUCCESS);
if (audio != null && audio.getAudioTrack() != null) {
embedBuilder.setTitle("Queued " + (index + 1) + ". '" + audio.getAudioTrack().getInfo().title + "'.");
} else {
embedBuilder.setTitle("Queued " + (index + 1) + ". 'Unknown" + "'.");
}
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
} catch (NumberFormatException ex) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("Supplied value is outside the queue range!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
return;
}
StringBuilder stringBuilder = new StringBuilder();
int count = 1;
for (Iterator<Audio> iterator = DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().iterator(); iterator.hasNext(); ) {
Audio audio = iterator.next();
if (count > 10) {
break;
}
if (audio.hasPlayed()) {
continue;
}
stringBuilder.append("`" + count + ". [ " + DiscordUtil.getTimestamp(audio.getAudioTrack().getInfo().length) + " ]` " + audio.getAudioTrack().getInfo().title + "\n");
count++;
}
if (stringBuilder.toString().trim().equals("")) {
embedBuilder.setTitle("Nothing Queued", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
count = DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() - count;
if (count > 0) {
embedBuilder.setFooter("and " + count + " more...", null);
}
embedBuilder.addField("Currently Queued", stringBuilder.toString(), false);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.
the class RepeatCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
if (arguments == null || arguments.isEmpty()) {
embedBuilder.setColor(DiscordUtil.DEFAULT);
embedBuilder.addField("Repeat Song", "" + DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatSong(), true);
embedBuilder.addField("Repeat Queue", "" + DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatQueue(), true);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (arguments.get(0).equalsIgnoreCase("song")) {
if (DiscordBot.getInstance().getDiscord().getAudioPlayer().isPaused() || DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("No song playing!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatSong()) {
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(false);
embedBuilder.setColor(DiscordUtil.WARNING);
embedBuilder.setTitle("No longer repeating current song.", null);
} else {
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatSong(true);
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Repeating current song.", null);
}
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (arguments.get(0).equalsIgnoreCase("queue")) {
if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().isEmpty()) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("No song in queue!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
if (DiscordBot.getInstance().getDiscord().getAudioQueue().isRepeatQueue()) {
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
embedBuilder.setColor(DiscordUtil.WARNING);
embedBuilder.setTitle("No longer repeating current queue.", null);
} else {
DiscordBot.getInstance().getDiscord().getAudioQueue().setRepeatQueue(false);
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Repeating current queue.", null);
}
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
}
use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.
the class ShuffleCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() < 2) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("The current queue is not big enough to shuffle!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
Collections.shuffle(DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue(), new Random(System.nanoTime()));
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Current queue shuffled.", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
use of net.dv8tion.jda.core.EmbedBuilder in project DiscordBot by LXGaming.
the class StopCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
embedBuilder.setColor(DiscordUtil.ERROR);
embedBuilder.setTitle("Player is not playing anything!", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
DiscordBot.getInstance().getDiscord().getAudioPlayer().stopTrack();
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle("Track stopped.", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
use of net.dv8tion.jda.core.EmbedBuilder in project MantaroBot by Mantaro.
the class ImageCmds method getImage.
private static EmbedBuilder getImage(int argsCount, String requestType, String url, String rating, String[] messageArray, GuildMessageReceivedEvent event) {
EmbedBuilder builder = new EmbedBuilder();
if (!nsfwCheck(event, false, false))
return builder.setDescription("Cannot send a lewd image in a non-nsfw channel.");
String json = Utils.wget(url, event);
try {
YandereImageData[] imageData = GsonDataManager.GSON_PRETTY.fromJson(json, YandereImageData[].class);
List<YandereImageData> filter = new ArrayList<>(Arrays.asList(imageData)).stream().filter(data -> rating.equals(data.rating)).collect(Collectors.toList());
int get;
try {
get = requestType.equals("tags") ? argsCount >= 4 ? number : r.nextInt(filter.size()) : argsCount <= 2 ? Integer.parseInt(messageArray[2]) : r.nextInt(filter.size());
} catch (IndexOutOfBoundsException e) {
get = r.nextInt(filter.size());
} catch (IllegalArgumentException e) {
if (e.getMessage().equals("bound must be positive"))
return builder.setDescription("No results found.");
else
return builder.setDescription("Query not valid.");
}
String AUTHOR = filter.get(get).getAuthor();
String tags = filter.get(get).getTags().stream().collect(Collectors.joining(", "));
if (!smallRequest) {
return builder.setAuthor("Found image", filter.get(get).getFile_url(), null).setDescription("Image uploaded by: " + (AUTHOR == null ? "not found" : AUTHOR) + ", with a rating of: **" + nRating.inverseBidiMap().get(filter.get(get).getRating()) + "**").setImage(filter.get(get).getFile_url()).addField("Height", String.valueOf(filter.get(get).getHeight()), true).addField("Width", String.valueOf(filter.get(get).getWidth()), true).addField("Tags", "``" + (tags == null ? "None" : tags) + "``", false).setFooter("If the image doesn't load, click the title.", null);
}
return builder.setAuthor("Found image", filter.get(get).getFile_url(), null).setDescription("Image uploaded by: " + (AUTHOR == null ? "not found" : AUTHOR) + ", with a rating of: **" + nRating.inverseBidiMap().get(filter.get(get).getRating()) + "**").setImage(filter.get(get).getFile_url()).addField("Width", String.valueOf(filter.get(get).getHeight()), true).addField("Height", String.valueOf(filter.get(get).getWidth()), true).addField("Tags", "``" + (tags == null ? "None" : tags) + "``", false).setFooter("If the image doesn't load, click the title.", null);
} catch (Exception ex) {
if (ex instanceof NullPointerException)
return builder.setDescription(EmoteReference.ERROR + "Wrong syntax.");
return builder.setDescription(EmoteReference.ERROR + "There are no images here, just dust.");
}
}
Aggregations