Martin Dimitrov 641c64989c
All checks were successful
Build and push Doorman UI / API / docker (push) Successful in 1m22s
clean up json output
2024-10-26 14:02:44 -07:00

24 lines
633 B
JavaScript

exports.handler = async function(context, event, callback) {
const response = new Twilio.Response();
const discordPath = Runtime.getFunctions()['common/discord'].path;
const discord = require(discordPath);
let msg = event.msg;
if (event.json && event.json != "undefined") {
const fingerprint = JSON.parse(event.json);
msg += `\`\`\`# Unlocked by\n${JSON.stringify(fingerprint, null, 4)}\`\`\``;
}
console.log(event.msg);
// user must be in "Doorman" server
await discord.sendMessageToUser(context,
event.discordUser,
msg,
).catch((e) => console.error(e));
return callback(null, response);
};