Skip to content

Commit

Permalink
fix: goldenframe handle not static image case
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Sep 10, 2023
1 parent b565992 commit 60a732b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions apps/bot/src/commands/main.slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export class Main extends CogSlashClass {

let url: string | null;
if (who) {
url = who.avatarURL({ size: 4096 });
url = who.avatarURL({ size: 4096, forceStatic: true });
if (!url) {
await ctx.followUp(
"Cannot G O L D E N F R A M E: Target user has no profile picture!",
"Golden Frame Failed: Target user has no profile picture!",
);
return;
}
Expand All @@ -93,8 +93,15 @@ export class Main extends CogSlashClass {
}

const res = await fetch(url);
if (!res.body) {
await ctx.followUp("Fetch Error: Cannot get Image");

const contentType = res.headers.get("Content-Type");
// Allow only static images
const allowedContentTypes = ["image/jpeg", "image/png", "image/webp"];

if (!allowedContentTypes.includes(contentType!)) {
await ctx.followUp(
`Fetch Error: Content-Type of ${contentType} is invalid!`,
);
return;
}

Expand Down

0 comments on commit 60a732b

Please sign in to comment.