From 087895920eb1610ab72c056138ef406e3f971044 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 7 Sep 2025 03:26:30 -0700 Subject: fix: Add rate-limit mitigation --- src/server.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/server.ts') diff --git a/src/server.ts b/src/server.ts index 3f54f63..bb0c458 100644 --- a/src/server.ts +++ b/src/server.ts @@ -9,15 +9,15 @@ import { ROLEPLAY_COMMAND, NSFW_COMMAND, TOP_COMMAND, -} from './commands.js'; +} from './commands.ts'; import { getCutePost, getRoleplayPost, getNSFWPost, getTopPost, type RedditPost, -} from './reddit.js'; -import type { TimePeriod } from './commands.js'; +} from './reddit.ts'; +import type { TimePeriod } from './commands.ts'; interface Environment { DISCORD_APPLICATION_ID: string; @@ -167,7 +167,9 @@ router.post('/', async (request: Request, environment: Environment) => { embeds: [embed], }, }); - } catch { + } catch (error) { + console.error('Error in hot command:', error); + return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { @@ -189,7 +191,9 @@ router.post('/', async (request: Request, environment: Environment) => { embeds: [embed], }, }); - } catch { + } catch (error) { + console.error('Error in roleplay command:', error); + return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { @@ -221,7 +225,9 @@ router.post('/', async (request: Request, environment: Environment) => { embeds: [embed], }, }); - } catch { + } catch (error) { + console.error('Error in NSFW command:', error); + return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { @@ -245,7 +251,9 @@ router.post('/', async (request: Request, environment: Environment) => { embeds: [embed], }, }); - } catch { + } catch (error) { + console.error('Error in top command:', error); + return new JSONResponse({ type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE, data: { -- cgit v1.2.3