net.dv8tion.jda.core.EmbedBuilder Java Examples

The following examples show how to use net.dv8tion.jda.core.EmbedBuilder. 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: Counter.java    From DiscordBot with Apache License 2.0 8 votes vote down vote up
private void create(String[] args, MessageReceivedEvent event) {
    Guild g = event.getGuild();

    String name = String.join(" ", Arrays.asList(args).subList(1, args.length));
    CCounter count = new CCounter(name, event.getMember());

    if (args.length < 2) {
        Messages.message(event.getTextChannel(), help(), Color.red);
        return;
    }

    if (counters.containsKey(g))
        counters.get(g).add(count);
    else {
        List<CCounter> l = new ArrayList<>();
        l.add(count);
        counters.put(event.getGuild(), l);
    }

    event.getTextChannel().sendMessage(new EmbedBuilder().setColor(Color.green).setDescription(
            String.format("Successfully created counter `%s`. *(ID: %d)*", name, counters.get(g).size() - 1)
    ).build()).queue();
}
 
Example #2
Source File: BotStats.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException {

    int commandsSize = Main.commands.size();
    int serversRunning = event.getJDA().getGuilds().size();

    event.getJDA().getGuilds().forEach(g -> g.getMembers().forEach(m -> countUpMembers()));

    event.getTextChannel().sendMessage(
            new EmbedBuilder()
            .setColor(Color.cyan)
            .setDescription(
                    "**zekroBot STATS**\n\n" +
                    "```\n" +
                    "Registered commands:  " + commandsSize + "\n" +
                    "Running on servers:   " + serversRunning + " / " + STATICS.SERVER_LIMIT + "\n" +
                    "Deserving members:    " + membersDeserving + "\n" +
                    "Messages processed:   " + messagesProcessed + "\n" +
                    "Commands executed:    " + commandsExecuted + "\n" +
                    "```"
            ).build()
    ).queue();

    membersDeserving = 0;

}
 
Example #3
Source File: QuickPollCommand.java    From DiscordBlueBot with MIT License 6 votes vote down vote up
@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 #4
Source File: PagedEmbedBuilder.java    From FlareBot with MIT License 6 votes vote down vote up
/**
 * Gets the {@link MessageEmbed} for a specified page.
 *
 * @param page The page to get an embed.
 * @return the {@link MessageEmbed} page.
 */
public MessageEmbed getEmbed(int page) {
    EmbedBuilder pageEmbed = new EmbedBuilder().setColor(ColorUtils.FLAREBOT_BLUE);
    if (title != null)
        pageEmbed.setTitle(title);
    if(useGroups) {
        int start = groupsPerPage * (page);
        int end = Math.min(start + groupsPerPage, groupTotal);
        int num = start;
        List<PaginationList<T>.PageGroup> groups = list.getGroups().subList(start, end);
        for (PaginationList.PageGroup group : groups) {
            pageEmbed.addField(groupPrefix + num, group.getGroupAsString(), false);
            num++;
        }
    } else {
        pageEmbed.setDescription((hasCodeBlock ? "```" + codeBlock + "\n" : "") + list.getPage(page) + (hasCodeBlock ? "\n```" : ""));
    }
    if (pageCounts) {
        pageEmbed.addField("Page", String.valueOf(page + 1), true);
        pageEmbed.addField("Total Pages", String.valueOf(pageTotal), true);
    }
    pageEmbed.setColor(color);
    return pageEmbed.build();
}
 
Example #5
Source File: VolumeCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
	
	if (arguments != null && !arguments.isEmpty()) {
		try {
			int volume = Integer.parseInt(arguments.get(0));
			if (volume > 100 || volume < 0) {
				volume = DiscordBot.getInstance().getDiscord().getAudioPlayer().getVolume();
			}
			
			DiscordBot.getInstance().getDiscord().getAudioPlayer().setVolume(volume);
			embedBuilder.setColor(DiscordUtil.SUCCESS);
		} catch (NumberFormatException ex) {
			embedBuilder.setColor(DiscordUtil.ERROR);
			embedBuilder.setTitle("Invalid volume!", null);
			DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
			return;
		}
	}
	
	embedBuilder.setTitle("Volume - " + DiscordBot.getInstance().getDiscord().getAudioPlayer().getVolume(), null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example #6
Source File: ServerLimitListener.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@Override
public void onGuildJoin(GuildJoinEvent event) {

    Guild guild = event.getGuild();
    wildcards = getWilrdcards();

    if (guild.getJDA().getGuilds().size() > STATICS.SERVER_LIMIT) {
        guild.getOwner().getUser().openPrivateChannel().queue(pc -> pc.sendMessage(
                new EmbedBuilder().setColor(Color.ORANGE).setTitle("Server Limit Reached", null).setDescription(
                        "Sorry, but because of currently limited resources the bot is limited to run on maximum " + STATICS.SERVER_LIMIT + " Servers.\n\n" +
                        "If you have a wildcard, you can send the token via PM to zekroBot.\n" +
                        "Otherwise, the bot will leave the server automatically after 2 minutes."
                ).build()
        ).queue());
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                guild.leave().queue();
            }
        }, 120000);
    }

}
 
