use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class UserProfile method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
User toGet;
List<User> mentionedUsers = message.getMentionedUsers();
if (mentionedUsers.size() == 0)
toGet = user;
else
toGet = mentionedUsers.get(0);
Profile profile = Profile.get(toGet);
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor("{0}'s profile".replace("{0}", toGet.getName()), getShard().url, toGet.getAvatarUrl());
Marriage marriage = Marry.getMarriage(toGet);
if (marriage == null)
builder.addField("Married to", "No one :(", true);
else {
builder.addField("Married to", UserUtils.getNameWithDiscriminator(marriage.getUser_one().equals(toGet.getId()) ? marriage.getUser_two() : marriage.getUser_one()), true);
}
builder.addField("Balance", RPGUtils.formatMoney(profile.getMoney()), true);
builder.addField("Items", "Coming soon!", true);
sendEmbed(builder, channel, user);
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class Daily method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
Profile profile = Profile.get(user);
if (profile.canCollect()) {
Random rand = new Random();
int random = rand.nextInt(1000);
profile.addMoney(random);
sendTranslatedMessage("Your daily bonus was **$" + random + "**, you can use this again in 24 hours!", channel, user);
profile.setCollected();
} else {
sendTranslatedMessage(profile.getCollectionTime(), channel, user);
}
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class Blackjack method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (sessions.contains(user.getId()))
return;
sendTranslatedMessage("Enter an amount to bet", channel, user);
interactiveOperation(channel, message, betMessage -> {
try {
int amountToBet = Integer.parseInt(betMessage.getContent());
Profile profile = Profile.get(user);
if (amountToBet <= 0 || profile.getMoney() < amountToBet) {
sendTranslatedMessage("You entered an invalid amount of money", channel, user);
return;
} else if (amountToBet > 5000) {
sendTranslatedMessage("The max bet is **$5,000**!", channel, user);
return;
}
Hand yourHand = new Hand().generate().generate();
Hand dealerHand = new Hand().generate().generate();
sessions.add(user.getId());
dispatchRound(amountToBet, yourHand, dealerHand, guild, channel, user, message, args);
} catch (Exception e) {
sendTranslatedMessage("You need to enter a whole number. Cancelling...", channel, user);
}
});
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class Pay method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
String[] raw = message.getRawContent().split(" ");
if (raw.length == 3) {
List<User> mentionedUsers = message.getMentionedUsers();
if (mentionedUsers.size() > 0) {
User mentioned = mentionedUsers.get(0);
if (mentioned.getId().equalsIgnoreCase(user.getId()) || mentioned.getId().equalsIgnoreCase(guild.getSelfMember().getUser().getId())) {
sendTranslatedMessage("You can't pay yourself or me, lol", channel, user);
return;
}
try {
double amount = Double.parseDouble(raw[2]);
Profile profile = Profile.get(user);
if (amount <= 0 || profile.getMoney() < amount) {
sendTranslatedMessage("You don't have enough money to do this!", channel, user);
return;
}
Profile.get(mentioned).addMoney(amount);
profile.removeMoney(amount);
sendEditedTranslation("**{0}** paid **{1}** {2}", user, channel, user.getName(), mentioned.getName(), RPGUtils.formatMoney(amount));
} catch (NumberFormatException ex) {
sendTranslatedMessage("That's not a number!", channel, user);
}
} else
sendTranslatedMessage("You need to mention a user", channel, user);
} else {
sendTranslatedMessage("Use /pay @User [amount]", channel, user);
}
}
use of tk.ardentbot.utils.rpg.profiles.Profile in project Ardent by adamint.
the class RPGMoney method setupSubcommands.
@Override
public void setupSubcommands() throws Exception {
subcommands.add(new Subcommand("See who has the most money - globally!", "top", "top") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (args.length == 2) {
HashMap<User, Double> moneyAmounts = new HashMap<>();
Cursor<HashMap> top = r.db("data").table("profiles").orderBy().optArg("index", r.desc("money")).limit(20).run(connection);
top.forEach(hashMap -> {
Profile profile = asPojo(hashMap, Profile.class);
assert profile.getUser() != null;
moneyAmounts.put(profile.getUser(), profile.getMoney());
});
Map<User, Double> sortedAmounts = MapUtils.sortByValue(moneyAmounts);
String topMoney = "Global Richest Users";
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor(topMoney, getShard().url, guild.getIconUrl());
StringBuilder description = new StringBuilder();
final int[] current = { 0 };
sortedAmounts.forEach((u, money) -> {
if (u != null) {
description.append("\n#" + (current[0] + 1) + ": **" + u.getName() + "** " + RPGUtils.formatMoney(money));
current[0]++;
}
});
description.append("\n\nGet money by sending commands or asking questions on our support server ( https://ardentbot" + ".tk/guild )\n\nSee people's money by doing /money @User or see yours by just using /money");
sendEmbed(builder.setDescription(description.toString()), channel, user);
return;
}
try {
int page = Integer.parseInt(args[2]) - 1;
HashMap<User, Double> moneyAmounts = new HashMap<>();
Cursor<HashMap> top = r.db("data").table("profiles").orderBy().optArg("index", r.desc("money")).slice((page * 20), (page * 20) + 11).limit(25).run(connection);
top.forEach(hashMap -> {
Profile profile = asPojo(hashMap, Profile.class);
assert profile.getUser() != null;
moneyAmounts.put(profile.getUser(), profile.getMoney());
});
Map<User, Double> sortedAmounts = MapUtils.sortByValue(moneyAmounts);
String topMoney = "Global Richest Users | Page " + page;
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor(topMoney, getShard().url, guild.getIconUrl());
StringBuilder description = new StringBuilder();
final int[] current = { 0 };
sortedAmounts.forEach((u, money) -> {
if (u != null) {
description.append("\n#" + ((page * 20) + current[0] + 1) + ": **" + u.getName() + "** " + RPGUtils.formatMoney(money));
current[0]++;
}
});
description.append("\n\nGet money by sending commands or asking questions on our support server ( https://ardentbot" + ".tk/guild )\n\nSee people's money by doing /money @User or see yours by just using /money");
sendEmbed(builder.setDescription(description.toString()), channel, user);
} catch (NumberFormatException e) {
sendTranslatedMessage("You need to specify a valid page number!", channel, user);
}
}
});
subcommands.add(new Subcommand("See who has the most money in your server", "server", "server", "guild", "topguild") {
@Override
public void onCall(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
if (!generatedFirstTimeFor.contains(guild.getId())) {
sendTranslatedMessage("Please wait a second, generating and caching your server's statistics", channel, user);
generatedFirstTimeFor.add(guild.getId());
}
HashMap<User, Double> moneyAmounts = new HashMap<>();
guild.getMembers().forEach(member -> {
User u = member.getUser();
moneyAmounts.put(u, Profile.get(u).getMoney());
});
Map<User, Double> sortedAmounts = MapUtils.sortByValue(moneyAmounts);
EmbedBuilder builder = MessageUtils.getDefaultEmbed(user);
builder.setAuthor("Richest Users | This Server", getShard().url, guild.getIconUrl());
StringBuilder description = new StringBuilder();
description.append("**Richest Users in this Server**");
final int[] current = { 0 };
sortedAmounts.forEach((u, money) -> {
if (current[0] < 10) {
description.append("\n#" + (current[0] + 1) + ": **" + u.getName() + "** " + RPGUtils.formatMoney(money));
current[0]++;
}
});
description.append("\n\nGet money by sending commands or asking questions on our support server ( https://ardentbot" + ".tk/guild )\n\nSee people's money by doing /money @User or see yours by just using /money");
sendEmbed(builder.setDescription(description.toString()), channel, user);
}
});
}
Aggregations