在 Discord Rich Embed 上显示字节数组图像
Display byte array image onto Discord Rich Embed
我的 Discord 机器人可以从我的数据库中获取 png 图像并将其存储为字节数组。我如何使用 c# Discord.Net 库将此图像嵌入到 Discord 的 Rich Embed 中?
我注意到 SendFileAsync
有两个构造函数,分别用于字符串文件名和 Stream。 google 关于流和字节数组的搜索让我找到了 here. Then I looked more into Discord.Net's EmbedBuilder Class and found information about embedding a local image file in the rich embed
使用这些资源我写了这个并且图像显示正确
using (System.IO.MemoryStream imgStream = new System.IO.MemoryStream(byteArrayImage))
{
build.WithThumbnailUrl("attachment://anyImageName.png"); //or build.WithImageUrl("")
await Context.Channel.SendFileAsync(imgStream, "anyImageName.png", "", false, build.Build());
}
我的 Discord 机器人可以从我的数据库中获取 png 图像并将其存储为字节数组。我如何使用 c# Discord.Net 库将此图像嵌入到 Discord 的 Rich Embed 中?
我注意到 SendFileAsync
有两个构造函数,分别用于字符串文件名和 Stream。 google 关于流和字节数组的搜索让我找到了 here. Then I looked more into Discord.Net's EmbedBuilder Class and found information about embedding a local image file in the rich embed
使用这些资源我写了这个并且图像显示正确
using (System.IO.MemoryStream imgStream = new System.IO.MemoryStream(byteArrayImage))
{
build.WithThumbnailUrl("attachment://anyImageName.png"); //or build.WithImageUrl("")
await Context.Channel.SendFileAsync(imgStream, "anyImageName.png", "", false, build.Build());
}