Example #7
Source File: Counter.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private void list(MessageReceivedEvent event) {
    Guild g = event.getGuild();

    if (!counters.containsKey(event.getGuild())) {
        Messages.message(event.getTextChannel(), "This guild has no counters!", Color.red);
        return;
    }

    StringBuilder sb = new StringBuilder();
    AtomicInteger count = new AtomicInteger();
    counters.get(g).forEach(c ->
        sb.append(String.format(":white_small_square:   `[%d]`  -  %s  -  **%d**\n", count.getAndAdd(1), c.name, c.count))
    );
    event.getTextChannel().sendMessage(new EmbedBuilder()
            .setColor(Color.cyan)
            .setTitle("Current counters")
            .setDescription(sb.toString())
            .build()).queue();
}
 
Example #8
Source File: UpdateClient.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private static void sendUpdateMsg(Object channel) {
    EmbedBuilder eb = new EmbedBuilder()
            .setColor(Color.cyan)
            .setTitle("New bot update is available!")
            .setDescription("Download the latest version and install it manually on your vServer.\n\n**Current version:  ** `" + STATICS.VERSION + "`")
            .addField("Latest Pre Release Build", String.format(
                    "Version:  `%s`\n" +
                            "Download & Changelogs:  [GitHub Release](%s)\n", PRE.tag, PRE.url
            ), false)
            .addField("Latest Stable Release Build", String.format(
                    "Version:  `%s`\n" +
                            "Download & Changelogs:  [GitHub Release](%s)\n", STABLE.tag, STABLE.url
            ), false)
            .setFooter("Enter '-disable' to disable this message on new updates.", null);

    try {
        TextChannel tc = (TextChannel) channel;
        tc.sendMessage(eb.build()).queue();
    } catch (Exception e) {
        PrivateChannel pc = (PrivateChannel) channel;
        pc.sendMessage(eb.build()).queue();
    }


}
 
Example #9
Source File: GeneralUtils.java    From FlareBot with MIT License 6 votes vote down vote up
/**
 * This is to handle "multi-selection commands" for example the info and stats commands which take one or more
 * arguments and get select data from an enum
 */
public static void handleMultiSelectionCommand(User sender, TextChannel channel, String[] args,
                                               MultiSelectionContent<String, String, Boolean>[] providedContent) {
    String search = MessageUtils.getMessage(args);
    String[] fields = search.split(",");
    EmbedBuilder builder = MessageUtils.getEmbed(sender).setColor(Color.CYAN);
    boolean valid = false;
    for (String string : fields) {
        String s = string.trim();
        for (MultiSelectionContent<String, String, Boolean> content : providedContent) {
            if (s.equalsIgnoreCase(content.getName()) || s.replaceAll("_", " ")
                    .equalsIgnoreCase(content.getName())) {
                builder.addField(content.getName(), content.getReturn(), content.isAlign());
                valid = true;
            }
        }
    }
    if (valid) channel.sendMessage(builder.build()).queue();

    else MessageUtils.sendErrorMessage("That piece of information could not be found!", channel);
}
 
Example #10
Source File: GeneralUtils.java    From FlareBot with MIT License 6 votes vote down vote up
/**
 * Gets the {@link Report} embed with all of the info on the report.
 *
 * @param sender The {@link User} who requested the embed
 * @param report The {@link Report} to get the embed of.
 * @return an {@link EmbedBuilder} that contains all the report data
 */
public static EmbedBuilder getReportEmbed(User sender, Report report) {
    EmbedBuilder eb = MessageUtils.getEmbed(sender);
    User reporter = Getters.getUserById(report.getReporterId());
    User reported = Getters.getUserById(report.getReportedId());

    eb.addField("Report ID", String.valueOf(report.getId()), true);
    eb.addField("Reporter", reporter != null ? MessageUtils.getTag(reporter) : "Unknown", true);
    eb.addField("Reported", reported != null ? MessageUtils.getTag(reported) : "Unknown", true);

    //eb.addField("Time", report.getTime().toLocalDateTime().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) + " GMT/BST", true);
    eb.setTimestamp(report.getTime().toLocalDateTime());
    eb.addField("Status", report.getStatus().getMessage(), true);

    eb.addField("Message", "```" + report.getMessage() + "```", false);
    StringBuilder builder = new StringBuilder("The last 5 messages by the reported user: ```\n");
    for (ReportMessage m : report.getMessages()) {
        builder.append("[").append(m.getTime().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm:ss"))).append(" GMT/BST] ")
                .append(FormatUtils.truncate(100, m.getMessage()))
                .append("\n");
    }
    builder.append("```");
    eb.addField("Messages from reported user", builder.toString(), false);
    return eb;
}
 
