mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
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:
@@ -105,6 +105,10 @@ class BaseClient extends EventEmitter {
|
||||
clearInterval(interval);
|
||||
this._intervals.delete(interval);
|
||||
}
|
||||
|
||||
toJSON(...props) {
|
||||
return Util.flatten(this, { domain: false }, ...props);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BaseClient;
|
||||
|
||||
@@ -411,6 +411,15 @@ class Client extends BaseClient {
|
||||
);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return super.toJSON({
|
||||
readyAt: false,
|
||||
broadcasts: false,
|
||||
pings: false,
|
||||
presences: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a ping to {@link Client#pings}.
|
||||
* @param {number} startTime Starting time of the ping
|
||||
|
||||
Reference in New Issue
Block a user