DPP: slash command reply does not render image when attaching a raw image buffer
Git commit reference v10.0.32
Describe the bug When replying to a slash command, I want to reply with an image that is stored in a buffer in memory. When I do this, the image does not render in discord, but if I click ‘open in browser’ and view the image that discord received it looks perfectly normal.
To Reproduce
Steps to reproduce the behavior:
I am using the following method
message& add_file(std::string_view filename, std::string_view filecontent, std::string_view filemimetype = "");
filecontent is a valid png buffer, created by skia. my createImage method returns the image buffer(const void *) and image size(size_t). As it takes a string view, I casted it to a string and provided that as the filecontent.
Expected behavior I want the image to render correctly in discord and not display the “sad poop” image.
Screenshots
The first image is using the image buffer and the second is using an actual png file
This is the discord attachment of the image buffer
System Details:
- OS: [MacOS Sonoma 14.5, debian ubuntu 24.0.4]
- Discord Client used for testing [mobile, desktop]
Additional context This is using the image buffer
auto [imageBuffer, imageSize] = CreateImage::createImage(plusEvBets, devigInfo.devigType);
auto message = dpp::message();
std::string fileContent(reinterpret_cast<const char*>(imageBuffer), imageSize);
message.add_file("odds.png", fileContent, std::string("image/png"));
event.reply(message)
When explicitly saving the buffer to a file and attaching the png file to the message it displays fine
auto [imageBuffer, imageSize] = CreateImage::createImage(plusEvBets, devigInfo.devigType);
std::ofstream outFile("ev.png", std::ios::binary);
if (!outFile) {
printf("Failed to open file for writing.\n");
return;
}
outFile.write(reinterpret_cast<const char*>(imageBuffer), imageSize);
outFile.close();
auto message = dpp::message();
message.add_file("odds.png", dpp::utility::read_file("ev.png"));
event.reply(message)```
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (8 by maintainers)
youre welcome! You should come along to the discord server, you can get much faster answers there! https://discord.gg/dpp
Welp. I had an old instance of my script running that was superceding/conflicting with what I was testing. It all works now. Sorry for the confusion and thanks for the help.
this is definetly some problem with your image lib…
as i mentioned i use opencv to do same thing and it works perfectly fine