Example #11
Source File: StopCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
	
	if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.setTitle("Player is not playing anything!", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	DiscordBot.getInstance().getDiscord().getAudioPlayer().stopTrack();
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle("Track stopped.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example #12
Source File: EmoteCmd.java    From Selfbot with Apache License 2.0 6 votes vote down vote up
@Override
protected void execute(String args, MessageReceivedEvent event) {
    String id = args.replaceAll("<:.+:(\\d+)>", "$1");
    Emote emote = event.getJDA().getEmoteById(id);
    if(emote==null)
        tempReply("Invalid emote or emote ID", event);
    else
    {
        EmbedBuilder builder = new EmbedBuilder();
        if(event.getGuild()!=null)
            builder.setColor(event.getGuild().getSelfMember().getColor());
        builder.setImage(emote.getImageUrl());
        builder.setDescription(emote.getAsMention()+" **:"+emote.getName()+":**\nID: **"+emote.getId()+"**\nGuild: **"+emote.getGuild().getName()+"**");
        reply(builder.build(), event);
    }
}
 
Example #13
Source File: WarframeAlerts.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private static EmbedBuilder createMessage(ArrayList<AlertsParser> inputList) {

        EmbedBuilder eb = new EmbedBuilder()
                .setColor(new Color(0x0088FF))
                .setTitle("WARFRAME ALERTS", null)
                .setDescription("*[ " + getCurrentTime() + " ]*\n\n_____");

        inputList.forEach(alert -> eb.addField(
                alert.location,
                "**TYPE:**   " + alert.type + "\n" +
                       "**ENEMIES:**   " + alert.enemies + "\n" +
                       "**LEVEL:**   " + alert.minLVL + " - " + alert.maxLVL + "\n" +
                       "**LOOT:**   " + Arrays.stream(alert.loot).collect(Collectors.joining(" - ")).replace(",", ".") + "\n" +
                       "**STATUS:**   " + getStartEndTime(alert.start, alert.end) + "\n" +
                       "___________",
                false
        ));

        return eb;

    }
 
Example #14
Source File: Vote3.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private static EmbedBuilder getParsedPoll(Poll poll, Guild guild) {

        StringBuilder ansSTR = new StringBuilder();
        final AtomicInteger count = new AtomicInteger();

        poll.answers.forEach(s -> {
            long votescount = poll.votes.keySet().stream().filter(k -> poll.votes.get(k).equals(count.get() + 1)).count();
            ansSTR.append(poll.emotis.get(count.get()) + "  -  " + s + "  -  Votes: `" + votescount + "` \n");
            count.addAndGet(1);
        });

        return new EmbedBuilder()
                .setAuthor(poll.getCreator(guild).getEffectiveName() + "'s poll.", null, poll.getCreator(guild).getUser().getAvatarUrl())
                .setDescription(":pencil:   " + poll.heading + "\n\n" + ansSTR.toString())
                .setColor(Color.cyan);

    }
 
Example #15
Source File: ShuffleCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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);
	
	if (DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue() == null || DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().size() < 2) {
		embedBuilder.setColor(DiscordUtil.ERROR);
		embedBuilder.setTitle("The current queue is not big enough to shuffle!", null);
		DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
		return;
	}
	
	Collections.shuffle(DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue(), new Random(System.nanoTime()));
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle("Current queue shuffled.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example #16
Source File: NowPlayingCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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 #17
Source File: BetaCommand.java    From FlareBot with MIT License 6 votes vote down vote up
@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
    String betaInfo =
            FormatUtils.formatCommandPrefix(guild, FlareBot.getCommandManager().getCommands()
                    .stream()
                    .filter(Command::isBetaTesterCommand)
                    .map(c -> "`{%}" + c.getCommand() + "` - " + c.getDescription())
                    .collect(Collectors.joining("\n")));
    String betaMessage = guild.hasBetaAccess() ?
            "Thank you for being apart of our beta program! Please report any bugs or give us suggestions over at the [support discord](" + Constants.INVITE_URL + ")!"
            : "Listed below are the commands you can gain access to by being a part of our beta program! To join the beta program, you will either need to win " +
            "beta access through a giveaway (Make sure you are in the [support server](" + Constants.INVITE_URL + ") to hear of these!) or you can become apart of the " +
            "Donator tier or higher on our [patreon page](https://www.patreon.com/flarebot)!";
    EmbedBuilder builder = MessageUtils.getEmbed(sender);
    builder.setColor(Color.CYAN);
    builder.setDescription(betaMessage);
    builder.addField("Beta Commands", betaInfo, false);
    channel.sendMessage(builder.build()).queue();
}
 
Example #18
Source File: Mute.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private void toggle(String[] args, Message msg, TextChannel tc) {

	    User victim = msg.getMentionedUsers().size() > 0 ? msg.getMentionedUsers().get(0) : msg.getJDA().getUserById(args[0]);

	    if (victim == null) {
	        tc.sendMessage(MSGS.error().setDescription("Please enter a valid mention or user ID!").build()).queue();
	        return;
        }

        String vicid = victim.getId();
        if (mutes.containsKey(vicid)) {
	        mutes.remove(vicid);
	        save();
	        tc.sendMessage(MSGS.success().setDescription(String.format("%s unmuted %s.", msg.getAuthor().getAsMention(), victim.getAsMention())).build()).queue();
        } else {
            String reason = "No reason.";
            if (args.length > 1)
                reason = String.join(" ", Arrays.asList(args).subList(1, args.length));
            mutes.put(vicid, reason);
            save();
            tc.sendMessage(new EmbedBuilder().setColor(Color.orange).setDescription(String.format("%s muted %s.\n\nReason: `%s`", msg.getAuthor().getAsMention(), victim.getAsMention(), reason)).build()).queue();
        }

    }
 
Example #19
Source File: AudioPlayerLoadResultHandler.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
	for (Iterator<AudioTrack> iterator = audioPlaylist.getTracks().iterator(); iterator.hasNext();) {
		AudioTrack audioTrack = iterator.next();
		if (audioTrack == null) {
			continue;
		}
		
		Audio audio = new Audio(getTextChannel(), getMember(), audioTrack);
		DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().add(audio);
		if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
			DiscordBot.getInstance().getDiscord().getAudioQueue().playNext();
		} else {
			LogHelper.debug("'" + audio.getAudioTrack().getInfo().title + "' Has been added to the queue.");
		}
		audio = null;
	}
	LogHelper.debug(audioPlaylist.getTracks().size() + " Songs have been added to the queue.");
	EmbedBuilder embedBuilder = new EmbedBuilder();
	embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
	embedBuilder.setColor(DiscordUtil.SUCCESS);
	embedBuilder.setTitle(audioPlaylist.getTracks().size() + " Songs have been added to the queue.", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example #20
Source File: HelpCommand.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
@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 #21
Source File: Autochannel.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private void unsetChan(String id, Guild g, TextChannel tc) {
    VoiceChannel vc = getVchan(id, g);

    if (vc == null) {
        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                String.format("Voice channel with the ID `%s` does not exist.", id)
        ).build()).queue();
    } else if (!autochans.containsKey(vc)) {
        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                String.format("Voice channel `%s` is not set as auto channel.", vc.getName())
        ).build()).queue();
    } else {
        autochans.remove(vc);
        unsetChan(vc);

        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                String.format("Successfully unset auto channel state of `%s`.", vc.getName())
        ).build()).queue();
    }
}
 
