Search in sources :

Example 1 with CoinhiveUser

use of fun.rubicon.core.coinhive.CoinhiveUser in project Rubicon by Rubicon-Bot.

the class CommandMiner method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    CoinhiveUser coinhiveUser = CoinhiveManager.getCoinhiveUser(parsedCommandInvocation.getAuthor());
    UserSQL userSQL = new UserSQL(parsedCommandInvocation.getAuthor());
    if (parsedCommandInvocation.getArgs().length == 0) {
        return EmbedUtil.message(new EmbedBuilder().setDescription("You currently have `" + coinhiveUser.getBalance() + "` hashes.").setAuthor(parsedCommandInvocation.getAuthor().getName(), null, parsedCommandInvocation.getAuthor().getAvatarUrl()).setColor(Colors.COLOR_PRIMARY).setFooter("Miner more on https://miner.rubicon.fun", null));
    }
    if (parsedCommandInvocation.getArgs()[0].equalsIgnoreCase("payout")) {
        int withdrawAmount = (int) coinhiveUser.getBalance();
        if (withdrawAmount == 0) {
            return EmbedUtil.message(EmbedUtil.error("No money!", "You have to mine new rubys first."));
        }
        int oldMoney = Integer.parseInt(userSQL.get("money"));
        int newMoney = oldMoney + withdrawAmount;
        userSQL.set("money", newMoney + "");
        CoinhiveManager.withdrawUser(coinhiveUser, withdrawAmount);
        return EmbedUtil.message(EmbedUtil.success("Payout successfull!", "Transfered `" + withdrawAmount + "` rubys."));
    } else {
        return createHelpMessage();
    }
}
Also used : UserSQL(fun.rubicon.sql.UserSQL) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) CoinhiveUser(fun.rubicon.core.coinhive.CoinhiveUser)

Aggregations

CoinhiveUser (fun.rubicon.core.coinhive.CoinhiveUser)1 UserSQL (fun.rubicon.sql.UserSQL)1 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)1