diff --git a/src/providers/patreon.ts b/src/providers/patreon.ts index b36ac59..810c759 100644 --- a/src/providers/patreon.ts +++ b/src/providers/patreon.ts @@ -27,7 +27,7 @@ export async function fetchPatreonSponsors(token: string): Promise !!pledge.relationships?.reward?.data) - .filter((pledge: any) => { + .filter((membership: any) => { // Filter declined users - if (pledge.attributes.declined_since) - return new Date(pledge.attributes.declined_since).getTime() - new Date().getTime() > 0 - return true + return membership.attributes.patron_status !== 'declined_patron' }) - .map((pledge: any) => ({ - pledge, + .map((membership: any) => ({ + membership, patron: sponsorshipData.included.find( - (v: any) => v.id === pledge.relationships.patron.data.id, - ), - reward: sponsorshipData.included.find( - (v: any) => v.id === pledge.relationships.reward.data.id, + (v: any) => v.id === membership.relationships.user.data.id, ), })), ) - sponsorshipApi = sponsorshipData.links.next + sponsorshipApi = sponsorshipData.links?.next } while (sponsorshipApi) const processed = sponsors.map( @@ -70,10 +64,10 @@ export async function fetchPatreonSponsors(token: string): Promise