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=react&page=62&format=json

For typeahead suggestions, use the /typeahead endpoint:

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

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

Found 9880 results for "react"(1583ms)

Discord_Bot_Servicesmap-vote-tallying.tsx25 matches

@ktodaz•Updated 1 week ago
1// Map Vote Tallying Function with Rate Limit Service Integration
2// This function counts emoji reactions and announces winners in a Hell Let Loose map vote
3import seedrandom from "https://esm.sh/seedrandom";
4import { DiscordRateLimitService } from "https://esm.town/v/ktodaz/Discord_Bot_Services/discord-rate-limit-service.tsx";
103}
104
105// Get emoji mapping to decode emoji reactions
106function getEmojiMapping() {
107 return {
219}
220
221// Get reactions for a specific message with rate limiting
222async function getMessageReactions(channelId: string, messageId: string, emoji: string) {
223 try {
224 const encodedEmoji = encodeURIComponent(emoji);
225 const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
226
227 return rateLimitService.executeWithRateLimit(routeKey, async () => {
228 const endpoint = `/channels/${channelId}/messages/${messageId}/reactions/${encodedEmoji}?limit=100`;
229 const reactions = await discordRequest(endpoint);
230 return reactions;
231 });
232 } catch (error) {
233 console.error(`Error getting reactions for message ${messageId}:`, error);
234 return []; // Return empty array on error to continue processing
235 }
578 }
579
580 // Get all reactions on this message
581 const reactions = msg.reactions || [];
582
583 // Process each reaction type
584 for (const reaction of Object.values(reactions)) {
585 const emoji = reaction.emoji.name;
586
587 // Skip if this emoji is not in our mapping
592
593 const variant = emojiMapping[emoji];
594 console.log(`Processing: Embed: ${mapName} (${variant}), Reactions: ${reaction.count}`);
595
596 // Get users who reacted with this emoji - using rate limited function
597 const reactedUsers = await getMessageReactions(channelId, msg.id, emoji);
598 console.log(`Emote key ${variant}: ${reactedUsers.length} users`);
599
600 // Process each user's reaction
601 for (const user of reactedUsers) {
602 // Skip bot reactions
603 if (user.bot) continue;
604
623 const random = seedrandom(Date.now().toString());
624 const userVotes: UserVote[] = [];
625 const embedVariantReactionCounts: Record<string, number> = {};
626
627 // Process users in smaller batches to manage rate limits better
673 for (const vote of votes) {
674 const key = `${vote.embed.title} ${vote.variant}`;
675 embedVariantReactionCounts[key] = (embedVariantReactionCounts[key] || 0) + 1;
676 }
677 }
682
683 // Convert to array of MapVote objects
684 for (const [key, count] of Object.entries(embedVariantReactionCounts)) {
685 const [mapName, variant] = key.split(/\s(?=[^\s]+$)/); // Split at the last space
686 mapVotes.push({
695 // Handle ties with random shuffle (match C# implementation)
696 const randomVariants = seedrandom(Date.now().toString());
697 const sortedVotes = Object.entries(embedVariantReactionCounts)
698 .map(([key, count]) => {
699 const [mapName, variant] = key.split(/\s(?=[^\s]+$)/);

radiohead_circle_jerkmain.tsx2 matches

@metart43•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react */
2import { renderToString } from "npm:react-dom/server";
3
4const notesStyle = {
101}
102
103// Add emoji reaction to message - RATE LIMITED VERSION
104async function addReaction(channelId: string, messageId: string, emoji: string) {
105 const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
106
107 return rateLimitService.executeWithRateLimit(routeKey, async () => {
108 const url = `${API_BASE}/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`;
109 const token = Deno.env.get("DISCORD_BOT_TOKEN");
110
123 if (!response.ok) {
124 let errorText = await response.text();
125 console.error(`Error adding reaction: Status ${response.status}, Body: ${errorText}`);
126 throw new Error(`Failed to add reaction: ${response.status}`);
127 }
128
129 // Successful reaction add
130 return true;
131 });
195 type: 0, // Role type
196 allow: "1024", // VIEW_CHANNEL, READ_MESSAGE_HISTORY
197 deny: "64", // ADD_REACTIONS
198 },
199 {
201 type: 0, // Role type
202 allow: "1024", // VIEW_CHANNEL, READ_MESSAGE_HISTORY
203 deny: "64", // ADD_REACTIONS
204 },
205 {
271}
272
273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275 const mapMetaVariants: string[] = [];
279 if (variantOptions.EnableDawn && map.MapDetails.Dawn) {
280 if (map.MapDetails.Dawn === "meta") {
281 console.log(`${map.MapName} Dawn variant is meta, not adding reaction`);
282 mapMetaVariants.push(`${map.MapName} Dawn`);
283 mapEnabledVariants.push("Dawn");
284 } else if (map.MapDetails.Dawn === "enabled") {
285 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.DAWN));
286 mapEnabledVariants.push("Dawn");
287 }
291 if (variantOptions.EnableDay && map.MapDetails.Day) {
292 if (map.MapDetails.Day === "meta") {
293 console.log(`${map.MapName} Day variant is meta, not adding reaction`);
294 mapMetaVariants.push(`${map.MapName} Day`);
295 mapEnabledVariants.push("Day");
296 } else if (map.MapDetails.Day === "enabled") {
297 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.DAY));
298 mapEnabledVariants.push("Day");
299 }
303 if (variantOptions.EnableDusk && map.MapDetails.Dusk) {
304 if (map.MapDetails.Dusk === "meta") {
305 console.log(`${map.MapName} Dusk variant is meta, not adding reaction`);
306 mapMetaVariants.push(`${map.MapName} Dusk`);
307 mapEnabledVariants.push("Dusk");
308 } else if (map.MapDetails.Dusk === "enabled") {
309 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.DUSK));
310 mapEnabledVariants.push("Dusk");
311 }
315 if (variantOptions.EnableNight && map.MapDetails.Night) {
316 if (map.MapDetails.Night === "meta") {
317 console.log(`${map.MapName} Night variant is meta, not adding reaction`);
318 mapMetaVariants.push(`${map.MapName} Night`);
319 mapEnabledVariants.push("Night");
320 } else if (map.MapDetails.Night === "enabled") {
321 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.NIGHT));
322 mapEnabledVariants.push("Night");
323 }
327 if (variantOptions.EnableFog && map.MapDetails.Fog) {
328 if (map.MapDetails.Fog === "meta") {
329 console.log(`${map.MapName} Fog variant is meta, not adding reaction`);
330 mapMetaVariants.push(`${map.MapName} Fog`);
331 mapEnabledVariants.push("Fog");
332 } else if (map.MapDetails.Fog === "enabled") {
333 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.FOG));
334 mapEnabledVariants.push("Fog");
335 }
339 if (variantOptions.EnableOvercast && map.MapDetails.Overcast) {
340 if (map.MapDetails.Overcast === "meta") {
341 console.log(`${map.MapName} Overcast variant is meta, not adding reaction`);
342 mapMetaVariants.push(`${map.MapName} Overcast`);
343 mapEnabledVariants.push("Overcast");
344 } else if (map.MapDetails.Overcast === "enabled") {
345 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.OVERCAST));
346 mapEnabledVariants.push("Overcast");
347 }
351 if (variantOptions.EnableRain && map.MapDetails.Rain) {
352 if (map.MapDetails.Rain === "meta") {
353 console.log(`${map.MapName} Rain variant is meta, not adding reaction`);
354 mapMetaVariants.push(`${map.MapName} Rain`);
355 mapEnabledVariants.push("Rain");
356 } else if (map.MapDetails.Rain === "enabled") {
357 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.RAIN));
358 mapEnabledVariants.push("Rain");
359 }
363 if (variantOptions.EnableSandstorm && map.MapDetails.Sandstorm) {
364 if (map.MapDetails.Sandstorm === "meta") {
365 console.log(`${map.MapName} Sandstorm variant is meta, not adding reaction`);
366 mapMetaVariants.push(`${map.MapName} Sandstorm`);
367 mapEnabledVariants.push("Sandstorm");
368 } else if (map.MapDetails.Sandstorm === "enabled") {
369 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.SAND));
370 mapEnabledVariants.push("Sandstorm");
371 }
375 if (variantOptions.EnableSnowstorm && map.MapDetails.Snowstorm) {
376 if (map.MapDetails.Snowstorm === "meta") {
377 console.log(`${map.MapName} Snowstorm variant is meta, not adding reaction`);
378 mapMetaVariants.push(`${map.MapName} Snowstorm`);
379 mapEnabledVariants.push("Snowstorm");
380 } else if (map.MapDetails.Snowstorm === "enabled") {
381 await addReaction(channelId, messageId, encodeURIComponent(EMOJIS.SNOW));
382 mapEnabledVariants.push("Snowstorm");
383 }
387}
388
389// Populate channel with map options and add reactions
390async function populateChannelWithMaps(
391 channel: any,
662 const initialMessage = await sendInitialEmbed(channel, initialEmbedData);
663
664 // Populate channel with map options and reactions
665 const { metaVariants, enabledVariants } = await populateChannelWithMaps(
666 channel,
luciaMagicLinkStarter

luciaMagicLinkStarterApp.tsx3 matches

@stevekrouse•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
6 return (
7 <div>
8 <h1>Val Town React + Hono Starter</h1>
9 I've been clicked <button onClick={() => setClicked((c) => c + 1)}>{clicked}</button> times
10 </div>

helloWorldmain.tsx2 matches

@charmaine•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react */
2import { blob } from "https://esm.town/v/std/blob?v=11";
3import { renderToString } from "npm:react-dom/server";
4
5export default async (request: Request) => {
34 InstallSlashInteractionsTextCommandTrigger: "installslashinteractions",
35 CreateMapRotationVoteTextChannelTextCommandTrigger: "mapvote",
36 TallyReactionVotesTextCommandTrigger: "tally",
37 },
38 DiscordTargets: {
53 fieldHowToTitle: "How to Vote",
54 fieldHowToText:
55 "Use the Emoji Reaction(s) under each option corresponding to your choice of time or weather variant.",
56 fieldEmojiKeyTitle: "Emoji Reaction Key",
57 fieldEmojiKeyText: "",
58 fieldCurrentMetaMapsTitle: "Current Meta Maps:",
69 title: "Garrisons & Whiskey Map Rotation Vote",
70 description:
71 "Rules, \"How to Vote\", and Emoji Reaction Key can be found at the top. The Map Rotation Guide can be found in the discussion thread below.",
72 fieldJumpTitle: "You have reached the bottom.",
73 fieldJumpValue: "",
81 threadHeader: {
82 title: "Welcome to the Discussion Thread!",
83 description: "Rules, \"How to Vote\", and Emoji Reaction Key can be found at the top of the main channel.",
84 fieldMapRotationGuideTitle: "Map Rotation Guide",
85 fieldMapRotationGuideText:
141 // Common tech skills to look for
142 const skillKeywords = [
143 "typescript", "javascript", "python", "react", "node.js", "nodejs", "vue",
144 "angular", "next.js", "nextjs", "go", "golang", "rust", "aws", "azure",
145 "gcp", "docker", "kubernetes", "k8s", "terraform", "ci/cd", "ml", "ai",

my-first-val04_design_partners.tsx4 matches

@stevekrouse•Updated 1 week ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import ReactDOMServer from "https://esm.sh/react-dom@18.2.0/server";
3import React from "https://esm.sh/react@18.2.0";
4
5function DesignPartnersSlide() {
105// HTTP handler function for Val Town
106export default async function(req: Request): Promise<Response> {
107 const html = ReactDOMServer.renderToString(<DesignPartnersSlide />);
108
109 return new Response(

markdownBlogStarterLayout.tsx3 matches

@imnaseer•Updated 1 week ago
1/** @jsxImportSource npm:react@18.2.0 */
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">
react-router-hono-starter

react-router-hono-starter4 file matches

@jxnblk•Updated 2 hours ago
Minimal React Router + Hono starter example
react-router-data-mode-starter

react-router-data-mode-starter4 file matches

@jxnblk•Updated 2 hours ago
Minimal React Router starter using data mode
effector
Write business logic with ease Meet the new standard for modern TypeScript development. Type-safe, reactive, framework-agnostic library to manage your business logic.
officialrajdeepsingh
Follow me if you learn more about JavaScript | TypeScript | React.js | Next.js | Linux | NixOS | Frontend Developer | https://linktr.ee/officialrajdeepsingh