-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Util): flatten ignoring certain fields #7773
Conversation
Addresses Issue discordjs#7712
This is what Message.toJSON() looks like before I made the change. {
"channelId": "723654712410374194",
"guildId": "605969074178228224",
"id": "963209574242979900",
"createdTimestamp": 1649717458068,
"type": 0,
"system": false,
"content": "",
"authorId": "605975599609020437",
"pinned": false,
"tts": false,
"nonce": null,
"embeds": [
{}
],
"components": [],
"attachments": [],
"stickers": [],
"editedTimestamp": null,
"webhookId": null,
"groupActivityApplicationId": null,
"applicationId": null,
"activity": null,
"flags": 0,
"reference": null,
"interaction": null,
"cleanContent": ""
} This is what it looks like with the change. Both {
"channelId": "723654712410374194",
"guildId": "605969074178228224",
"id": "963209574242979900",
"createdTimestamp": 1649717458068,
"type": 0,
"system": false,
"content": "",
"authorId": "605975599609020437",
"pinned": false,
"tts": false,
"nonce": null,
"embeds": [
{
"data": {
"type": "rich",
"author": {
"name": "hey"
}
}
}
],
"components": [],
"attachments": [],
"stickers": [],
"editedTimestamp": null,
"mentions": {
"everyone": false,
"users": [],
"roles": [],
"crosspostedChannels": [],
"repliedUser": null
},
"webhookId": null,
"groupActivityApplicationId": null,
"applicationId": null,
"activity": null,
"flags": 0,
"reference": null,
"interaction": null,
"cleanContent": ""
} |
One of my concerns here is... shouldn't we try to use With the switch to raw data, we may have nested data, which is what happens here in your sample: "embeds": [
{
+ "data": {
"type": "rich",
"author": {
"name": "hey"
}
+ }
}
], If |
@kyranet I made a second commit making it try to use {
"channelId": "723654712410374194",
"guildId": "605969074178228224",
"id": "963209574242979900",
"createdTimestamp": 1649717458068,
"type": 0,
"system": false,
"content": "",
"authorId": "605975599609020437",
"pinned": false,
"tts": false,
"nonce": null,
"embeds": [
{
"type": "rich",
"author": {
"name": "hey"
}
}
],
"components": [],
"attachments": [],
"stickers": [],
"editedTimestamp": null,
"mentions": {
"everyone": false,
"users": [],
"roles": [],
"crosspostedChannels": [],
"repliedUser": null,
"members": [],
"channels": []
},
"webhookId": null,
"groupActivityApplicationId": null,
"applicationId": null,
"activity": null,
"flags": 0,
"reference": null,
"interaction": null,
"cleanContent": ""
} |
Please describe the changes this PR makes and why it should be merged:
Fixes #7712
Improves clarity of toJSON functions throughout. Currently, some fields are ignored in toJSON if the value tied to that field is an object (as pointed out by issue #7712). This change fixes issue #7712 by making it so fields tied to an object don't get ignored.
Status and versioning classification: