Skip to content

Instantly share code, notes, and snippets.

@gotjoshua
Created June 15, 2021 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotjoshua/b160004a8982780ec821158dd0ad7c70 to your computer and use it in GitHub Desktop.
Save gotjoshua/b160004a8982780ec821158dd0ad7c70 to your computer and use it in GitHub Desktop.
moralis sendToDiscord channel hook
const sendToDiscord = async (channelHookURL, content) => {
// https://discord.com/developers/docs/resources/webhook#execute-webhook
let httpResponse; let status = 'success'
try {
httpResponse = await Moralis.Cloud.httpRequest({
method: 'POST',
url: channelHookURL,
body: {
flags: 1 << 2, // not working attempt to prevent links from embedding
content,
},
})
} catch (error) {
status = 'error'
log(JSON.stringify(error.data, null, 2), 'discord caught :')
}
log(`discord ${status}`)
// logger.info(JSON.stringify(httpResponse))
return { httpResponse, status }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment