use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class BaseCommand method chooseFromList.
public EmbedBuilder chooseFromList(String title, Guild guild, User user, BaseCommand command, String... options) throws Exception {
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor(title, Ardent.gameUrl, user.getAvatarUrl());
StringBuilder description = new StringBuilder();
description.append("**" + title + "**");
for (int i = 0; i < options.length; i++) {
description.append("\n**#" + (i + 1) + "**: " + options[i]);
}
description.append("\n\n" + "Select the number of the option you want");
return builder.setDescription(description.toString());
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Status method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
Shard shard = GuildUtils.getShard(guild);
InternalStats internalStats = InternalStats.collect();
StringBuilder uptime = new StringBuilder();
long secondsUptime = internalStats.getUptime();
long days = secondsUptime / 86400;
long hours = (secondsUptime / 3600) % 24;
long minutes = (secondsUptime / 60) % 60;
long seconds = secondsUptime % 60;
if (days > 0)
uptime.append(String.valueOf(days) + " day(s), ");
if (hours > 0)
uptime.append(String.valueOf(hours) + " hour(s), ");
if (minutes > 0)
uptime.append(String.valueOf(minutes) + " minute(s), ");
uptime.append(String.valueOf(seconds) + " second(s)");
DecimalFormat formatter = new DecimalFormat("#,###");
String cmds = formatter.format(internalStats.getCommandsReceived());
Pair<Integer, Integer> musicStats = Music.getMusicStats();
EmbedBuilder embedBuilder = MessageUtils.getDefaultEmbed(user);
embedBuilder.setAuthor("Ardent Status", "https://ardentbot.tk", shard.bot.getAvatarUrl());
embedBuilder.setThumbnail("https://a.dryicons.com/images/icon_sets/polygon_icons/png/256x256/computer.png");
embedBuilder.addField("Loaded Commands", String.valueOf(shard.factory.getLoadedCommandsAmount()), true);
embedBuilder.addField("Received Messages", String.valueOf(internalStats.getMessagesReceived()), true);
embedBuilder.addField("Commands Received", cmds, true);
embedBuilder.addField("Servers", String.valueOf(internalStats.getGuilds()), true);
embedBuilder.addField("Music Players", String.valueOf(musicStats.getK()), true);
embedBuilder.addField("Queue Length", String.valueOf(musicStats.getV()), true);
embedBuilder.addField("CPU Usage", internalStats.getCpu_usage() + "%", true);
embedBuilder.addField("RAM Usage", internalStats.getUsed_ram() + " / " + internalStats.getTotal_ram() + " MB", true);
embedBuilder.addField("Uptime", uptime.toString(), true);
embedBuilder.addField("Website", "https://ardentbot.tk", true);
embedBuilder.addField("Get Help", "https://ardentbot.tk/guild", true);
sendEmbed(embedBuilder, channel, user);
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class Define method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (args.length == 1) {
sendTranslatedMessage("You need to include a word to define ^_^", channel, user);
} else {
Calendar myCal = Calendar.getInstance();
myCal.setTimeInMillis(System.currentTimeMillis());
boolean isMidnight = myCal.get(Calendar.HOUR_OF_DAY) == 0 && myCal.get(Calendar.MINUTE) == 0 && myCal.get(Calendar.SECOND) == 0 && myCal.get(Calendar.MILLISECOND) == 0;
if (isMidnight)
requests = 0;
else {
if (requests < 2000) {
Shard shard = getShard();
String query = message.getContent().replace(GuildUtils.getPrefix(guild) + args[0] + " ", "");
try {
Dictionary dictionary = shard.gson.fromJson(Unirest.get("https://wordsapiv1.p.mashape" + ".com/words/" + query + "/definitions").header("X-Mashape-Key", Ardent.mashapeKey).header("Accept", "application/json").asString().getBody(), Dictionary.class);
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor("English Dictionary", "https://ardentbot.tk", shard.bot.getAvatarUrl());
List<Definition> definitions = dictionary.getDefinitions();
StringBuilder description = new StringBuilder();
description.append("Word: **" + query + "**\n");
if (definitions.size() == 0)
description.append("There were no definitions for this word");
else {
Definition first = definitions.get(0);
description.append("Part of Speech: " + first.getPartOfSpeech() + "\n");
description.append("Definition: " + first.getDefinition());
}
builder.setDescription(description.toString());
sendEmbed(builder, channel, user);
} catch (Exception ex) {
sendTranslatedMessage("There were no definitions for this word!", channel, user);
}
} else
sendTranslatedMessage("We have hit the daily API limit for the dictionary, sorry!", channel, user);
}
}
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class AdBlock method setupSubcommands.
@Override
public void setupSubcommands() throws Exception {
subcommands.add(new Subcommand("View the Adblock settings for this server", "settings", "settings") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
AntiAdvertisingSettings settings = asPojo(r.table("anti_advertising_settings").get(guild.getId()).run(connection), AntiAdvertisingSettings.class);
if (settings == null) {
settings = new AntiAdvertisingSettings(guild.getId(), true, false);
r.table("anti_advertising_settings").insert(r.json(gson.toJson(settings))).run(connection);
}
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
String adblockSettings = "Adblock Settings";
builder.setAuthor(adblockSettings, guild.getIconUrl(), guild.getIconUrl());
StringBuilder description = new StringBuilder();
description.append("**" + adblockSettings + "**");
description.append("\nAllow users to post server invites: *" + settings.isAllow_discord_server_links() + "*");
description.append("\nBan users after they advertise twice: *" + settings.isBan_after_two_infractions() + "*");
sendEmbed(builder.setDescription(description), channel, user);
}
});
subcommands.add(new Subcommand("Allow or block users from sending server invites", "serverinvites [true/false]", "serverinvites") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
try {
AntiAdvertisingSettings settings = asPojo(r.table("anti_advertising_settings").get(guild.getId()).run(connection), AntiAdvertisingSettings.class);
boolean allow = Boolean.parseBoolean(args[2]);
if (allow) {
if (settings == null)
r.table("anti_advertising_settings").insert(r.json(gson.toJson(new AntiAdvertisingSettings(guild.getId(), true, false)))).run(connection);
else
r.table("anti_advertising_settings").get(guild.getId()).update(r.hashMap("allow_discord_server_links", true)).run(connection);
sendTranslatedMessage("People can now post Discord server invite links", channel, user);
} else {
if (settings == null)
r.table("anti_advertising_settings").insert(r.json(gson.toJson(new AntiAdvertisingSettings(guild.getId(), false, false)))).run(connection);
else
r.table("anti_advertising_settings").get(guild.getId()).update(r.hashMap("allow_discord_server_links", false)).run(connection);
sendTranslatedMessage("People now **cannot** post Discord server invite links", channel, user);
}
} catch (Exception ex) {
sendTranslatedMessage("You need to specify true or false!", channel, user);
}
}
});
subcommands.add(new Subcommand("Ban users who advertise more than twice", "banafter2ads [true/false]", "banafter2ads") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
try {
AntiAdvertisingSettings settings = asPojo(r.table("anti_advertising_settings").get(guild.getId()).run(connection), AntiAdvertisingSettings.class);
boolean yes = Boolean.parseBoolean(args[2]);
if (yes) {
if (settings == null)
r.table("anti_advertising_settings").insert(r.json(gson.toJson(new AntiAdvertisingSettings(guild.getId(), false, true)))).run(connection);
else
r.table("anti_advertising_settings").get(guild.getId()).update(r.hashMap("ban_after_two_infractions", true)).run(connection);
sendTranslatedMessage("I will now ban users if they advertise more than twice", channel, user);
} else {
if (settings == null)
r.table("anti_advertising_settings").insert(r.json(gson.toJson(new AntiAdvertisingSettings(guild.getId(), true, false)))).run(connection);
else
r.table("anti_advertising_settings").get(guild.getId()).update(r.hashMap("ban_after_two_infractions", false)).run(connection);
sendTranslatedMessage("I won't ban members after 2 advertising infractions", channel, user);
}
} catch (Exception ex) {
sendTranslatedMessage("You need to specify true or false!", channel, user);
}
}
});
}
use of net.dv8tion.jda.core.EmbedBuilder in project Ardent by adamint.
the class About method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor("Ardent About", getShard().url, getShard().bot.getAvatarUrl());
StringBuilder description = new StringBuilder();
description.append("**What's this embed? ;O**\n\n").append("Ardent was a small project started by Adam#9261 in December of 2016 to have some " + "fun programming and play music.\n\n").append("In March, we had our second developer, Akio, join us, and we've been blessed to have had an " + "amazing community of staff and members, who are listed below.\n\n");
String devs = MessageUtils.listWithCommas(UserUtils.getNamesById(Ardent.developers));
String moderators = MessageUtils.listWithCommas(UserUtils.getNamesById(Ardent.moderators));
String translators = MessageUtils.listWithCommas(UserUtils.getNamesById(Ardent.translators));
ArrayList<String> patronsList = new ArrayList<>();
patronsList.addAll(Ardent.tierOnepatrons);
patronsList.addAll(Ardent.tierTwopatrons);
patronsList.addAll(Ardent.tierThreepatrons);
String patrons = MessageUtils.listWithCommas(UserUtils.getNamesById(patronsList));
description.append("**Developers**: *" + devs + "*\n").append("**Moderators**: *" + moderators + "*\n").append("**Translators**: *" + translators + "*\n").append("**Patrons**: *" + patrons + "*");
builder.setDescription(description);
sendEmbed(builder, channel, user);
}
Aggregations