Example #22
Source File: Autochannel.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private void setChan(String id, Guild g, TextChannel tc) {
    VoiceChannel vc = getVchan(id, g);

    if (vc == null) {
        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                String.format("Voice channel with the ID `%s` does not exist.", id)
        ).build()).queue();
    } else if (autochans.containsKey(vc)) {
        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                "This channel is just set as auto channel."
        ).build()).queue();
    } else {
        autochans.put(vc, g);
        saveVchan(vc, g);
        tc.sendMessage(new EmbedBuilder().setColor(Color.green).setDescription(
                String.format("Successfully set voice channel `%s` as auto channel.", vc.getName())
        ).build()).queue();
    }
}
 
Example #23
Source File: Vote2.java    From DiscordBot with Apache License 2.0 6 votes vote down vote up
private EmbedBuilder getParsedPoll(Poll poll, Guild guild) {

        StringBuilder ansSTR = new StringBuilder();
        final AtomicInteger count = new AtomicInteger();

        poll.answers.forEach(s -> {
            long votescount = poll.votes.keySet().stream().filter(k -> poll.votes.get(k).equals(count.get() + 1)).count();
            ansSTR.append(EMOTI[count.get()] + "  -  " + s + "  -  Votes: `" + votescount + "` \n");
            count.addAndGet(1);
        });

        return new EmbedBuilder()
                .setAuthor(poll.getCreator(guild).getEffectiveName() + "'s poll.", null, poll.getCreator(guild).getUser().getAvatarUrl())
                .setDescription(":pencil:   " + poll.heading + "\n\n" + ansSTR.toString())
                .setFooter("Enter '" + SSSS.getPREFIX(guild) + "vote v <number>' to vote!", null)
                .setColor(Color.cyan);

    }
 
Example #24
Source File: Perms.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
public static boolean check(int required, MessageReceivedEvent event) {
    if (required > getLvl(event.getMember())) {
        event.getTextChannel().sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(
                "Sorry but you need permission level `" + required + "` or above!\n(Your current permission level is `" + getLvl(event.getMember()) + "`)."
        ).build()).queue();
        return true;
    }
    return false;
}
 
Example #25
Source File: CurrencyCommand.java    From FlareBot with MIT License 5 votes vote down vote up
private MessageEmbed getCurrencyRatesEmbed(User sender, CurrencyComparison c) {
    EmbedBuilder builder = MessageUtils.getEmbed(sender);
    builder.setColor(Color.CYAN)
            .setDescription("Currency Conversion Rates")
            .addField("From", c.getBase(), true)
            .addField("To", c.getTo(), true)
            .addField("Rate", ConvertCommand.DECIMAL_FORMAT.format(c.getRate()), false);
    return builder.build();
}
 
Example #26
Source File: AudioPlayerLoadResultHandler.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
@Override
public void noMatches() {
	EmbedBuilder embedBuilder = new EmbedBuilder();
	embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
	embedBuilder.setColor(DiscordUtil.ERROR);
	embedBuilder.setTitle("No matches found!", null);
	DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
 
Example #27
Source File: SongCommand.java    From FlareBot with MIT License 5 votes vote down vote up
public static void updateSongMessage(User sender, Message message, TextChannel channel) {
    Track track = FlareBot.instance().getMusicManager().getPlayer(channel.getGuild().getId()).getPlayingTrack();
    if (track == null)
        return;
    EmbedBuilder eb = MessageUtils.getEmbed(sender)
            .addField("Current Song", getLink(track), false)
            .setThumbnail("https://img.youtube.com/vi/" + track.getTrack().getIdentifier() + "/hqdefault.jpg");
    if (track.getTrack().getInfo().isStream)
        eb.addField("Amount Played", "Issa livestream ;)", false);
    else
        eb.addField("Amount Played", GeneralUtils.getProgressBar(track), true)
                .addField("Time", String.format("%s / %s", FormatUtils.formatDuration(track.getTrack().getPosition()),
                        FormatUtils.formatDuration(track.getTrack().getDuration())), false);
    message.editMessage(eb.build()).queue();
}
 
Example #28
Source File: Constants.java    From FlareBot with MIT License 5 votes vote down vote up
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();
}
 
Example #29
Source File: CustomEmbedCommand.java    From DiscordBlueBot with MIT License 5 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) {
    String query = "";
    Pattern subjectRegex = Pattern.compile("\\((.*?)\\)");
    String subject;

    for (String arg : args) {
        query += arg + " ";
    }

    Matcher subjectMatcher = subjectRegex.matcher(query);

    if (subjectMatcher.find()) {
        subject = subjectMatcher.group(1);
    } else {
        event.getTextChannel().sendMessage("Please provide a message").queue();
        return;
    }

    EmbedBuilder builder = new EmbedBuilder();
    builder.setColor(Color.decode(MainBot.getConfig().getEmbedColor()));
    builder.setAuthor(event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + " : " + subject, null, event.getAuthor().getAvatarUrl());
    builder.addField("","**" + subject + "**", false);

    event.getMessage().delete().queue();
    event.getTextChannel().sendMessage(builder.build()).queue();
}
 
Example #30
Source File: Autochannel.java    From DiscordBot with Apache License 2.0 5 votes vote down vote up
@Override
public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException {

    Guild g = event.getGuild();
    TextChannel tc = event.getTextChannel();

    if (args.length < 1) {
        tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
        return;
    }

    switch (args[0]) {

        case "list":
        case "show":
            listChans(g, tc);
            break;

        case "add":
        case "set":
            if (args.length < 2)
                tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
            else
                setChan(args[1], g, tc);
            break;

        case "remove":
        case "delete":
        case "unset":
            if (args.length < 2)
                tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
            else
                unsetChan(args[1], g, tc);
            break;

        default:
            tc.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
    }

}