use of net.dv8tion.jda.core.EmbedBuilder 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());
}
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Command method getHelp.
private EmbedBuilder getHelp(Guild guild, User author) throws Exception {
Shard shard = GuildUtils.getShard(guild);
EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(author);
String name = getName();
name = name.substring(0, 1).toUpperCase() + name.substring(1);
embedBuilder.setAuthor(name, shard.url, shard.bot.getAvatarUrl());
StringBuilder description = new StringBuilder();
description.append(getDescription());
if (subcommands.size() > 0) {
description.append("\n\n**Subcommands**\n");
for (Subcommand subcommand : subcommands) {
description.append(subcommand.getSyntax() + ": *" + subcommand.getDescription() + "*\n");
}
description.append("\n**Example**:");
description.append("\n/" + name.toLowerCase() + " " + subcommands.get(0).getSyntax());
}
if (aliases != null && aliases.length > 0) {
description.append("\n**Aliases**:\n");
description.append(MessageUtils.listWithCommas(Arrays.asList(aliases)));
}
embedBuilder.setDescription(description.toString());
return embedBuilder;
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class MessageUtils method getDefaultEmbed.
public static EmbedBuilder getDefaultEmbed(User author) {
try {
final Random random = new Random();
final float hue = random.nextFloat();
final float saturation = (random.nextInt(2000) + 1000) / 10000f;
final float luminance = 2f;
final Color color = Color.getHSBColor(hue, saturation, luminance);
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(color);
builder.setFooter("Requested by {0}".replace("{0}", author.getName() + "#" + author.getDiscriminator()), author.getAvatarUrl());
return builder;
} catch (Exception e) {
new BotException(e);
return null;
}
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Music method getMusicEmbed.
private EmbedBuilder getMusicEmbed(Guild guild, User user) throws Exception {
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor(WordUtils.capitalize(getName()), getShard().url, guild.getSelfMember().getUser().getAvatarUrl());
return builder;
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class UD method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
Shard shard = GuildUtils.getShard(guild);
if (args.length == 1) {
sendTranslatedMessage("Search a word's definition from Urban Dictionary. Example: {0}ud test".replace("{0}", GuildUtils.getPrefix(guild)), channel, user);
} else {
GetRequest getRequest = Unirest.get("http://api.urbandictionary.com/v0/define?term=" + message.getRawContent().replace(GuildUtils.getPrefix(guild) + args[0] + " ", "").replaceAll(" ", "%20"));
String json = "";
try {
json = getRequest.asJson().getBody().toString();
} catch (UnirestException e) {
e.printStackTrace();
}
UrbanDictionary definition = shard.gson.fromJson(json, UrbanDictionary.class);
if (definition.getList().size() == 0) {
sendTranslatedMessage("There aren't any definitions for this word!", channel, user);
} else {
EmbedBuilder builder = MessageUtils.getDefaultEmbed(message.getAuthor());
UDList list = definition.getList().get(0);
String def = "Definition";
String author = "Author";
String example = "Example";
String link = "Link";
String thumbsUp = "Thumbs Up";
String thumbsDown = "Thumbs Down";
String urbanDictionary = "Urban Dictionary";
builder.setAuthor(urbanDictionary, shard.bot.getAvatarUrl(), shard.bot.getAvatarUrl());
builder.setThumbnail("https://i.gyazo.com/6a40e32928743e68e9006396ee7c2a14.jpg");
builder.setColor(Color.decode("#00B7BE"));
String definitionText = list.getDefinition();
String exampleText = list.getExample();
if (definitionText.length() > 1024)
definitionText = definitionText.substring(0, 1023);
if (exampleText.length() > 1024)
exampleText = exampleText.substring(0, 1023);
builder.addField(def, definitionText, true);
builder.addField(example, exampleText, true);
builder.addField(thumbsUp, String.valueOf(list.getThumbsUp() + ":thumbsup:"), true);
builder.addField(thumbsDown, String.valueOf(list.getThumbsDown() + ":thumbsdown:"), true);
builder.addField(author, list.getAuthor(), true);
builder.addField(link, list.getPermalink(), true);
sendEmbed(builder, channel, user);
}
}
}
Aggregations