use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.
the class PlaylistCommand method playlistListCommand.
@BotCommand(command = { "playlist", "list" }, module = MusicModule.MODULE, aliases = "pl", allowPM = true, description = "List all stored playlists", usage = "Playlist list", allowedChannels = "music", args = 2)
public static void playlistListCommand(CommandContext cc) throws CommandException {
EmbedBuilder embed = new EmbedBuilder();
embed.withColor(MusicModule.EMBED_COLOR);
embed.withAuthorName("Playlists");
List<Playlist> playlists = MusicModule.getPlaylistManager().getPlaylists();
embed.withTitle("Number of Playlists:");
embed.withDescription(playlists.size() + "");
IUser currentUser = null;
StringBuilder sb = new StringBuilder();
int id = 1;
for (Playlist pl : playlists) {
if (currentUser == null || !pl.getOwnerID().equals(currentUser.getLongID())) {
if (currentUser != null)
embed.appendField(currentUser.getName(), sb.toString(), false);
sb.setLength(0);
currentUser = pl.getOwner();
}
if (sb.length() != 0)
sb.append('\n');
sb.append(id++).append(". ").append(pl.getTitle());
}
if (currentUser != null)
embed.appendField(currentUser.getName(), sb.toString(), false);
cc.replyWith(embed.build());
}
use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.
the class ListRoles method listRolesCommand.
@BotCommand(command = "ListRoles", module = "Administration", description = "List the roles of the guild and their ID.", usage = "ListRoles", permissions = Permissions.MANAGE_ROLES)
public static void listRolesCommand(CommandContext cc) {
StringBuilder sb = new StringBuilder("```");
for (IRole r : cc.getGuild().getRoles()) {
sb.append(String.format("%-33s%-18s%n", r.getName(), r.getStringID()));
}
EmbedBuilder embed = new EmbedBuilder();
embed.withAuthorName(cc.getGuild().getName() + "'s Roles");
embed.withAuthorIcon(cc.getGuild().getIconURL());
embed.withColor(36, 153, 153);
embed.setLenient(true);
embed.withFooterIcon(cc.getAuthor().getAvatarURL());
embed.withFooterText("Requested by " + cc.getAuthor().getName());
embed.appendDescription(sb.append("```").toString());
embed.withTimestamp(System.currentTimeMillis());
cc.replyWith(embed.build());
}
use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.
the class DiceModule method getDieEmbed.
private static EmbedObject getDieEmbed(int numDice, int numSides) {
int[] results = roll(numSides, numDice);
int total = Arrays.stream(results).sum();
EmbedBuilder embed = new EmbedBuilder();
embed.withColor(EMBED_COLOR);
if (numSides == 2 && numDice == 1) {
embed.withTitle(total == 1 ? "Heads" : "Tails");
} else {
embed.withTitle(Integer.toString(total));
}
if (numDice > 1) {
embed.withDescription(EmbedUtil.ZERO_WIDTH_SPACE);
embed.appendField(numDice + "d" + numSides, Arrays.stream(results).mapToObj(i -> ((Integer) i).toString()).collect(Collectors.joining(" + ")), false);
} else {
embed.withDescription(numDice + "d" + numSides);
}
embed.withThumbnail(getDieURL(numSides, total, 250));
return embed.build();
}
use of sx.blah.discord.util.EmbedBuilder in project BoltBot by DiscordBolt.
the class MusicModule method createPlayingEmbed.
public static EmbedObject createPlayingEmbed(IGuild guild, AudioTrack track) {
EmbedBuilder embed = new EmbedBuilder();
embed.withColor(MusicModule.EMBED_COLOR);
embed.withTitle(":musical_note: " + track.getInfo().title);
// embed.withAuthorUrl(track.getInfo().uri);
embed.withDescription(getVoiceManager().getTrackRequester(guild, track) != null ? "Requested by: " + getVoiceManager().getTrackRequester(guild, track) : "Unknown Requester");
if (track.getInfo().uri.toLowerCase().contains("youtu")) {
embed.withThumbnail("https://img.youtube.com/vi/" + track.getIdentifier() + "/0.jpg");
}
return embed.build();
}
use of sx.blah.discord.util.EmbedBuilder in project S-argo by Expugn.
the class WeaponScout method displayAndSave.
/**
* Displays the scout results to the channel where the command was
* requested and save the results to the user file afterwards. If
* the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
if (!SIMPLE_MESSAGE) {
scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Weapon Result -", weaponString, false);
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(139, 69, 19);
if (weapons.get(0).getRarity() == 2)
scoutMenu.withThumbnail(new GitHubImage("images/System/Brown_Chest.png").getURL());
else if (weapons.get(0).getRarity() == 3)
scoutMenu.withThumbnail(new GitHubImage("images/System/Blue_Chest.png").getURL());
else if (weapons.get(0).getRarity() == 4)
scoutMenu.withThumbnail(new GitHubImage("images/System/Red_Chest.png").getURL());
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left");
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
simpleMessage += "**" + SELECTED_BANNER.getBannerName() + "**" + "\n";
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Weapon Result -**" + "\n";
simpleMessage += weaponString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left";
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
LOGGER.debug("Saving User Data...");
USER.saveData();
deleteTempDirectory();
}
Aggregations