Search in sources :

Example 6 with Axe

use of com.sx4.bot.entities.economy.item.Axe in project Sx4 by sx4-discord-bot.

the class AxeCommand method info.

@Command(value = "info", aliases = { "information" }, description = "View information on a users axe")
@CommandId(391)
@Examples({ "axe info", "axe info @Shea#6653", "axe info Shea" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void info(Sx4CommandEvent event, @Argument(value = "user", endless = true, nullDefault = true) Member member) {
    Member effectiveMember = member == null ? event.getMember() : member;
    User user = member == null ? event.getAuthor() : effectiveMember.getUser();
    Bson filter = Filters.and(Filters.eq("userId", effectiveMember.getIdLong()), Filters.eq("item.type", ItemType.AXE.getId()));
    Document data = event.getMongo().getItem(filter, Projections.include("item"));
    if (data == null) {
        event.replyFailure("That user does not have an axe").queue();
        return;
    }
    Axe axe = Axe.fromData(event.getBot().getEconomyManager(), data.get("item", Document.class));
    EmbedBuilder embed = new EmbedBuilder().setAuthor(user.getName() + "'s " + axe.getName(), null, user.getEffectiveAvatarUrl()).setColor(effectiveMember.getColorRaw()).setThumbnail("https://www.shareicon.net/data/2016/09/02/823994_ax_512x512.png").addField("Durability", axe.getDurability() + "/" + axe.getMaxDurability(), false).addField("Current Price", String.format("$%,d", axe.getCurrentPrice()), false).addField("Price", String.format("$%,d", axe.getPrice()), false).addField("Max Materials", String.valueOf(axe.getMaxMaterials()), false).addField("Multiplier", NumberUtility.DEFAULT_DECIMAL_FORMAT.format(axe.getMultiplier()), false);
    event.reply(embed.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) User(net.dv8tion.jda.api.entities.User) Document(org.bson.Document) Member(net.dv8tion.jda.api.entities.Member) Bson(org.bson.conversions.Bson) Axe(com.sx4.bot.entities.economy.item.Axe) BotPermissions(com.sx4.bot.annotations.command.BotPermissions) Command(com.jockie.bot.core.command.Command) Sx4Command(com.sx4.bot.core.Sx4Command) CommandId(com.sx4.bot.annotations.command.CommandId) Examples(com.sx4.bot.annotations.command.Examples)

Aggregations

Sx4Command (com.sx4.bot.core.Sx4Command)6 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)6 Command (com.jockie.bot.core.command.Command)5 CommandId (com.sx4.bot.annotations.command.CommandId)5 Examples (com.sx4.bot.annotations.command.Examples)5 BotPermissions (com.sx4.bot.annotations.command.BotPermissions)4 Axe (com.sx4.bot.entities.economy.item.Axe)4 PagedResult (com.sx4.bot.paged.PagedResult)4 Document (org.bson.Document)4 Bson (org.bson.conversions.Bson)4 ModuleCategory (com.sx4.bot.category.ModuleCategory)3 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)3 Operators (com.sx4.bot.database.mongo.model.Operators)3 ItemStack (com.sx4.bot.entities.economy.item.ItemStack)3 Upgrade (com.sx4.bot.entities.economy.upgrade.Upgrade)3 EconomyUtility (com.sx4.bot.utility.EconomyUtility)3 ExceptionUtility (com.sx4.bot.utility.ExceptionUtility)3 List (java.util.List)3 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)3 Argument (com.jockie.bot.core.argument.Argument)2