miramallows / patreon-discord

a patreon api v2 wrapper that allows you to grab your patrons' data easily without the hassle of dealing with scopes and the JSON:API spec standard.
19 stars 14 forks source link

I got this error! #2

Closed JoniXTech closed 2 years ago

JoniXTech commented 3 years ago

I got this error:

Connected to the Mongodb database.
[
  {
    code: 1,
    code_name: 'NotFound',
    detail: 'The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.',
    id: 'ab22b93b-739b-41d2-bef1-7c15efa69625',
    status: '404',
    title: 'Not Found'
  }
]
/Users/jonathan/Documents/Green-Bot-Dev/node_modules/patreon-discord/class/campaign.js:77
        const { allPatronsPledges: pledges, allPatronsSocials: socials } = await this._scrapeData();
                                   ^

TypeError: Cannot destructure property 'allPatronsPledges' of '(intermediate value)' as it is undefined.
    at Campaign.fetchPatrons (/Users/jonathan/Documents/Green-Bot-Dev/node_modules/patreon-discord/class/campaign.js:77:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
pauldb09 commented 2 years ago

@miramallows Having a look will be realy appreciated

miramallows commented 2 years ago

@pauldb09 @JoniXTech Could I see your code snippets relevant to this?

JoniXTech commented 2 years ago

That´s not working in the package:

async fetchPatrons (patronStatusFilter) {

        const { allPatronsPledges: pledges, allPatronsSocials: socials } = await this._scrapeData();
        const patrons = await this._sortData(pledges, socials, patronStatusFilter)
        return patrons;

    }

And i tried this in my code:

const { Campaign } = require('patreon-discord')

const myCampaign = new Campaign({ 
                patreonToken: 'my patreonToken',
                campaignId: 'my campaignId'
            })

            myCampaign.fetchPatrons(['active_patron', 'declined_patron'])
                .then(patrons => { 
                    console.log(patrons)
                })
miramallows commented 2 years ago

hey @JoniXTech, i couldn't recreate this bug. I imagine it might be related to missing your campaign ID or that your campaign ID is invalid?

there's a few ways to grab the campaign id, the easiest way is going to your main page of patreon (for me, it would be https://patreon.com/mimubot ) and type this in your console. prompt('Campaign ID',window.patreon.bootstrap.creator.data.id);

from there you'll be prompted with a copy-pasteable campaign id :)