Search in sources :

Example 1 with Campaign

use of com.patreon.resources.Campaign in project DiscordSailv2 by Vaerys-Dawn.

the class Client method checkPatrons.

public static void checkPatrons() {
    if (!checkPatreonIsValid())
        return;
    List<Long> patronIDs = new ArrayList<>();
    try {
        if (patreonApi == null)
            return;
        List<Campaign> campaigns = patreonApi.fetchCampaigns().get();
        for (Campaign c : campaigns) {
            List<Pledge> pledges = patreonApi.fetchAllPledges(c.getId());
            if (pledges != null) {
                for (Pledge p : pledges) {
                    if (p.getReward().getTitle().equalsIgnoreCase("Pioneer")) {
                        try {
                            long userID = Long.parseUnsignedLong(p.getPatron().getSocialConnections().getDiscord().getUser_id());
                            patronIDs.add(userID);
                        } catch (NumberFormatException e) {
                        // skip
                        }
                    }
                }
            }
        }
        logger.info("Patron List Updated.");
    } catch (IOException e) {
    // nothing happens
    }
    Globals.setPatrons(patronIDs);
}
Also used : Campaign(com.patreon.resources.Campaign) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Pledge(com.patreon.resources.Pledge)

Aggregations

Campaign (com.patreon.resources.Campaign)1 Pledge (com.patreon.resources.Pledge)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1