mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-21 16:16:10 -05:00
Remove old Discord roles when changing tiers
This commit is contained in:
11
src/util.js
11
src/util.js
@@ -292,7 +292,16 @@ async function handleStripeEvent(event) {
|
||||
const discordId = pnid.get('connections.discord.id');
|
||||
|
||||
if (subscription.status === 'canceled' && currentSubscriptionId && subscription.id !== currentSubscriptionId) {
|
||||
// Canceling old subscription, do nothing but update webhook date
|
||||
// Canceling old subscription, do nothing but update webhook date and remove Discord roles
|
||||
if (product.metadata.beta === 'true') {
|
||||
removeDiscordMemberTesterRole(discordId).catch(error => {
|
||||
logger.error(`Error removing user Discord tester role | ${customer.id}, ${discordId}, ${pid} | - ${error.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
removeDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
|
||||
logger.error(`Error removing user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
|
||||
});
|
||||
|
||||
const updateData = {
|
||||
'connections.stripe.latest_webhook_timestamp': event.created
|
||||
|
||||
Reference in New Issue
Block a user