/** * Sets the Title of the embed. * <br>Overload for {@link #setTitle(String, String)} without URL parameter. * * <p><b><a href="http://i.imgur.com/JgZtxIM.png">Example</a></b> * * @param title * the title of the embed * * @throws java.lang.IllegalArgumentException * <ul> * <li>If the provided {@code title} is an empty String.</li> * <li>If the length of {@code title} is greater than {@link net.dv8tion.jda.core.entities.MessageEmbed#TITLE_MAX_LENGTH}.</li> * </ul> * * @return the builder after the title has been set */ public EmbedBuilder setTitle(String title) { return setTitle(title, null); }
public PlaceholderMessage setTitle(String title, String url) { builder.setTitle(trimString(title, MessageEmbed.TITLE_MAX_LENGTH), url); return this; }
/** * Builds the "Thanks for Voting" message with the given title, * and the given amount of vote points for the user. * * @param title The title that should be used for the message. * @param points The amounts of points that should be displayed in the message. * @return The JDA message embed object with the thanks for voting message. */ public MessageEmbed buildThanksForVotingMessage(@Nonnull String title, int points) { return MessageFactory.createEmbeddedBuilder() .setColor(Color.decode("#E91E63")) .setTitle(title, "https://discordbots.org/bot/avaire") .setFooter("Don't want to receive messages when you vote? use \"!voteopt out\"", null) .setDescription(String.format( "Thanks for voting for [AvaIre](https://discordbots.org/bot/avaire)! It's really appreciated ❤" + "\nYou now have **%s** vote points, rewards for vote points is coming soon! <a:lurk:425394751357845506>" + "\nYou now also have access to the `!volume` and `!default-volume` commands for the next 12 hours on servers you have permission to run them on, you can also save up your vote points to buy special rank backgrounds using the `!backgrounds` command.", points)) .build(); }
/** * Sends the "Must Vote" message to the given channel, letting the * user know that they must vote to use the given feature. * * @param channel The channel the message should be sent to. * @param feature The feature that the user has to vote for to use, or * <code>null</code> to specify the current command. */ public void sendMustVoteMessage(@Nonnull MessageChannel channel, @Nullable String feature) { channel.sendMessage(MessageFactory.createEmbeddedBuilder() .setColor(Color.decode("#E91E63")) .setTitle("Vote for AvaIre on DBL", "https://discordbots.org/bot/avaire") .setDescription(String.format( "You must vote to %s, voting is free and only takes a few seconds\nTo get started, head over to:\n\nhttps://discordbots.org/bot/avaire\n\nOnce you've voted you'll gain access to this, and other commands for the next 12 hours!", feature == null ? "use this command" : feature )) .build() ).queue(); } }
color = Color.decode('#' + hex); int unsignedInt = Integer.parseUnsignedInt(hex, 16); EmbedBuilder eb = MessageUtils.getEmbed().setColor(color).setTitle("#" + hex) .addField("RGB", color.getRed() + ", " + color.getGreen() + ", " + color.getBlue(), true) .addField("Numbers", String.format("Binary: %s\nDecimal: %d", Integer.toBinaryString(unsignedInt),
Comparator.comparingInt(entry -> entry.getValue().size())); User mostWarned = GuildUtils.getUser(highestEntry.getKey(), guild.getGuildId(), true); channel.sendMessage(new EmbedBuilder().setTitle("Warning stats", null) .addField("Total Warnings", String.valueOf( guild.getWarningsMap().values().stream().mapToLong(List::size).sum()), true) .setTitle("Warnings for " + user.getName()) .addField("Warning count", String.valueOf(tmp.size()), true) .addField("Last 5 warnings", "```md\n" + sb.toString().trim() + "\n```", false)
private static MessageEmbed makeEmbedConfig(Guild guild, int activePage) { EmbedBuilder b = new EmbedBuilder(); List<String> keys = DefaultGuildSettings.getWritableKeys(); Collections.sort(keys); int maxPage = (int) Math.ceil((double) keys.size() / (double) CFG_PER_PAGE); activePage = Math.max(0, Math.min(maxPage - 1, activePage - 1)); int endIndex = activePage * CFG_PER_PAGE + CFG_PER_PAGE; int elements = 0; for (int i = activePage * CFG_PER_PAGE; i < keys.size() && i < endIndex; i++) { String key = keys.get(i); b.addField(key.toLowerCase(), GuildSettings.get(guild.getIdLong()).getDisplayValue(guild, key), true); elements++; } if (elements % 3 == 2) { b.addBlankField(true); } String commandPrefix = DisUtil.getCommandPrefix(guild); b.setFooter("Page " + (activePage + 1) + " / " + maxPage + " | Press the buttons for other pages", null); b.setDescription(String.format("To see more details about a setting:\n" + "`%1$scfg settingname`\n\n", commandPrefix)); b.setTitle("Current Settings for " + guild.getName() + " [" + (1 + activePage) + " / " + maxPage + "]", null); return b.build(); }
private MessageEmbed printVersion(MessageChannel channel, ProgramVersion version, SimpleRank rank) { EmbedBuilder b = new EmbedBuilder(); OBotVersion dbVersion = CBotVersions.findBy(version); if (!rank.isAtLeast(SimpleRank.BOT_ADMIN) && dbVersion.published == 0) { return null; } List<OBotVersionChange> changes = CBotVersionChanges.getChangesFor(dbVersion.id); if (changes.isEmpty()) { return null; } StringBuilder desc = new StringBuilder(); OBotVersionChange.ChangeType lastType = null; for (OBotVersionChange change : changes) { if (!change.changeType.equals(lastType)) { lastType = change.changeType; desc.append(String.format("\n**%s %s**\n", lastType.getEmoji(), lastType.getTitle().toUpperCase())); } desc.append(String.format(" • %s\n", change.description)); } b.setTitle("[" + version.toString() + "] Changelog " + (dbVersion.published == 0 ? Emojibet.WARNING + " Still being worked on!" : ""), null); b.setDescription(desc.toString()); b.setFooter(String.format("I'd love to hear your feedback, feel free to join %sdiscord", DisUtil.getCommandPrefix(channel)), channel.getJDA().getSelfUser().getAvatarUrl()); return b.build(); } }
} catch (QueryExecutionException | QueryValidationException e) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle("Failed to execute query"); eb.addField("Error", "```\n" + e.getMessage() + "\n```", false); channel.sendMessage(eb.build()).queue();
public static MessageEmbed buildCase(Guild guild, OModerationCase modcase) { EmbedBuilder b = new EmbedBuilder(); b.setTitle(String.format("%s | case #%s", modcase.punishment.getKeyword(), modcase.id), null); b.setColor(modcase.punishment.getColor()); b.addField("User", modcase.userName + "\n" + CUser.getCachedDiscordId(modcase.userId) + "\n", true); b.addField("Moderator", modcase.moderatorName + "\n" + CUser.getCachedDiscordId(modcase.moderatorId), true); b.addField("Issued", banDateFormat.format(modcase.createdAt), true); if (modcase.expires != null) { b.addField("Expires", modcase.expires.toString(), true); } String reason = modcase.reason; if (reason == null || reason.isEmpty()) { reason = "Reason not set! use `" + DisUtil.getCommandPrefix(guild) + "case reason " + modcase.id + " <message>` to set the reason"; } b.addField("Reason", reason, false); return b.build(); } }
public static void logEG(String eg, Command command, Guild guild, User user) { EmbedBuilder builder = new EmbedBuilder().setTitle("Found `" + eg + "`") .addField("Guild", guild.getId() + " (`" + guild.getName() + "`) ", true) .addField("User", user.getAsMention() + " (`" + user.getName() + "#" + user.getDiscriminator() + "`)", true) .setTimestamp(LocalDateTime.now(Clock.systemUTC())); if (command != null) builder.addField("Command", command.getCommand(), true); Constants.getEGLogChannel().sendMessage(builder.build()).queue(); }
.setAuthor(lyrics.getAuthor()) .setColor(event.getSelfMember().getColor()) .setTitle(lyrics.getTitle(), lyrics.getURL()); if(lyrics.getContent().length()>15000) event.reply(eb.setDescription(content.substring(0, index).trim()).build()); content = content.substring(index).trim(); eb.setAuthor(null).setTitle(null, null);
public static void sendUsage(Command command, TextChannel channel, User user, String[] args) { String title = capitalize(command.getCommand()) + " Usage"; List<String> usages = UsageParser.matchUsage(command, args); String usage = FormatUtils.formatCommandPrefix(channel.getGuild(), usages.stream().collect(Collectors.joining("\n"))); EmbedBuilder b = getEmbed(user).setTitle(title, null).setDescription(usage).setColor(Color.pink); if (command.getExtraInfo() != null) { b.addField("Extra Info", command.getExtraInfo(), false); } if (command.getPermission() != null) { b.addField("Permission", "`" + command.getPermission() + "`\n\n" + "Default Permission: " + command.getPermission().isDefaultPerm() + "\n" + "Beta Command: " + command.isBetaTesterCommand(), false); } channel.sendMessage(b.build()).queue(); }
/** * Sends the blacklist message to the given channel to let * the user/guild know that they have been added to the * blacklist automatically. * * @param channel The channel that the message should be sent to. * @param expires The carbon time instance for when the blacklist expires. */ public void sendBlacklistMessage(MessageChannel channel, Carbon expires) { channel.sendMessage(MessageFactory.createEmbeddedBuilder() .setColor(Color.decode("#A5306B")) .setTitle("Whoa there!", "https://avairebot.com/") .setFooter("Expires", null) .setTimestamp(expires.getTime().toInstant()) .setDescription("Looks like people on the server are using commands a bit too fast, " + "I've banned the server from using any commands, or earning any XP until everyone " + "clams down a bit.\n" + "The ban expires in " + expires.addSecond().diffForHumans(true) + ", " + "keep in mind repeating the behavior will get the server banned for longer " + "periods of time, eventually if you keep it up the server will be banned " + "from using any of my commands permanently." ).build() ).queue(); }
/** * Sends the blacklist message to the given use in a direct * message to let the user know that they have been added * to the blacklist automatically. * * @param user The user that was blacklisted. * @param expires The carbon time instance for when the blacklist expires. */ public void sendBlacklistMessage(User user, Carbon expires) { user.openPrivateChannel().queue(channel -> { channel.sendMessage(MessageFactory.createEmbeddedBuilder() .setColor(Color.decode("#A5306B")) .setTitle("Whoa there!", "https://avairebot.com/") .setFooter("Expires", null) .setTimestamp(expires.getTime().toInstant()) .setDescription("Looks like you're using commands a bit too fast, I've banned you " + "from using any commands, or earning any XP until you cool down a bit.\n" + "Your ban expires in " + expires.addSecond().diffForHumans(true) + ", " + "keep in mind repeating the behavior will get you banned for longer " + "periods of time, eventually if you keep it up you will be banned " + "from using any of my commands permanently." ).build() ).queue(); }, RestActionUtil.ignore); }
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message msg, String[] args, Member member) { if (guild.getGuildId().equals("226785954537406464") && PerGuildPermissions.isAdmin(sender)) { if (args.length == 0) { channel.sendMessage("You kinda need like.... a message to announce... like yeah...").queue(); return; } Role r = guild.getGuild().getRoleById(320304080926801922L); r.getManager().setMentionable(true).queue(aVoid -> { if (args[0].startsWith("pr:")) { channel.sendMessage(new MessageBuilder().setEmbed(GitHubUtils.getEmbedForPR(args[0].substring(3)) .build()).append(r.getAsMention()).build()).queue(bVoid -> channel.sendMessage("make sure to report any bugs over to be <#242206261767176192> channel " + "and if you need any support we're happy to help over in the <#226786463440699392> " + "channel!").queue() ); } else { String message = msg.getContentRaw(); message = message.substring(message.indexOf(" ") + 1); channel.sendMessage(new MessageBuilder().setContent(r.getAsMention()) .setEmbed(new EmbedBuilder().setTitle("Some announcement thing!").setDescription(message) .setFooter("Announcement by " + member.getEffectiveName(), sender.getEffectiveAvatarUrl()).build()).build()) .complete(); } }); r.getManager().setMentionable(false).queue(); } }
if (channel.getGuild().getRegion() == Region.EU_WEST || channel.getGuild().getRegion() == Region.VIP_EU_WEST) { if (LocalDateTime.now().getHour() == 0 && LocalDateTime.now().getMinute() == 0 && LocalDateTime.now().getSecond() == 0) { channel.sendMessage(new EmbedBuilder().setTitle("Jesus Quist", null).setDescription("It's quite late to be listening to music! You should be asleep! " + ":zzz: :night_with_stars:").setColor(Color.blue).build()).queue(); Constants.logEG("Jesus Quist - Late night", this, guild.getGuild(), sender);
public Message getNoMusicPlaying(JDA jda) { Guild guild = guild(jda); return new MessageBuilder() .setContent(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing...**")) .setEmbed(new EmbedBuilder() .setTitle("No music playing") .setDescription(JMusicBot.STOP_EMOJI+" "+FormatUtil.progressBar(-1)+" "+FormatUtil.volumeIcon(audioPlayer.getVolume())) .setColor(guild.getSelfMember().getColor()) .build()).build(); }
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 1 && args[0].matches("[0-9]{18,22}")) { if (!guild.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_MANAGE)) { MessageUtils.sendErrorMessage("I need the `Manage Messages` permission in order to pin!", channel); return; } Message msg = channel.getMessageById(args[0].trim()).complete(); if (msg == null) { MessageUtils.sendErrorMessage("That message could not be found!", channel); return; } msg.pin().complete(); channel.getHistory().retrievePast(1).complete().get(0).delete().queue(); } else if (args.length != 0) { if (!guild.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_MANAGE)) { MessageUtils.sendErrorMessage("I need the `Manage Messages` permission in order to pin!", channel); return; } Message msg = channel.sendMessage(new EmbedBuilder().setTitle(sender.getName(), null) .setThumbnail(MessageUtils.getAvatar(sender)).setDescription(MessageUtils.getMessage(args, 0)) .build()).complete(); msg.pin().complete(); channel.getHistory().retrievePast(1).complete().get(0).delete().queue(); } else { MessageUtils.sendUsage(this, channel, sender, args); } }