sync from github
This commit is contained in:
60
js/modules/patreon/module.js
Normal file
60
js/modules/patreon/module.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/* ------------------------- */
|
||||
/* PATREON MODULE VARIABLES */
|
||||
/* ------------------------- */
|
||||
|
||||
const showPatreon = getURLParam("showPatreon", true);
|
||||
|
||||
const showPatreonMemberships = getURLParam("showPatreonMemberships", true);
|
||||
|
||||
// PATREON EVENTS HANDLERS
|
||||
|
||||
const patreonHandlers = {
|
||||
'Patreon.PledgeCreated': (response) => {
|
||||
patreonMemberships(response.data);
|
||||
},
|
||||
};
|
||||
|
||||
if (showPatreon) {
|
||||
registerPlatformHandlersToStreamerBot(patreonHandlers, '[Patreon]');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PATREON EVENTS FUNCTIONS
|
||||
|
||||
async function patreonMemberships(data) {
|
||||
|
||||
if (showPatreonMemberships == false) return;
|
||||
|
||||
const template = eventTemplate;
|
||||
const clone = template.content.cloneNode(true);
|
||||
const messageId = createRandomString(40);
|
||||
const userId = createRandomString(40);
|
||||
|
||||
const {
|
||||
header,
|
||||
platform,
|
||||
user,
|
||||
action,
|
||||
value,
|
||||
'actual-message': message
|
||||
} = Object.fromEntries(
|
||||
[...clone.querySelectorAll('[class]')]
|
||||
.map(el => [el.className, el])
|
||||
);
|
||||
|
||||
const classes = ['patreon', 'membership'];
|
||||
|
||||
header.remove();
|
||||
|
||||
|
||||
var money = (data.attributes.will_pay_amount_cents / 100).toFixed(2);
|
||||
|
||||
user.innerHTML = `<strong>${data.attributes.full_name}</strong>`;
|
||||
action.innerHTML = ` donated `;
|
||||
value.innerHTML = `<strong>${money}</strong>`;
|
||||
|
||||
message.remove();
|
||||
|
||||
addEventItem('patreon', clone, classes, userId, messageId);
|
||||
}
|
Reference in New Issue
Block a user