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=function&page=47&format=json

For typeahead suggestions, use the /typeahead endpoint:

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

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

Found 19282 results for "function"(1094ms)

1// toggle-server-helper-pings-service.ts - Service for handling server helper ping toggle functionality
2import { fetch } from "https://esm.town/v/std/fetch";
3
10
11// Toggle server helper pings role for a user
12export async function toggleServerHelperPings(
13 guildId: string,
14 userId: string,
101
102// Create response messages based on toggle result
103export function createToggleServerHelperPingsResponseMessage(
104 result: { success: boolean; action: string; roleName?: string; error?: string },
105): string {

Discord_Bot_Servicestoggle-role-service.tsx7 matches

@ktodazโ€ขUpdated 4 days ago
1// toggle-role-service.ts - Service for handling role toggle functionality
2import { withErrorHandling } from "https://esm.town/v/ktodaz/Discord_Bot_Services/error-handling.tsx";
3import { fetch } from "https://esm.town/v/std/fetch";
12
13// Check if user has permission to toggle roles
14async function hasPermission(guildId: string, userId: string): Promise<{
15 hasPermission: boolean;
16 isAdmin: boolean;
93
94// Toggle role for a user (for the command processor)
95export async function toggleRole(
96 guildId: string,
97 userId: string,
178
179// Create response messages based on toggle result
180export function createToggleRoleResponseMessage(
181 result: { success: boolean; action: string; roleName?: string; error?: string },
182): string {
192}
193
194// Then modify your getToggleableRoles function to use the error handling wrapper
195export async function getToggleableRoles(guildId: string): Promise<{
196 success: boolean;
197 roles?: Array<{ id: string; name: string }>;
249
250// Handle role autocomplete interaction
251export async function handleRoleAutocomplete(interaction: any): Promise<Response> {
252 try {
253 const guildId = interaction.guild_id;

slacktest.ts9 matches

@dinavinterโ€ขUpdated 4 days ago
213
214// -------------------------------
215// Custom Functions
216// https://api.slack.com/automation/functions/custom
217// -------------------------------
218
219app.function("fetch_user_details", async ({ payload, context: { client, functionExecutionId } }) => {
220 try {
221 // Requires users:read scope
224 });
225 const user = userInfo.user!;
226 await client.functions.completeSuccess({
227 function_execution_id: functionExecutionId!,
228 outputs: {
229 full_name: user.real_name || user.profile?.real_name_normalized || user.profile?.real_name,
239 } catch (e) {
240 console.error(e);
241 await client.functions.completeError({
242 function_execution_id: functionExecutionId!,
243 error: `Failed to respond to fetch_user_details function event (${e})`,
244 });
245 }
261(async () => await sm.start())();
262
263export default async function handler(req: Request) {
264 return Response.json(
265 await app.client.conversations.replies({

mandateagents.ts3 matches

@salonโ€ขUpdated 4 days ago
6
7// Summarizer Agent (unchanged, but shown for completeness)
8export async function summarizerAgent(
9 input: AgentInput<{ textToSummarize: string }>,
10 context: AgentContext,
52
53// Fetch Agent (Now fetches and parses RSS feeds for headlines)
54export async function fetchAgent(
55 input: AgentInput<{ url_from_input?: string; maxHeadlines?: number }>, // Added maxHeadlines
56 context: AgentContext,
206
207// Combiner Agent (Adapted to handle new headline structure from FetchAgent)
208export async function combinerAgent(
209 input: AgentInput<{
210 summary?: string;

govaltownmain.tsx2 matches

@bradnobleโ€ขUpdated 4 days ago
22 let colorIndex = 0;
23
24 // Function to change the heading color
25 function changeHeadingColor() {
26 const heading = document.getElementById('colorful-heading');
27 heading.style.color = colors[colorIndex];

cp24-digestmain.tsx1 match

@gwoods22โ€ขUpdated 4 days ago
9// https://gwoods22-blob_admin_app.web.val.run/view/cp24Emails
10
11export async function forwarder(e: Email) {
12 let attachments: AttachmentData[] = [];
13 for (const f of e.attachments) {

untitled-3323new-file-8432.tsx5 matches

@AP123โ€ขUpdated 4 days ago
5// MAIN HANDLER โ€“ unchanged except 1-line regex
6// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
7export default async function server(req: Request): Promise<Response> {
8 const { searchParams } = new URL(req.url);
9 let feedUrl = searchParams.get("url") ?? "";
62// FULL-DATA fetch for a single Reddit submission
63// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
64async function fetchRedditPost(postUrl: string, limit: number) {
65 const pathname = new URL(postUrl).pathname.replace(/\/$/, "");
66 const headers = {
136// โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
137const txt = (v: any) => (typeof v === "string" ? v : v?._ ?? v?.__cdata ?? "");
138function extractLink(n: any): string {
139 if (!n || !n.link) return "";
140 if (typeof n.link === "string") return n.link.trim();
147 return "";
148}
149function stripHtml(html: string): string {
150 if (!html) return "";
151 let t = html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
160 return t.replace(/&[A-Za-z0-9#]+;/g, m => e[m] ?? m);
161}
162function json(d: unknown, s = 200) {
163 return new Response(JSON.stringify(d, null, 2), {
164 status: s,

pollinaterpbldemo.tsx5 matches

@armadillomikeโ€ขUpdated 4 days ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function BeehiveMonitor() {
6 const [temperature, setTemperature] = useState(null);
7 const [humidity, setHumidity] = useState(null);
9
10 useEffect(() => {
11 async function fetchSensorData() {
12 try {
13 // Simulated sensor data with realistic bee habitat conditions
70}
71
72function App() {
73 return <BeehiveMonitor />;
74}
75
76function client() {
77 createRoot(document.getElementById("root")).render(<App />);
78}
79if (typeof document !== "undefined") { client(); }
80
81export default async function server(request: Request): Promise<Response> {
82 return new Response(
83 `

rdo-dailies-webhookmain.ts4 matches

@mmoriharaโ€ขUpdated 4 days ago
82}
83
84async function fetchDailies() {
85 const response = await fetch("https://api.rdo.gg/challenges/index.json");
86 return response.json();
87}
88
89function formatDailies(data: DailyResponse) {
90 const { general, easy, med, hard } = data;
91
140}
141
142export async function main() {
143 const dailies = await fetchDailies();
144 const formatted = formatDailies(dailies);
167}
168
169export default async function(interval: Interval) {
170 const { content, embeds } = await main();
171

whatsapp-callbackindex.tsx5 matches

@yawnxyzโ€ขUpdated 4 days ago
44const CLARIFICATION_EXPIRY_MS = 15 * 60 * 1000; // 15 minutes
45
46// --- Helper Functions ---
47async function sendWhatsAppMessage(phoneNumber, businessId, text, originalMessageId) {
48 if (!WHATSAPP_GRAPH_API_TOKEN || !businessId) {
49 console.error("WhatsApp API token or business ID is missing. Cannot send message.");
81
82// Updated to be smarter and potentially ask for clarification or respond directly
83async function sendSmartAcknowledgement(
84 phoneNumber: string,
85 businessId: string,
255}
256
257async function initiateChatWithMCPOrchestrator(userQuery, userIdentifier, originalMessageId, businessPhoneNumberId, initialAssistantMessage: string | null) {
258 if (!conversations[userIdentifier]) {
259 conversations[userIdentifier] = [];
588 </style>
589 <script>
590 async function sendWelcome() {
591 const phoneNumberInput = document.getElementById('phoneNumber');
592 const messageBodyInput = document.getElementById('messageBody');

getFileEmail4 file matches

@shouserโ€ขUpdated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkโ€ขUpdated 3 weeks ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.