Search in sources :

Example 1 with Command

use of gg.projecteden.discord.appcommands.annotations.Command in project Nexus by ProjectEdenGG.

the class BalanceAppCommand method check.

@Command(value = "Check a player's balance", literals = false)
void check(@Desc("player") @Default("self") Nerd player, @Desc("gamemode") @Default("SURVIVAL") @Optional ShopGroup gamemode) {
    boolean isSelf = PlayerUtils.isSelf(player, verify());
    String formatted = new BankerService().getBalanceFormatted(player, gamemode);
    replyEphemeral(camelCase(gamemode) + " balance" + (isSelf ? "" : " of " + player.getNickname()) + ": " + formatted);
}
Also used : BankerService(gg.projecteden.nexus.models.banker.BankerService) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 2 with Command

use of gg.projecteden.discord.appcommands.annotations.Command in project Nexus by ProjectEdenGG.

the class NewPlayersAppCommand method run.

@Command(value = "List new players", literals = false)
void run() {
    final HoursService service = new HoursService();
    Map<Player, Integer> players = new HashMap<>() {

        {
            for (Player player : OnlinePlayers.getAll()) {
                Hours hours = service.get(player);
                if (!hours.has(TickTime.HOUR))
                    put(player, hours.getTotal());
            }
        }
    };
    if (players.isEmpty())
        throw new InvalidInputException("No new players found");
    StringBuilder response = new StringBuilder();
    Utils.sortByValue(players).forEach((player, hours) -> response.append(Nickname.of(player)).append(" - ").append(Timespan.ofSeconds(players.get(player)).format()).append(System.lineSeparator()));
    reply(StringUtils.getDiscordPrefix("NewPlayers") + System.lineSeparator() + response);
}
Also used : InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) Player(org.bukkit.entity.Player) HashMap(java.util.HashMap) Hours(gg.projecteden.nexus.models.hours.Hours) HoursService(gg.projecteden.nexus.models.hours.HoursService) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 3 with Command

use of gg.projecteden.discord.appcommands.annotations.Command in project Nexus by ProjectEdenGG.

the class SuggestAppCommand method run.

@Command(value = "Suggest a player for promotion", literals = false)
void run(@Desc("Player") Nerd nerd, @Desc("Rank") @Optional Rank rank) {
    if (rank == null)
        rank = nerd.getRank().getPromotion();
    if (!Arrays.asList(Rank.MEMBER, Rank.TRUSTED, Rank.ELITE, Rank.VETERAN).contains(nerd.getRank()))
        throw new InvalidInputException(nerd.getName() + " is not eligible for promotion (They are " + nerd.getRank().getName() + ")");
    Hours hours = new HoursService().get(nerd);
    String firstJoin = nerd.getFirstJoin().format(DateTimeFormatter.ofPattern("MMMM dd, yyyy"));
    String hoursTotal = TimespanBuilder.ofSeconds(hours.getTotal()).noneDisplay(true).format();
    String hoursMonthly = TimespanBuilder.ofSeconds(hours.getMonthly()).noneDisplay(true).format();
    String history = "None";
    if (Punishments.of(nerd).hasHistory())
        history = Punishments.of(nerd).getPunishments().size() + " [View](" + Justice.URL + "/history/" + nerd.getName() + ")";
    EmbedBuilder embed = new EmbedBuilder().appendDescription("\n:information_source: **Rank**: " + nerd.getRank().getName()).appendDescription("\n:calendar_spiral: **First join**: " + firstJoin).appendDescription("\n:clock" + RandomUtils.randomInt(1, 12) + ": **Hours (Total)**: " + hoursTotal).appendDescription("\n:clock" + RandomUtils.randomInt(1, 12) + ": **Hours (Monthly)**: " + hoursMonthly).appendDescription("\n:scroll: **History**: " + history).setThumbnail("https://minotar.net/helm/" + nerd.getName() + "/100.png");
    embed.setColor(rank.getDiscordColor());
    String name = nerd.getName();
    if (nerd.hasNickname())
        name = "%s (%s)".formatted(nerd.getNickname(), name);
    reply(new MessageBuilder().setContent("@here " + member().getAsMention() + " is suggesting **" + name + "** for **" + camelCase(rank.getName()) + "**").setEmbeds(embed.build()));
}
Also used : InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) MessageBuilder(net.dv8tion.jda.api.MessageBuilder) Hours(gg.projecteden.nexus.models.hours.Hours) HoursService(gg.projecteden.nexus.models.hours.HoursService) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 4 with Command

