summaryrefslogtreecommitdiff
path: root/src/main/java/net/uomc/mineshaft/DailyCommand.java
blob: 129c336a422d90d7dd5fd61f3e961efa7748838b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package net.uomc.mineshaft;

import java.util.LinkedHashMap;
import java.util.Map;

import com.mouldycheerio.dbot.commands.CommandDetails;
import com.mouldycheerio.dbot.commands.cooldowns.CooldownCommand;

import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class DailyCommand extends CooldownCommand {

    Mineshaft bot;

    public DailyCommand(Mineshaft bot) {
        super(bot);
        setCommandDetails(CommandDetails.from("daily", "get free ores", "furnace"));
        this.bot = bot;

        setCooldown(24l* 60l * 60l * 1000l);
    }

    @Override
    public boolean trigger(MessageReceivedEvent e) {


        Map<MineshaftItem, Long> award = new LinkedHashMap<>();
        for (int i = 0; i < 10; ++i) {
            award = bot.sumItems(award,
                    bot.getMineCommand().getAwards(e.getMember(),
                            bot.getMineCommand().getOre(
                                   e.getMember())));
        }
        ;

        String awardsList = bot.createItemList(award, "+%s", ", ");
        bot.sendSuccessMessage(e, "You received your daily ores:\n**" + awardsList +"**");
        bot.addItems(e.getMember(), award);
        return true;
    }
}