Add savefile.js with the database format specifications

This commit is contained in:
chylex 2016-10-23 19:25:26 +02:00
parent 00e951076e
commit 2ee1f6550b

66
src/tracker/savefile.js Normal file
View File

@ -0,0 +1,66 @@
/*
* SAVEFILE STRUCTURE
* ==================
*
* {
* meta: {
* users: {
* <discord user id>: {
* name: <user name>
* }, ...
* },
*
* // the user index is an array of discord user ids,
* // these indexes are used in the message objects to save space
* userindex: [
* <discord user id>, ...
* ],
*
* server: [
* {
* name: <server name>,
* type: <"SERVER"|"DM">
* }, ...
* ],
*
* channels: {
* <discord channel id>: {
* server: <server index in the metadata.server array>,
* name: <channel name>
* }, ...
* }
* },
*
* data: {
* <discord channel id>: {
* <discord message id>: {
* u: <user index of the sender>,
* t: <message timestamp>,
* m: <message content>,
* f: <message flags>, // bit 1 = edited, bit 2 = has user mentions (omit for no flags),
* e: [ // omit for no embeds
* {
* url: <embed url>,
* type: <embed type>
* }, ...
* ],
* a: [ // omit for no attachments
* {
* url: <attachment url>
* }, ...
* ]
* }, ...
* }, ...
* }
* }
*/
var SAVEFILE = function(){
this.db = {};
this.db.meta = {};
this.db.data = {};
};
SAVEFILE.prototype.toJson = function(){
return JSON.stringify(this.db);
};