Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Burl%7D?q=discord&page=1&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=discord

Returns an array of strings in format "username" or "username/projectName"

Found 942 results for "discord"(896ms)

untitled-8809disc-receive-message.tsx6 matches

@simdlauper•Updated 4 hours ago
11
12 try {
13 const DISCORD_PUBLIC_KEY = process.env.discordPublicKey;
14
15 if (!DISCORD_PUBLIC_KEY) {
16 throw new Error("Discord webhook public key is not set");
17 }
18
30
31 // Convert public key and signature to Uint8Array
32 const publicKeyBytes = sodium.from_hex(DISCORD_PUBLIC_KEY);
33 const signatureBytes = sodium.from_hex(signature);
34
44 }
45
46 // Parse the incoming JSON payload from the Discord webhook
47 const payload = await JSON.parse(body);
48
53
54 // Log the entire payload to the console
55 console.log("Discord Webhook Received:", JSON.stringify(payload, null, 2));
56
57 // Respond with a 200 OK to acknowledge receipt

redditTestmain.tsx8 matches

@charmaine•Updated 4 hours ago
1import { searchWithSerpApi } from "https://esm.town/v/charmaine/searchWithSerpApi";
2import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
3
4// Customize your search parameters
5const KEYWORDS = "\"val town\" OR \"val.town\" OR \"val.run\"";
6const DISCORD_API_KEY = Deno.env.get("mentionsDiscord");
7const SERP_API_KEY = Deno.env.get("SERP_API_KEY");
8
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
17 return;
18 }
59 console.log("Relevant Reddit Posts:", content);
60
61 // Send Discord notification (only if isProd is true)
62 if (isProd) {
63 await discordWebhook({
64 url: DISCORD_API_KEY,
65 content,
66 });
67 console.log("Discord notification sent successfully.");
68 }
69 } catch (error) {

redditTestREADME.md9 matches

@charmaine•Updated 5 hours ago
5This template will help you:
61. Search Reddit for specific keywords within a defined time range.
72. Send notifications to your preferred platform (Discord, Slack, email, etc.)
8
9Reddit does not have an API that allows users to scrape data, so we are doing this with the Google Search API, [Serp](https://serpapi.com/).
12
13## Example
14This val tracks mentions of "Val Town" and related terms on Reddit, filtering results from the last 7 days and sending alerts to a Discord webhook.
15![Screenshot 2025-01-10 at 5.13.16 PM.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/beecb766-824e-4672-8393-3abd2edb1c00/public)
16
52
53### 5. Set Up Your Notification Method
54This template uses a Discord webhook for notifications. You can update this to your preferred platform:
55
56**Create a Discord webhook following [this guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks).**
57Save your webhook URL in your Val Town environment variables (you can find this on the left sidebar):
58- Key: `mentionsDiscord`
59- Value: Your Discord webhook URL.
60Notifications will be sent using this function:
61```
62 await discordWebhook({
63 url: Deno.env.get("mentionsDiscord"),
64 content,
65 });
66```
67
68To switch to another platform (e.g., Slack, email, or custom webhooks), replace the discordWebhook call with the appropriate integration ((e.g., [`@std/email`](https://docs.val.town/std/email/), [Slack](https://docs.val.town/integrations/slack/send-messages-to-slack/), or [anywhere else](https://docs.val.town/guides/creating-a-webhook/))
69
70---

x-cache-bugserver.ts2 matches

@hacksore•Updated 7 hours ago
9 let redirectUrl = DEFAULT_REDIRECT_TARGET; // Assume default redirect initially
10
11 // Check if User-Agent exists and contains 'twitter' or 'discord' (case-insensitive)
12 if (userAgent) {
13 const lowerCaseUserAgent = userAgent.toLowerCase();
14 if (
15 lowerCaseUserAgent.includes("twitter")
16 || lowerCaseUserAgent.includes("discord")
17 ) {
18 // If it matches, set the special redirect target

stevensDemoREADME.md1 match

@tijs•Updated 10 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

stevensDemoREADME.md1 match

@kuanche•Updated 16 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

a4595dc5b24_README.md1 match

@vtTestLocal•Updated 22 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

a55fa86a2ad_README.md1 match

@vtTestLocal•Updated 22 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

a221c7cb8ae_README.md1 match

@vtTestLocal•Updated 22 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

a14a9ff1f83_README.md1 match

@vtTestLocal•Updated 22 hours ago
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries

vt-discord

@boucher•Updated 3 days ago

discord-bot25 file matches

@boucher•Updated 3 days ago
andiebuk
Old time coder, just trying to keep up with this AI lark! On discord and YouTube as EmulatedAndie