chore: better responses on failure

This commit is contained in:
2025-07-19 17:09:41 -07:00
parent 256481f279
commit bd8c5457cc
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -41,12 +41,12 @@ export const announceOnDiscord = async(
},
);
if (messageRequest.status !== 200) {
return "Failed to send message to Discord.";
return `Failed to send message to Discord. Status: ${messageRequest.status.toString()} ${messageRequest.statusText}`;
}
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- fetch does not accept generics.
const message = await messageRequest.json() as { id?: string };
if (message.id === undefined) {
return "Failed to parse message ID, cannot crosspost.";
return `Failed to parse message ID, cannot crosspost. ${JSON.stringify(message)}`;
}
const crosspostRequest = await fetch(
`https://discord.com/api/v10/channels/${channelIds[type]}/messages/${message.id}/crosspost`,
@@ -59,7 +59,7 @@ export const announceOnDiscord = async(
},
);
if (!crosspostRequest.ok) {
return "Failed to crosspost message to Discord.";
return `Failed to crosspost message to Discord. Status: ${crosspostRequest.status.toString()} ${crosspostRequest.statusText}`;
}
return "Successfully sent and published message to Discord.";
};
+1 -1
View File
@@ -34,7 +34,7 @@ export const announceOnForum = async(
},
);
if (forumRequest.status !== 200) {
return "Failed to send message to forum.";
return `Failed to send message to forum. Status: ${forumRequest.status.toString()} ${forumRequest.statusText}`;
}
return "Successfully sent message to forum.";
};