Java Code Examples for net.dv8tion.jda.core.EmbedBuilder#setFooter()
The following examples show how to use
net.dv8tion.jda.core.EmbedBuilder#setFooter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickPollCommand.java From DiscordBlueBot with MIT License | 6 votes |
@Override public void action(String[] args, MessageReceivedEvent event) { String query = ""; for (String arg : args) { query += arg + " "; } EmbedBuilder builder = new EmbedBuilder(); builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor())); builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " created a poll", null, event.getAuthor().getAvatarUrl()); builder.addField("", ":grey_question: Question : " + "**" + query + "**", false); builder.setFooter("Vote by adding a reaction below !", null); event.getMessage().delete().queue(); event.getTextChannel().sendMessage(builder.build()).queue(); //Now retrieves the last message from BlueBot to add reactions List<Message> history = event.getTextChannel().getHistory().retrievePast(10).complete(); //arbitrary ammount for (Message msg : history) { if(msg.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) { msg.addReaction("\uD83D\uDC4D").queue(); msg.addReaction("\ud83d\udc4e").queue(); msg.addReaction("\uD83E\uDD37").queue(); break; } } }
Example 2
Source File: NowPlayingCommand.java From DiscordBot with Apache License 2.0 | 6 votes |
@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); AudioTrack audioTrack = DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack(); if (audioTrack == null) { embedBuilder.setTitle("Nothing is currently playing.", null); DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true); return; } embedBuilder.addField("Now playing", audioTrack.getInfo().title, false); embedBuilder.setFooter(DiscordUtil.getTimestamp(audioTrack.getPosition()) + " / " + DiscordUtil.getTimestamp(audioTrack.getDuration()), null); DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true); }
Example 3
Source File: HelpCommand.java From DiscordBot with Apache License 2.0 | 6 votes |
@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); embedBuilder.setTitle("Commands", null); for (Iterator<ICommand> iterator = DiscordBot.getInstance().getDiscord().getCommand().getRegisteredCommands().iterator(); iterator.hasNext();) { ICommand command = iterator.next(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Description - " + command.getDescription() + "\n"); stringBuilder.append("Usage - " + command.getUsage() + "\n"); if (command.getAliases() != null && !command.getAliases().isEmpty()) { stringBuilder.append("Aliases - " + String.join(", ", command.getAliases())); } embedBuilder.addField(command.getName(), stringBuilder.toString(), false); } embedBuilder.setFooter("<> = Required Argument, [] = Optional Argument", null); DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true); }
Example 4
Source File: ServerInfoCommand.java From FlareBot with MIT License | 4 votes |
private void sendGuildInfo(Guild guild, TextChannel channel) { EmbedBuilder eb = new EmbedBuilder(); eb.setTitle(guild.getName()); eb.setThumbnail(guild.getIconUrl()); eb.addField("Users", "**Total:** " + guild.getMembers().size() + "\n" + "\n" + "**Online:** " + guild.getMembers().stream().filter(member -> !member.getOnlineStatus().equals(OnlineStatus.OFFLINE)).count() + "\n" + "\n" + "**Owner:** " + MessageUtils.getTag(guild.getOwner().getUser()), true); String afk = guild.getAfkChannel() == null ? "" : "**AFK:**\n" + "Channel: " + guild.getAfkChannel().getName() + "\n" + "\n" + "Timeout: " + FormatUtils.formatTime(guild.getAfkTimeout().getSeconds(), TimeUnit.SECONDS, true, false); eb.addField("Channels", "**Text**\n" + "Total: " + guild.getTextChannels().size() + "\n" + "\n" + "**Voice**\n" + "Total: " + guild.getVoiceChannels().size() + "\n" + "\n" + "Active: " + guild.getVoiceChannels().stream().filter(voiceChannel -> voiceChannel.getMembers().size() > 0).count() + "\n" + "\n" + afk, true); eb.addField("Misc info", "**Creation time:** " + guild.getCreationTime().toLocalDateTime().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + " UTC\n" + "\n" + "**Roles:** " + guild.getRoles().size() + "\n" + "\n" + "**Server region:** " + guild.getRegion().getName() + "\n" + "\n" + "**Verification Level:** " + GeneralUtils.getVerificationString(guild.getVerificationLevel()), true); eb.setFooter("ID: " + guild.getId(), null); eb.setColor(Color.CYAN); channel.sendMessage(eb.build()).queue(); }
Example 5
Source File: SettingsCommand.java From DiscordBlueBot with MIT License | 4 votes |
@Override public void action(String[] args, MessageReceivedEvent event) { EmbedBuilder builder = new EmbedBuilder(); builder.setAuthor("Settings for " + event.getGuild().getName(), "https://bluebot.pw", event.getJDA().getSelfUser().getAvatarUrl()); builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor())); builder.setThumbnail(event.getGuild().getIconUrl()); //Channels String defaultChannel = "`No channel specified`"; String twitchChannel = MainBot.getTwitchChannel().get(event.getGuild().getId()); if(twitchChannel == null) { twitchChannel = defaultChannel; } else { twitchChannel = event.getJDA().getTextChannelById(twitchChannel).getAsMention(); } String userEventChannel = MainBot.getUserEventChannel().get(event.getGuild().getId()); if(userEventChannel == null) { userEventChannel = defaultChannel; } else { userEventChannel = event.getJDA().getTextChannelById(userEventChannel).getAsMention(); } String soundChannel = MainBot.getMusicChannel().get(event.getGuild().getId()); if(soundChannel == null) { soundChannel = defaultChannel; } else { soundChannel = event.getJDA().getTextChannelById(soundChannel).getAsMention(); } builder.addField("Channels", "Twitch channel : " + twitchChannel + "\nUser events channel : " + userEventChannel + "\nSound channel : " + soundChannel, false); //Functionalities String twitchNotif = "`enabled`"; if(MainBot.getTwitchDisabled().contains(event.getGuild().getId())) { twitchNotif = "`disabled`"; } String badWords = "`enabled`"; if(MainBot.getBwDisabled().contains(event.getGuild().getId())) { badWords = "`disabled`"; } String userEvents = "`enabled`"; if(MainBot.getUserEventDisabled().contains(event.getGuild().getId())) { userEvents = "`disabled`"; } String serverSb = "`dedicated`"; if(MainBot.getServerSBDisabled().contains(event.getGuild().getId())) { serverSb = "`general`"; } builder.addField("Functionalities : ", "Twitch notifications : " + twitchNotif + "\nBad words filter : " + badWords + "\nUser events : " + userEvents + "\nSoundboard : " + serverSb, false); //Autorole String autorole = MainBot.getAutoRoleList().get(event.getGuild().getId()); if(autorole == null) { autorole = "`No role specified`"; } else { autorole = event.getJDA().getRolesByName(autorole, true).get(0).getAsMention(); } builder.addField("Autorole : ", autorole, false); //Prefix String prefix = MainBot.getPrefixes().get(event.getGuild().getId()); if(prefix == null) { prefix = "!"; } builder.addField("Current prefix : ", "Prefix is `" + prefix + "`", false); builder.setFooter("To edit these settings, use the channel, enable/disable, setautorole & setprefix commands", "https://i.imgur.com/VHtAEeP.png"); event.getTextChannel().sendMessage(builder.build()).queue(); }
Example 6
Source File: MultiPollCommand.java From DiscordBlueBot with MIT License | 4 votes |
@Override public void action(String[] args, MessageReceivedEvent event) { String query = ""; String subject; String choicesList = ""; ArrayList<String> choices = new ArrayList<>(); Pattern subjectRegex = Pattern.compile("\\((.*?)\\)"); Pattern choiceRegex = Pattern.compile("\\[(.*?)]"); for (String arg : args) { query += arg + " "; } Matcher subjectMatcher = subjectRegex.matcher(query); Matcher choiceMatcher = choiceRegex.matcher(query); while (choiceMatcher.find()) { choices.add(choiceMatcher.group(1)); } if (subjectMatcher.find()) { subject = subjectMatcher.group(1); } else { event.getTextChannel().sendMessage("Please provide a poll question/subject.").queue(); return; } if(choices.size() < 2 || choices.size() > 10) { //At least 2 options and max 10 event.getTextChannel().sendMessage("You can only propose from 2 to 10 options.").queue(); return; } EmbedBuilder builder = new EmbedBuilder(); builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor())); builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " created a poll", null, event.getAuthor().getAvatarUrl()); builder.addField("", "Question : " + "**" + subject + "**", true); for(int i = 0; i < choices.size(); ++i) { if(i == 9) { choicesList = choicesList + "\uD83D\uDD1F " + choices.get(i); //Keycap 10 case break; } choicesList = choicesList + (i+1) + "⃣ " + choices.get(i) + "\n"; //damn these emojis made me mad } builder.addField("", choicesList, false); builder.setFooter("Vote by adding a reaction below !", null); event.getMessage().delete().queue(); event.getTextChannel().sendMessage(builder.build()).queue(); //Now retrieves the last message from BlueBot to add reactions List<Message> history = event.getTextChannel().getHistory().retrievePast(10).complete(); //arbitrary ammount for (Message msg : history) { if(msg.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())) { for(int i = 0; i < choices.size(); ++i) { if(i == 9) { msg.addReaction("\uD83D\uDD1F").queue(); //Keycap 10 case break; } msg.addReaction(i+1 + "⃣").queue(); //damn these emojis made me mad } break; } } }