fix project not found

This commit is contained in:
Ryan Cao 2022-09-16 21:58:41 +08:00
parent 0e4329492e
commit 2a35abdce0
No known key found for this signature in database

View file

@ -42,9 +42,23 @@ export const modrinthCommand = async (
return;
}
const data = (await fetch('https://api.modrinth.com/v2/project/' + id).then(
(a) => a.json()
)) as ModrinthProject | { error: string; description: string };
const res = await fetch('https://api.modrinth.com/v2/project/' + id);
const data = (await res.json()) as
| ModrinthProject
| { error: string; description: string };
if (!res.ok) {
await i.editReply({
embeds: [
new EmbedBuilder()
.setTitle('Error!')
.setDescription('Not found!')
.setColor(COLORS.red),
],
});
return;
}
if ('error' in data) {
console.error(data);