use of gg.projecteden.discord.appcommands.annotations.Command in project Nexus by ProjectEdenGG.

the class TicketsAppCommand method reopen.

@Command("Reopen a ticket")
void reopen(@Desc("Ticket Id") Ticket ticket) {
    if (ticket.isOpen())
        throw new InvalidInputException("Ticket already open");
    ticket.setOpen(true);
    service.save(tickets);
    TicketFeature.broadcastDiscord(ticket, nickname(), TicketAction.REOPEN);
    thumbsupEphemeral();
}
Also used : InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Example 5 with Command

use of gg.projecteden.discord.appcommands.annotations.Command in project Nexus by ProjectEdenGG.

the class TicketsAppCommand method list.

@Command("List open tickets")
void list() {
    List<Ticket> opened = tickets.getTickets().stream().filter(Ticket::isOpen).collect(Collectors.toList());
    if (opened.isEmpty())
        throw new InvalidInputException("There are no open tickets");
    String ids = opened.stream().map(_ticket -> "#" + _ticket.getId()).collect(Collectors.joining(", "));
    replyEphemeral(PREFIX + ids);
}
Also used : Verify(gg.projecteden.nexus.features.discord.appcommands.annotations.Verify) Desc(gg.projecteden.discord.appcommands.annotations.Desc) AppCommandRegistry(gg.projecteden.discord.appcommands.AppCommandRegistry) Tickets(gg.projecteden.nexus.models.ticket.Tickets) TicketAction(gg.projecteden.nexus.features.tickets.TicketFeature.TicketAction) Collectors(java.util.stream.Collectors) Ticket(gg.projecteden.nexus.models.ticket.Tickets.Ticket) Utils(gg.projecteden.nexus.utils.Utils) AppCommandEvent(gg.projecteden.discord.appcommands.AppCommandEvent) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) List(java.util.List) TicketsService(gg.projecteden.nexus.models.ticket.TicketsService) TicketFeature(gg.projecteden.nexus.features.tickets.TicketFeature) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand) RequiredRole(gg.projecteden.discord.appcommands.annotations.RequiredRole) Ticket(gg.projecteden.nexus.models.ticket.Tickets.Ticket) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) Command(gg.projecteden.discord.appcommands.annotations.Command) NexusAppCommand(gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)

Aggregations

Command (gg.projecteden.discord.appcommands.annotations.Command)15 NexusAppCommand (gg.projecteden.nexus.features.discord.appcommands.NexusAppCommand)15 InvalidInputException (gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException)7 RequiredRole (gg.projecteden.discord.appcommands.annotations.RequiredRole)3 Verify (gg.projecteden.nexus.features.discord.appcommands.annotations.Verify)2 BankerService (gg.projecteden.nexus.models.banker.BankerService)2 DiscordUserService (gg.projecteden.nexus.models.discord.DiscordUserService)2 Hours (gg.projecteden.nexus.models.hours.Hours)2 HoursService (gg.projecteden.nexus.models.hours.HoursService)2 AppCommandEvent (gg.projecteden.discord.appcommands.AppCommandEvent)1 AppCommandRegistry (gg.projecteden.discord.appcommands.AppCommandRegistry)1 Desc (gg.projecteden.discord.appcommands.annotations.Desc)1 TicketFeature (gg.projecteden.nexus.features.tickets.TicketFeature)1 TicketAction (gg.projecteden.nexus.features.tickets.TicketFeature.TicketAction)1 NegativeBalanceException (gg.projecteden.nexus.framework.exceptions.preconfigured.NegativeBalanceException)1 NotEnoughMoneyException (gg.projecteden.nexus.framework.exceptions.preconfigured.NotEnoughMoneyException)1 Transaction (gg.projecteden.nexus.models.banker.Transaction)1 DeathMessagesService (gg.projecteden.nexus.models.deathmessages.DeathMessagesService)1 DiscordUser (gg.projecteden.nexus.models.discord.DiscordUser)1 NicknameHistoryEntry (gg.projecteden.nexus.models.nickname.Nickname.NicknameHistoryEntry)1