feat: enhance rule34 message handling with improved error handling and command processing
This commit is contained in:
@@ -10,9 +10,30 @@ function isKey(key: string): key is PostKeys {
|
||||
}
|
||||
|
||||
export async function drop() {
|
||||
const response = await requestJSON<ImageResponse[]>(`${postUrl}&limit=1`);
|
||||
if (response[0] === undefined) throw Error("Bro, get some sleep");
|
||||
return response[0].file_url;
|
||||
try {
|
||||
const response = await requestJSON<ImageResponse[]>(`${postUrl}&limit=1`);
|
||||
const img = response[0];
|
||||
if (img === undefined) throw Error("An undefined Array was given!");
|
||||
return new Embed(
|
||||
`ID: ${img.id}`,
|
||||
img.sample_url,
|
||||
new EmbedAuthor(img.owner),
|
||||
// [new EmbedField("Tags", img.tags, true)],
|
||||
new EmbedImage(img.file_url, img.height, img.width),
|
||||
);
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
return new Embed(
|
||||
"Error Message",
|
||||
"https://gifdb.com/images/thumbnail/nuh-uh-demon-slayer-girl-hm7q3hqa4lnqyl6d.gif",
|
||||
new EmbedAuthor("fzzinChemical"),
|
||||
new EmbedImage(
|
||||
"https://gifdb.com/images/thumbnail/nuh-uh-demon-slayer-girl-hm7q3hqa4lnqyl6d.gif",
|
||||
250,
|
||||
250,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function requestWorker(requestString: string) {
|
||||
@@ -34,8 +55,8 @@ export async function requestWorker(requestString: string) {
|
||||
}
|
||||
return stack;
|
||||
} catch (e) {
|
||||
console.error((e as Error).message);
|
||||
return []
|
||||
console.error((e as Error).message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user