Eris JSON
A helper utility for writing Eris objects to JSON
npm install eris-json
Use Eris JSON to write your bot or message objects to JSON.
const Eris = ;const ErisJSON = ; let bot = 'BOT_TOKEN'; bot; bot; bot;
Usage
Any time after initializing your bot, you can call ErisJSON.botToJSON(bot)
to write the bot object to a tab-indented JSON file in the root folder named bot.json
. You may specify a different name or path:
ErisJSON;
This function also returns the stringified JSON. If you just want to get the string and not write it to a file, pass in false
as the second argument.
let botJSON = ErisJSON;
You can write message
objects the same way from a messageCreate
event using ErisJSON.messageToJSON(message)
.
Why?
Eris has a lot of state data in its client object, as well as its message objects. I have found it useful to see it all laid out in a JSON file. But simply running JSON.stringify()
on the objects do not yield the complete structure, due to the use of getters and maps. There is also some redundant or useless data that this utility ignores. Eris comes with .toJSON()
functions for the client and messages, but these give incomplete results.
Notes
Some redundancy is eliminated in the bot and message objects. For example, the Channel objects listed in a guild's channels
property do not contain guild
properties of their own. Also, message objects contain a user
property instead of author
or member
properties. It will contain all of the added properties of a Member when the message comes from a guild channel.
Collections (or maps) are converted to arrays. Maybe they should be converted to objects instead. Tell me what you think.
My sincere thanks and appreciation to abalabahaha for their awesome library.