Search in sources :

Example 11 with User

use of de.c0debase.bot.database.model.User 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)

Aggregations

User (de.c0debase.bot.database.model.User)11 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 ArrayList (java.util.ArrayList)2 Member (net.dv8tion.jda.api.entities.Member)2 Test (org.junit.Test)2 Codebase (de.c0debase.bot.Codebase)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Executors (java.util.concurrent.Executors)1 TimeUnit (java.util.concurrent.TimeUnit)1 Invite (net.dv8tion.jda.api.entities.Invite)1 Role (net.dv8tion.jda.api.entities.Role)1 Document (org.bson.Document)1