Public
Likediscord-showcase
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
Public API serving messages from the #showcase channel in the Val Town Discord.
Rendering mermaid diagram...
How it works:
poll.tsruns every minute via Val Town's interval scheduler- It fetches new messages from the Discord
#showcasechannel using the Discord API - Messages are upserted into a SQLite database (so re-fetches don't create duplicates)
api.tsis an HTTP endpoint that queries SQLite and returns JSON
Returns API info and total message count.
Returns showcase messages, newest first.
| Param | Type | Default | Description |
|---|---|---|---|
limit | number | 50 | Messages per page (1β100) |
offset | number | 0 | Pagination offset |
search | string | β | Search message content |
author | string | β | Filter by author username |
Example response:
{ "messages": [ { "id": "123456789", "author_id": "987654321", "author_username": "cool_dev", "author_avatar": "abc123", "content": "Check out my new val! ...", "timestamp": "2025-01-15T12:00:00.000Z", "attachments": [], "embeds": [...], "reactions": [{ "count": 5, "emoji": { "id": null, "name": "π₯" } }], "reply_to_id": null, "thread_id": null, "thread_name": null } ], "pagination": { "limit": 50, "offset": 0, "total": 1234, "has_more": true } }
- Create a Discord bot with Read Message History permission in the Val Town server
- Set the
DISCORD_BOT_TOKENenvironment variable to your bot token - The poller will start collecting messages automatically
| File | Type | Description |
|---|---|---|
api.ts | HTTP | Public JSON API |
poll.ts | Interval | Fetches new messages every minute |
discord.ts | Script | Discord API client |
db.ts | Script | SQLite schema & connection |