Skip to content

Commit

Permalink
Fix toJSON() consistency (abalabahaha#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaaz authored Mar 24, 2021
1 parent f2af4ac commit 2974f72
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/structures/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Base {
const json = {};
if(this.id) {
json.id = this.id;
json.createdAt = this.createdAt;
}
for(const prop of props) {
const value = this[prop];
Expand Down
9 changes: 9 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ class Guild extends Base {
"afkChannelID",
"afkTimeout",
"applicationID",
"approximateMemberCount",
"approximatePresenceCount",
"autoRemoved",
"banner",
"categories",
Expand All @@ -934,6 +936,7 @@ class Guild extends Base {
"large",
"maxMembers",
"maxPresences",
"maxVideoChannelUsers",
"memberCount",
"members",
"mfaLevel",
Expand All @@ -944,12 +947,18 @@ class Guild extends Base {
"premiumTier",
"primaryCategory",
"primaryCategoryID",
"publicUpdatesChannelID",
"region",
"roles",
"rulesChannelID",
"splash",
"systemChannelFlags",
"systemChannelID",
"unavailable",
"vanityURL",
"verificationLevel",
"widgetChannelID",
"widgetEnabled",
...props
]);
}
Expand Down
13 changes: 6 additions & 7 deletions lib/structures/GuildPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,15 @@ class GuildPreview extends Base {

toJSON(props = []) {
return super.toJSON([
"id",
"name",
"icon",
"description",
"splash",
"discoverySplash",
"features",
"approximateMemberCount",
"approximatePresenceCount",
"description",
"discoverySplash",
"emojis",
"features",
"icon",
"name",
"splash",
...props
]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ class Member extends Base {
"game",
"joinedAt",
"nick",
"premiumSince",
"roles",
"status",
"user",
"voiceState",
"premiumSince",
...props
]);
}
Expand Down
9 changes: 9 additions & 0 deletions lib/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,20 +442,29 @@ class Message extends Base {

toJSON(props = []) {
return super.toJSON([
"activity",
"application",
"attachments",
"author",
"channel",
"content",
"editedTimestamp",
"embeds",
"flags",
"guildID",
"hit",
"member",
"mentionEveryone",
"mentions",
"messageReference",
"pinned",
"reactions",
"referencedMesssage",
"roleMentions",
"timestamp",
"tts",
"type",
"webhookID",
...props
]);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/structures/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class User extends Base {
"avatar",
"bot",
"discriminator",
"publicFlags",
"system",
"username",
...props
]);
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/VoiceState.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class VoiceState extends Base {
"channelID",
"deaf",
"mute",
"selfMute",
"selfDeaf",
"selfMute",
"selfStream",
"selfVideo",
"sessionID",
Expand Down

0 comments on commit 2974f72

Please sign in to comment.