Merge branch 'master' into dev

This commit is contained in:
Ash Monty
2022-11-03 17:05:28 +01:00
5 changed files with 165 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ const PNIDSchema = new Schema({
},
server_access_level: String,
access_level: Number,
username: String,
connections: {
discord: {
id: String

View File

@@ -414,6 +414,19 @@ async function handleStripeEvent(event) {
assignDiscordMemberSupporterRole(discordId, product.metadata.discord_role_id).catch(error => {
logger.error(`Error assigning user Discord supporter role | ${customer.id}, ${discordId}, ${pid}, ${product.metadata.discord_role_id} | - ${error.message}`);
});
for (const email of config.stripe.notification_emails) {
// * Send notification emails for new sub
try {
await mailer.sendMail({
to: email,
subject: `[Pretendo] - New ${product.name} subscription`,
text: `${pnid.get('username')} just became a ${product.name} tier subscriber`
});
} catch (error) {
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
}
}
}
if (subscription.status === 'canceled') {
@@ -430,6 +443,19 @@ async function handleStripeEvent(event) {
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}`);
});
for (const email of config.stripe.notification_emails) {
// * Send notification emails for new sub
try {
await mailer.sendMail({
to: email,
subject: `[Pretendo] - Canceled ${product.name} subscription`,
text: `${pnid.get('username')} just canceled their ${product.name} tier subscription`
});
} catch (error) {
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
}
}
}
if (subscription.status === 'unpaid') {
@@ -446,6 +472,19 @@ async function handleStripeEvent(event) {
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}`);
});
for (const email of config.stripe.notification_emails) {
// * Send notification emails for new sub
try {
await mailer.sendMail({
to: email,
subject: `[Pretendo] - Removed ${product.name} subscription`,
text: `${pnid.get('username')}'s ${product.name} tier subscription has been canceled due to non payment`
});
} catch (error) {
logger.error(`Error sending notification email | ${email} | - ${error.message}`);
}
}
}
}
}