From 7504e39ec8de22d851c66fc0d93d7092b152d3df Mon Sep 17 00:00:00 2001 From: ArcaneDisgea Date: Thu, 27 May 2021 09:49:44 -0400 Subject: [PATCH] update readme --- readme.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index d890207..39197a5 100644 --- a/readme.md +++ b/readme.md @@ -32,4 +32,45 @@ The API will reply with its status, and in case of success, the URL to the final ## Using in your application -You can use the ``create-card.js`` file in any NodeJS project. It will return a PNG-buffer for you to use in your bot or application.
Check ``index.js`` for usage examples. +``` +yarn add xiv-character-cards +# or +npm i xiv-character-cards +``` + +You will receive a PNG-buffer for you to use in your bot or application.
Check ``index.js`` for other usage examples. + +### Example + +```js +const { CardCreator } = require("xiv-character-cards"); +const fs = require("fs"); + +const card = new CardCreator(); +const lodestoneid = "13821878"; + +function example(cb) { + card.ensureInit() + .then( + () => card.createCard(lodestoneid), + (reason) => cb("Init failed: " + reason, null) + ) + .then((image) => + cb(null, { + binary: { + image: image, + }, + }) + ) + .catch((reason) => cb("createCard failed: " + reason, null)); +} + +example((err, response) => { + const buffer = response.binary.image; + fs.writeFileSync(`./${lodestoneid}.png`, response.binary.image, (err) => { + if (err) { + console.log(err); + } + }); +}); +```