Skip to content

Commit

Permalink
Fix booru video being too heavy to be sent
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwilarg committed Nov 13, 2024
1 parent 79883fc commit e2a0003
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Sanara/Module/Command/Impl/Doujin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,17 @@ public async Task BooruAsync(IContext ctx)
}
else
{
using MemoryStream ms = new(await ctx.Provider.GetRequiredService<HttpClient>().GetByteArrayAsync(post.FileUrl.AbsoluteUri));
await ctx.ReplyAsync(ms, $"image{ext}", embed: embed.Build(), components: comp);
var arr = await ctx.Provider.GetRequiredService<HttpClient>().GetByteArrayAsync(post.FileUrl.AbsoluteUri);
using MemoryStream ms = new(arr);
if (arr.Length > 8000000)
{
embed.Description = "This post was too heavy to be previewed";
await ctx.ReplyAsync(embed: embed.Build(), components: comp);
}
else
{
await ctx.ReplyAsync(ms, $"image{ext}", embed: embed.Build(), components: comp);
}
}

await ctx.Provider.GetRequiredService<Db>().AddBooruAsync(type.ToString());
Expand Down

0 comments on commit e2a0003

Please sign in to comment.