use of net.kodehawa.mantarobot.core.CommandRegistry in project MantaroBot by Mantaro.
the class MoneyCmds method balance.
@Subscribe
public void balance(CommandRegistry cr) {
cr.register("balance", new SimpleCommand(Category.CURRENCY) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
User user = event.getAuthor();
boolean isExternal = false;
List<Member> found = FinderUtil.findMembers(content, event.getGuild());
if (found.isEmpty() && !content.isEmpty()) {
event.getChannel().sendMessage(EmoteReference.ERROR + "Your search yielded no results :(").queue();
return;
}
if (found.size() > 1 && !content.isEmpty()) {
event.getChannel().sendMessage(String.format("%sToo many users found, maybe refine your search? (ex. use name#discriminator)\n" + "**Users found:** %s", EmoteReference.THINKING, found.stream().map(m -> m.getUser().getName() + "#" + m.getUser().getDiscriminator()).collect(Collectors.joining(", ")))).queue();
return;
}
if (found.size() == 1) {
user = found.get(0).getUser();
isExternal = true;
}
long balance = MantaroData.db().getPlayer(user).getMoney();
event.getChannel().sendMessage(EmoteReference.DIAMOND + (isExternal ? user.getName() + "'s balance is: **$" : "Your balance is: **$") + balance + "**").queue();
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return baseEmbed(event, "Balance command").setDescription("**Shows your current balance or another person's balance.**").build();
}
});
cr.registerAlias("balance", "credits");
cr.registerAlias("balance", "bal");
}
Aggregations