Skip to content

Commit

Permalink
extra error handling for resize function
Browse files Browse the repository at this point in the history
  • Loading branch information
TiltedToast committed Mar 30, 2024
1 parent bc366f1 commit c3c8146
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/strftime": "^0.9.8",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"bun-types": "^1.0.31",
"bun-types": "^1.0.36",
"concurrently": "^8.2.2",
"drizzle-kit": "^0.20.13",
"eslint": "^8.56.0",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function convertEmojis(emojis: RegExpMatchArray, message: Message) {
${magickPrefix} ${frameTwoPath} -quality 90 ${frameTwoPath}
`.catch(console.error);

if (!compressOutput) {
if (!compressOutput || compressOutput.exitCode !== 0) {
await message.channel.send(`Could not compress \`${name}\`, skipping...`);
continue;
}
Expand All @@ -129,7 +129,7 @@ async function convertEmojis(emojis: RegExpMatchArray, message: Message) {
${magickPrefix} ${frameOnePath} ${frameTwoPath} -delay 100 ${gifPath}
`.catch(console.error);

if (!convertOutput) {
if (!convertOutput || convertOutput.exitCode !== 0) {
await message.channel.send(`Could not convert \`${name}\`, skipping...`);
continue;
}
Expand All @@ -142,7 +142,7 @@ async function convertEmojis(emojis: RegExpMatchArray, message: Message) {
animated: true,
});

if (!output) {
if (!output || ("exitCode" in output && output.exitCode !== 0)) {
await message.channel.send(
`Something went wrong while resizing \`${name}\`, skipping...`
);
Expand Down Expand Up @@ -340,7 +340,7 @@ export async function addEmoji(message: Message, prefix: string) {
animated: imgType === "gif",
});

if (!output) {
if (!output || ("exitCode" in output && output.exitCode !== 0)) {
return message.channel.send(
"Something went wrong while resizing the image, please try again!"
);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/imgProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function beautiful(input: Message | ChatInputCommandInteraction) {
animated: false,
});

if (!output) {
if (!output || ("exitCode" in output && output.exitCode !== 0)) {
return await sendOrReply(
input,
"I'm sorry, failed to resize the pfp. Maybe try again later?"
Expand Down Expand Up @@ -146,7 +146,7 @@ export async function resizeImg(message: Message, prefix: string) {
animated: imgType === "gif",
});

if (!output) {
if (!output || ("exitCode" in output && output.exitCode !== 0)) {
return await message.channel.send(
"I'm sorry, failed to resize the image. Maybe try again later?"
);
Expand Down

0 comments on commit c3c8146

Please sign in to comment.