Created
November 9, 2017 08:58
-
-
Save fabien0102/3ff2735c65bbeb4846aff33af88107f4 to your computer and use it in GitHub Desktop.
Discord logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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