Search in sources :

Example 46 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.

the class RankCommand method execute.

@Override
public void execute(final String[] args, final Message message) {
    final Member member = DiscordUtils.getAddressedMember(message);
    final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), member.getUser());
    final User user = bot.getDatabase().getUserDao().getOrCreateUser(member.getGuild().getId(), member.getUser().getId());
    embedBuilder.addField("Level", String.valueOf(user.getLevel()), false);
    embedBuilder.addField("Exp", user.getXp() + "/" + (user.getLevel() == 0 ? "1000" : (1000 * user.getLevel() * 1.2)), false);
    if (user.getLevel() == 0 || user.getLevel() == 1) {
        embedBuilder.addField("Total Exp", String.valueOf(user.getLevel() == 0 ? user.getXp() : user.getXp() + 1000), false);
    } else {
        embedBuilder.addField("Total Exp", String.valueOf(Double.valueOf(((1000 * (user.getLevel() - 1) * 1.2) * user.getLevel()) / 2 + 1000 + user.getXp())), false);
    }
    message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) User(de.c0debase.bot.database.model.User) Member(net.dv8tion.jda.api.entities.Member)

Example 47 with EmbedBuilder

use of net.dv8tion.jda.api.EmbedBuilder in project Saber-Bot by notem.

the class SchedulesCommand method action.

@Override
public void action(String prefix, String[] args, MessageReceivedEvent event) {
    Guild guild = event.getGuild();
    List<String> scheduleIds = Main.getScheduleManager().getSchedulesForGuild(guild.getId());
    // build output main body
    StringBuilder content = new StringBuilder();
    for (String sId : scheduleIds) {
        content.append("<#").append(sId).append("> - has ").append(Main.getEntryManager().getEntriesFromChannel(sId).size()).append(" events\n");
    }
    // title for embed
    String title = "Schedules on " + guild.getName();
    // footer for embed
    String footer = scheduleIds.size() + " schedule(s)";
    // build embed
    MessageEmbed embed = new EmbedBuilder().setDescription(content.toString()).setTitle(title).setFooter(footer, null).build();
    // build message
    Message message = new MessageBuilder().setEmbed(embed).build();
    // send message
    MessageUtilities.sendMsg(message, event.getTextChannel(), null);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageEmbed(net.dv8tion.jda.api.entities.MessageEmbed) Message(net.dv8tion.jda.api.entities.Message) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Guild(net.dv8tion.jda.api.entities.Guild)

Aggregations

EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)47 Member (net.dv8tion.jda.api.entities.Member)8 TimeUnit (java.util.concurrent.TimeUnit)7 Collectors (java.util.stream.Collectors)7 Message (net.dv8tion.jda.api.entities.Message)7 Context (net.kodehawa.mantarobot.core.modules.commands.base.Context)7 MantaroData (net.kodehawa.mantarobot.data.MantaroData)7 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)7 Color (java.awt.Color)6 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)6 MessageEmbed (net.dv8tion.jda.api.entities.MessageEmbed)6 Utils (net.kodehawa.mantarobot.utils.Utils)6 Subscribe (com.google.common.eventbus.Subscribe)5 List (java.util.List)5 Role (net.dv8tion.jda.api.entities.Role)5 CommandCategory (net.kodehawa.mantarobot.core.modules.commands.base.CommandCategory)5 HelpContent (net.kodehawa.mantarobot.core.modules.commands.help.HelpContent)5 I18nContext (net.kodehawa.mantarobot.core.modules.commands.i18n.I18nContext)5 LinkedList (java.util.LinkedList)4 Permission (net.dv8tion.jda.api.Permission)4