Skip to content

Commit f0a3ba4

Browse files
committed
Better error handling for suggestions
1 parent d089deb commit f0a3ba4

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/server/forumWebhook.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default async function forumWebhook(req: express.Request<{}, {}, any>, re
3232
.setURL(url)
3333
.setDescription(`**${title}**\n\n${htmlToText(topic.firstPost.content).substring(0, 2000)}`)
3434
.setTimestamp(new Date(topic.firstPost.date))
35-
.setImage(SUGGESTION_ICON)
35+
.setThumbnail(SUGGESTION_ICON)
3636
.setFooter({text: `Tags: ${topic.tags.join(', ')}`});
3737

3838
const webhookMessage: RESTPostAPIWebhookWithTokenJSONBody = { embeds: [embed.data] };
@@ -56,14 +56,11 @@ export default async function forumWebhook(req: express.Request<{}, {}, any>, re
5656
const author = post.author.name;
5757
logger.info('New post via forum webhook', { threadId, url, author, content: htmlToText(post.content) });
5858
// We need to get the thread info to make sure it's in the suggestion forum.
59-
const topic = await getTopic(threadId).catch(() => {
60-
logger.warn('Could not get topic for post', { threadId, url, author });
59+
const topic = await getTopic(threadId).catch((err) => {
60+
logger.warn('Could not get topic for post', { threadId, url, err });
6161
return null;
6262
});
63-
if (!topic) {
64-
logger.warn('Could not get topic for post', { threadId, url, author });
65-
return;
66-
}
63+
if (!topic) return;
6764
// If this post is the first post in a thread we can ignore it.
6865
if (topic.firstPost.id === post.id) return;
6966
// Only process posts in the suggestion forum.
@@ -73,7 +70,7 @@ export default async function forumWebhook(req: express.Request<{}, {}, any>, re
7370
.setColor('Orange')
7471
.setAuthor({name: author, iconURL: post.author.photoUrl})
7572
.setURL(url)
76-
.setImage(SUGGESTION_ICON)
73+
.setThumbnail(SUGGESTION_ICON)
7774
.setDescription(`${htmlToText(post.content).substring(0, 2000)}`)
7875
.setTimestamp(new Date(post.date))
7976
.setFooter({text: `Tags: ${topic.tags.join(', ')}`, iconURL: SUGGESTION_ICON});

0 commit comments

Comments
 (0)