Add toJSON methods (#1859)

* tojson things

* fix client

* ignore private properties

* remove extra property descriptors

* handle primitive flattening

* remove unused import

* add toJSON to collections

* reduce stateful props

* state

* allow custom prop names when flattening

* fix client

* fix build

* fix flatten docs

* remove guild.available, cleanup permissions, remove arbitrary id reduction

* fix util import

* add valueOf as needed, update member props

* fix incorrect merge

* update permissionoverwrites and permissions

remove serialization of permissions in PermissionOverwrites#toJSON.
change Permissions#toJSON to serialize permissions, by default excluding
admin checks.

* change Permissions#toJSON to return the primitive

* Permissions#toJSON explicitly return bitfield
This commit is contained in:
Will Nelson
2018-03-01 21:00:21 -08:00
committed by Isabella
parent 24571e465b
commit cf7dcba1a5
28 changed files with 236 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
const Collection = require('../util/Collection');
const Snowflake = require('../util/Snowflake');
const Webhook = require('./Webhook');
const Util = require('../util/Util');
/**
* The target type of an entry, e.g. `GUILD`. Here are the available types:
@@ -220,6 +221,10 @@ class GuildAuditLogs {
return 'ALL';
}
toJSON() {
return Util.flatten(this);
}
}
/**
@@ -371,6 +376,10 @@ class GuildAuditLogsEntry {
get createdAt() {
return new Date(this.createdTimestamp);
}
toJSON() {
return Util.flatten(this, { createdTimestamp: true });
}
}
GuildAuditLogs.Actions = Actions;