#[SOLVED] Sending an image that embeds?
1 messages · Page 1 of 1 (latest)
I've looked at the documentation and saw the Embed Image, but it requires an URL, I can't really upload images, because the software I'm contributing to is used by a lot of people and we don't have any funds to finance an API.
It would be ideal if we could have the image embed if sent as a file.
use the url "attachment://<uploadFileNAme>" in .WithImage
no not that one
you still need the MessageBuilder with the .WithFile
just use the AddEmbed on that with that EmbedBuilder
the part after the attachment:// is the files name not its full path
Ooh, that might the problem
Let me try
that is the problem
before the /Map ?
Rendered_Maps/ < this
tried that
also I doubt embeds support .bmp
I tried with png too
youre missing the embed
you use both the embed and the messagebuilder
not one or the other
Something like this?
I get an empty embed
Tried with .WithFiles too doesn't work
Could you please write out the code part, I just picked up this library, I know it's spoon feeding but I tried different combinations already?
Thanks
cant give the exact code example but heres a step by step tutorial
- do not send the embed, just store it in a variable
- get the commented .SendMessageAsync call from a few lines below, and just add
.AddEmbed(theVariableYouPutTheEmbedBuilderIn)call there - send the MessageBuilder, not the EmbedBuilder
So basically this? :
var embed = new DiscordEmbedBuilder().WithImageUrl($"attachment://{filePath}");
var messageBuilder = new DiscordMessageBuilder().AddEmbed(embed);
_client.SendMessageAsync(_channel, messageBuilder).Wait();
you deleted .AddFile
AddFile is for WebhookBuilder and InteractionResponseBuilder from what I see
I've added WithFile
oh yeah that
var embed = new DiscordEmbedBuilder().WithImageUrl($"attachment://{filePath}");
var messageBuilder = new DiscordMessageBuilder()
.AddEmbed(embed)
.WithFiles(new Dictionary<string, Stream>() { { filePath, fs } });
_client.SendMessageAsync(_channel, messageBuilder).Wait();
that should do it
doesn't work either way
could it be that the image is corrupted and the client cannot display it
you're also giving discord a file path, not a file name
I am giving it just the fileName
then rename your variable please
I strip evertything before the file name
so filePath contains the string "file.png" or similar?
The images are "corrupted"
🗿 🗿 🗿
seems that they're not properly converted
but the .net paint does not have issues with them
this one works
Anyone knows a good image converting library for all platforms in .NET Core?
Btw thanks for the help
imagemagick for simple converting
skiasharp for drawing
I am using it already
Slapped an example from their documentation, I think I am doing it correctly
ehm… maybe im just having a moment… but this code looks wrong
like it doesnt save the image
it just renames the .bmp to .png
I haven't found any other override for Write that accepts the file name
I think that it should save into the opened file
maybe I am wrong
if you just need the image to upload it to discord you dont need to save it to disk
you can pass the meory stream to .WithFile
I am rendering an image from a stream of bytes over the network
I have the render in the console, and as an image, I use .bmp because it's the only one that works on all platforms in .NET
and how big can they get? because if you want to convert them to png later on you can just leave them in memory… but depending on your hardware and how often the function is called that could also end badly (50 images each 50mb in memory, possible, but could also crash the bot on resource constrained hardware)
well, the crashing part probably depends on your error handling but i think you get the point
they can't get that bigger
I think max is 1024
let me check if we have a limit on the picture size
they're usually in kilobytes
ok, so if you dont need the .bmp image FILE, just write it in a memory stream and pass that to image magickk to write in a png file