From a70d9edbe30294ed350fe7ab76a5e56dffc8267a Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 18 May 2021 18:56:55 -0400 Subject: [PATCH] Fix --- Xiao.js | 11 ++++++----- structures/Client.js | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Xiao.js b/Xiao.js index c8ed98b4..6679a3bd 100644 --- a/Xiao.js +++ b/Xiao.js @@ -219,11 +219,12 @@ client.on('ready', async () => { client.allowedUsers.push(patron); } setInterval(() => { - client.fetchPatrons().catch(() => null); - for (const patron of client.patrons) { - if (client.allowedUsers.includes(patron)) continue; - client.allowedUsers.push(patron); - } + client.fetchPatrons().then(() => { + for (const patron of client.patrons) { + if (client.allowedUsers.includes(patron)) continue; + client.allowedUsers.push(patron); + } + }); }, 3.6e+6); client.logger.info(`[PATREON] Fetched ${client.patrons.length} patrons.`); } catch (err) { diff --git a/structures/Client.js b/structures/Client.js index 3a09a55b..471b68da 100644 --- a/structures/Client.js +++ b/structures/Client.js @@ -83,15 +83,16 @@ module.exports = class XiaoClient extends CommandoClient { .get(`https://www.patreon.com/api/oauth2/v2/campaigns/${PATREON_CAMPAIGN_ID}/members`) .set({ Authorization: `Bearer ${PATREON_ACCESS_TOKEN}` }) .query({ - include: 'currently_entitled_tiers', - 'fields[member]': 'social_connections' + include: 'currently_entitled_tiers,user', + 'fields[user]': 'social_connections' }); const patrons = []; for (const patron of body.data) { if (patron.attributes.patron_status !== 'active_patron') continue; - const userData = patron.user.social_connections.discord; - if (!userData) continue; - patrons.push(userData.user_id); + const socials = body.included.find(user => user.id === patron.relationships.user.data.id) + ?.attributes?.social_connections; + if (!socials || !socials.discord || !socials.discord.user_id) continue; + patrons.push(socials.discord.user_id); } this.patrons = patrons; return patrons;