generated from nhcarrigan/template
chore: better responses on failure
This commit is contained in:
@@ -41,12 +41,12 @@ export const announceOnDiscord = async(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (messageRequest.status !== 200) {
|
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.
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- fetch does not accept generics.
|
||||||
const message = await messageRequest.json() as { id?: string };
|
const message = await messageRequest.json() as { id?: string };
|
||||||
if (message.id === undefined) {
|
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(
|
const crosspostRequest = await fetch(
|
||||||
`https://discord.com/api/v10/channels/${channelIds[type]}/messages/${message.id}/crosspost`,
|
`https://discord.com/api/v10/channels/${channelIds[type]}/messages/${message.id}/crosspost`,
|
||||||
@@ -59,7 +59,7 @@ export const announceOnDiscord = async(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (!crosspostRequest.ok) {
|
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.";
|
return "Successfully sent and published message to Discord.";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const announceOnForum = async(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (forumRequest.status !== 200) {
|
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.";
|
return "Successfully sent message to forum.";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user