Search in sources :

Example 21 with BotPermissions

use of com.sx4.bot.annotations.command.BotPermissions in project Sx4 by sx4-discord-bot.

the class MinerCommand method shop.

@Command(value = "shop", description = "View all the different miners you can buy")
@CommandId(402)
@Examples({ "miner shop" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void shop(Sx4CommandEvent event) {
    List<Miner> miners = event.getBot().getEconomyManager().getItems(Miner.class);
    PagedResult<Miner> paged = new PagedResult<>(event.getBot(), miners).setPerPage(12).setCustomFunction(page -> {
        EmbedBuilder embed = new EmbedBuilder().setDescription("Miners are a good way to easily gather materials").setAuthor("Miner Shop", null, event.getSelfUser().getEffectiveAvatarUrl()).setTitle("Page " + page.getPage() + "/" + page.getMaxPage()).setFooter(PagedResult.DEFAULT_FOOTER_TEXT);
        page.forEach((miner, index) -> embed.addField(miner.getName(), String.format("Price: $%,d", miner.getPrice()), true));
        return new MessageBuilder().setEmbeds(embed.build());
    });
    paged.execute(event);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) PagedResult(com.sx4.bot.paged.PagedResult) 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)

Example 22 with BotPermissions

use of com.sx4.bot.annotations.command.BotPermissions 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) ReturnDocument(com.mongodb.client.model.ReturnDocument) 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)

Example 23 with BotPermissions

use of com.sx4.bot.annotations.command.BotPermissions in project Sx4 by sx4-discord-bot.

the class AxeCommand method shop.

@Command(value = "shop", description = "View all the axes you are able to buy or craft")
@CommandId(388)
@Examples({ "axe shop" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void shop(Sx4CommandEvent event) {
    List<Axe> axes = event.getBot().getEconomyManager().getItems(Axe.class);
    PagedResult<Axe> paged = new PagedResult<>(event.getBot(), axes).setPerPage(12).setCustomFunction(page -> {
        EmbedBuilder embed = new EmbedBuilder().setAuthor("Axe Shop", null, event.getSelfUser().getEffectiveAvatarUrl()).setTitle("Page " + page.getPage() + "/" + page.getMaxPage()).setDescription("Axes are a good way to get some wood for crafting").setFooter(PagedResult.DEFAULT_FOOTER_TEXT);
        page.forEach((axe, index) -> {
            List<ItemStack<CraftItem>> items = axe.getCraft();
            String craft = items.isEmpty() ? "None" : items.stream().map(ItemStack::toString).collect(Collectors.joining("\n"));
            embed.addField(axe.getName(), String.format("Price: $%,d\nCraft: %s\nDurability: %,d", axe.getPrice(), craft, axe.getMaxDurability()), true);
        });
        return new MessageBuilder().setEmbeds(embed.build());
    });
    paged.execute(event);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) ItemStack(com.sx4.bot.entities.economy.item.ItemStack) PagedResult(com.sx4.bot.paged.PagedResult) 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)

Example 24 with BotPermissions

use of com.sx4.bot.annotations.command.BotPermissions in project Sx4 by sx4-discord-bot.

the class CrateCommand method shop.

@Command(value = "shop", description = "View all the crates you can buy")
@CommandId(411)
@Examples({ "crate shop" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void shop(Sx4CommandEvent event) {
    List<Crate> crates = event.getBot().getEconomyManager().getItems(Crate.class).stream().filter(Predicate.not(Crate::isHidden)).collect(Collectors.toList());
    PagedResult<Crate> paged = new PagedResult<>(event.getBot(), crates).setPerPage(12).setCustomFunction(page -> {
        EmbedBuilder embed = new EmbedBuilder().setDescription("Crates give you a random item, the better the crate the better the chance of a better item").setAuthor("Crate Shop", null, event.getSelfUser().getEffectiveAvatarUrl()).setTitle("Page " + page.getPage() + "/" + page.getMaxPage()).setFooter(PagedResult.DEFAULT_FOOTER_TEXT);
        page.forEach((crate, index) -> embed.addField(crate.getName(), String.format("Price: $%,d\nContents: %s", crate.getPrice(), crate.getContentString()), true));
        return new MessageBuilder().setEmbeds(embed.build());
    });
    paged.execute(event);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Crate(com.sx4.bot.entities.economy.item.Crate) PagedResult(com.sx4.bot.paged.PagedResult) 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)

Example 25 with BotPermissions

use of com.sx4.bot.annotations.command.BotPermissions in project Sx4 by sx4-discord-bot.

the class PickaxeCommand method shop.

@Command(value = "shop", description = "View all the pickaxes you are able to buy or craft")
@CommandId(360)
@Examples({ "pickaxe shop" })
@BotPermissions(permissions = { Permission.MESSAGE_EMBED_LINKS })
public void shop(Sx4CommandEvent event) {
    List<Pickaxe> pickaxes = event.getBot().getEconomyManager().getItems(Pickaxe.class);
    PagedResult<Pickaxe> paged = new PagedResult<>(event.getBot(), pickaxes).setPerPage(12).setCustomFunction(page -> {
        EmbedBuilder embed = new EmbedBuilder().setAuthor("Pickaxe Shop", null, event.getSelfUser().getEffectiveAvatarUrl()).setTitle("Page " + page.getPage() + "/" + page.getMaxPage()).setDescription("Pickaxes are a good way to gain some extra money aswell as some materials").setFooter(PagedResult.DEFAULT_FOOTER_TEXT);
        page.forEach((pickaxe, index) -> {
            List<ItemStack<CraftItem>> items = pickaxe.getCraft();
            String craft = items.isEmpty() ? "None" : items.stream().map(ItemStack::toString).collect(Collectors.joining("\n"));
            embed.addField(pickaxe.getName(), String.format("Price: $%,d\nCraft: %s\nDurability: %,d", pickaxe.getPrice(), craft, pickaxe.getMaxDurability()), true);
        });
        return new MessageBuilder().setEmbeds(embed.build());
    });
    paged.execute(event);
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Pickaxe(com.sx4.bot.entities.economy.item.Pickaxe) ItemStack(com.sx4.bot.entities.economy.item.ItemStack) PagedResult(com.sx4.bot.paged.PagedResult) 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

Command (com.jockie.bot.core.command.Command)44 Sx4Command (com.sx4.bot.core.Sx4Command)44 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)37 BotPermissions (com.sx4.bot.annotations.command.BotPermissions)33 CommandId (com.sx4.bot.annotations.command.CommandId)33 Examples (com.sx4.bot.annotations.command.Examples)31 Document (org.bson.Document)29 PagedResult (com.sx4.bot.paged.PagedResult)25 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)21 Bson (org.bson.conversions.Bson)20 Argument (com.jockie.bot.core.argument.Argument)14 ModuleCategory (com.sx4.bot.category.ModuleCategory)14 Sx4CommandEvent (com.sx4.bot.core.Sx4CommandEvent)14 Permission (net.dv8tion.jda.api.Permission)14 User (net.dv8tion.jda.api.entities.User)14 Collectors (java.util.stream.Collectors)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 java.util (java.util)10 ArrayList (java.util.ArrayList)10 FormatterManager (com.sx4.bot.formatter.FormatterManager)9