Skip to content

Instantly share code, notes, and snippets.

@fabien0102
Created November 9, 2017 08:58
Show Gist options
  • Save fabien0102/3ff2735c65bbeb4846aff33af88107f4 to your computer and use it in GitHub Desktop.
Save fabien0102/3ff2735c65bbeb4846aff33af88107f4 to your computer and use it in GitHub Desktop.
Discord logger
/* DEBUG WITH DISCORD */
const request = require("request");
const log = content => new Promise((resolve, reject) => {
const options = {
method: 'POST',
url: `${discordWebhookURL}`, // <- setup your discord webhook url here
headers: { 'content-type': 'application/json' },
body: { content: "```json\n" + JSON.stringify(content, null, 2) + "\n```" },
json: true
};
request(options, function (error, response, body) {
if (error) return reject(error);
resolve(body);
});
});
// Usage
log("hello word"); // You can log everything: objects, arrays, strings…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment