You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I double checked the docs and couldn't find any useful information.
Verify Issue Source
I verified the issue was caused by Discord.Net.
Check your intents
I double checked that I have the required intents.
Description
When using the ToJsonString extension, a Cast error is returned Unable to cast object of type 'Discord.API.Embed' to type 'Discord.EmbedType' and when using the Parse, a constructor error is returned Unable to find a constructor to use for type Discord.Embed. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute.
Version
3.10.0
Working Version
No response
Logs
ToJsonString: System.InvalidCastException: Unable to cast object of type 'Discord.API.Embed' to type 'Discord.EmbedType'. at Discord.Net.Converters.EmbedTypeConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings) at Discord.Rest.StringExtensions.ToJsonString(Embed embed, Formatting formatting) at BOT.Commands.Interaction.Modules.Slash.Global.EmbedCreate.EmbedCreateCommand.RunExportButton() in C:\repos\Alfredo\BOT\Commands\Interaction\Modules\Slash\Global\EmbedCreate\ButtonExportCommand.cs:line 27 at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()
Parse: Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type Discord.Embed. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'description', line 1, position 15. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at Discord.EmbedBuilder.Parse(String json) at BOT.Commands.Interaction.Modules.Slash.Global.EmbedCreate.EmbedCreateCommand.RunImportModal(ModalEditEmbed modal) in C:\repos\Alfredo\BOT\Commands\Interaction\Modules\Slash\Global\EmbedCreate\ButtonImportCommand.cs:line 39 at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()
//String json received by modal in variable `Paragraph0`.EmbedBuildereb= EmbedBuilder.Parse(modal.Paragraph0);await DeferAsync();await Context.Interaction.ModifyOriginalResponseAsync(x => x.Embed = eb.Build());
Packages
Newtonsoft.Json v13.0.2
The text was updated successfully, but these errors were encountered:
Hello, could you explain what it is you're trying to achieve with this code, and why you've chosen to do it this way?
It seems like the issue here is that an Embed can't really be constructed from a json, if that's what you're trying to do, which isn't really something documented as far as I can tell
Hello, could you explain what it is you're trying to achieve with this code, and why you've chosen to do it this way? It seems like the issue here is that an Embed can't really be constructed from a json, if that's what you're trying to do, which isn't really something documented as far as I can tell
The extensions I mentioned (Embed.ToJsonString() and EmbedBuilder.Parse()) were included in pull #2284.
As they are native Discord.Net functions and have errors, I reported them.
Check The Docs
Verify Issue Source
Check your intents
Description
When using the ToJsonString extension, a Cast error is returned
Unable to cast object of type 'Discord.API.Embed' to type 'Discord.EmbedType'
and when using the Parse, a constructor error is returnedUnable to find a constructor to use for type Discord.Embed. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute
.Version
3.10.0
Working Version
No response
Logs
ToJsonString:
System.InvalidCastException: Unable to cast object of type 'Discord.API.Embed' to type 'Discord.EmbedType'. at Discord.Net.Converters.EmbedTypeConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings) at Discord.Rest.StringExtensions.ToJsonString(Embed embed, Formatting formatting) at BOT.Commands.Interaction.Modules.Slash.Global.EmbedCreate.EmbedCreateCommand.RunExportButton() in C:\repos\Alfredo\BOT\Commands\Interaction\Modules\Slash\Global\EmbedCreate\ButtonExportCommand.cs:line 27 at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()
Parse:
Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type Discord.Embed. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'description', line 1, position 15. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at Discord.EmbedBuilder.Parse(String json) at BOT.Commands.Interaction.Modules.Slash.Global.EmbedCreate.EmbedCreateCommand.RunImportModal(ModalEditEmbed modal) in C:\repos\Alfredo\BOT\Commands\Interaction\Modules\Slash\Global\EmbedCreate\ButtonImportCommand.cs:line 39 at Discord.Interactions.Builders.ModuleClassBuilder.<>c__DisplayClass11_0.<<CreateCallback>g__ExecuteCallback|1>d.MoveNext()
Sample
Packages
Newtonsoft.Json v13.0.2
The text was updated successfully, but these errors were encountered: