charmaineValSearchcomponents.tsx2 matches
1226<a href="?q=image" className="example-link">image</a>
1227<a href="?q=function" className="example-link">function</a>
1228<a href="?q=discord" className="example-link">discord</a>
1229<a href="?q=openai" className="example-link">openai</a>
1230<a href="?q=react" className="example-link">react</a>
1380<a href="?q=image" className="example-link">image</a>
1381<a href="?q=function" className="example-link">function</a>
1382<a href="?q=discord" className="example-link">discord</a>
1383<a href="?q=openai" className="example-link">openai</a>
1384<a href="?q=react" className="example-link">react</a>
templateTwitterAlertmain.tsx4 matches
1import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
2import { socialDataSearch, Tweet } from "https://esm.town/v/stevekrouse/socialDataSearch";
32627// Format notification content as a list of Tweet URLs
28// Using fxtwitter, which fixes Twitter Embed Unfurls for Discord
29const content = response.tweets?.map(({ user: { screen_name }, id_str }) =>
30`https://fxtwitter.com/${screen_name}/status/${id_str}`
40// Send notifications (only if isProd is set to true)
41if (isProd && content?.length) {
42await discordWebhook({
43url: Deno.env.get("mentionsDiscord"), // Replace with your Discord webhook URL or other notification method
44content,
45});
templateTwitterAlertREADME.md10 matches
5This template will help you:
61. Search for specific mentions on Twitter/X using customizable keywords.
72. Deliver notifications wherever you'd like (email, Discord, Slack, Telegram, etc).
89## Example
10This val tracks mentions of "Val Town" and related terms, excluding noise like retweets and irrelevant accounts. Notifications are sent to a Discord webhook but can be easily reconfigured for other platforms.
11<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/85912106-f625-443e-5321-6e2699453200/public" width="500"/>
12To see exactly how we use this template at Val Town: https://www.val.town/x/stevekrouse/twitterAlert
37### 5. Choose Notification Method
3839This template uses a Discord webhook for notifications, but
40you can update this to your preferred platform by replacing the `discordWebhook` call
41with a call to [Slack](https://docs.val.town/integrations/slack/send-messages-to-slack/), [`@std/email`](https://docs.val.town/std/email/), etc.
4243**Create a Discord webhook following [this guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks).**
4445Save your Discord Webhook URL in your Environment Variables (you can find this on the left sidebar):
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
4950```ts
51await discordWebhook({
52url: Deno.env.get("mentionsDiscord"),
53content,
54});
my-first-valREADME.md1 match
10Feel free to edit these examples or add new files to your project.
1112For inspiration, check out our [Docs](https://docs.val.town/), [Templates](https://www.val.town/explore/use-cases), [Showcase](https://www.val.town/explore/community-showcase) and [Discord](https://discord.val.town/)!
1314Stay as long as you'd like in this project, or head to your main [dashboard](/dashboard) to keep exploring the rest of Val Town.
templateHackerNewsAlertREADME.md9 matches
5This template will help you:
61. Search Hacker News for specific keywords.
72. Send notifications to your preferred platform (Discord, Slack, email, etc.), the default in this template is Discord.
89---
1011## Example
12This val tracks mentions of "Val Town" on Hacker News and sends updates to a Discord webhook.
13
143435### 5. Set Up Your Notification Method
36This template uses a Discord webhook for notifications. You can update this to your preferred platform:
3738**Create a Discord webhook following [this guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks).**
39Save your webhook URL in your Val Town environment variables (you can find this on the left sidebar):
40- Key: `mentionsDiscord`
41- Value: Your Discord webhook URL.
42Notifications will be sent using this function:
43```
44await discordWebhook({
45url: Deno.env.get("mentionsDiscord"),
46content,
47});
48```
4950To 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/))
5152---
templateHackerNewsAlertmain.tsx3 matches
1import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
2import { hnEmail } from "https://esm.town/v/stevekrouse/hnEmail";
3import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts";
17let { text } = await hnEmail({ posts, footer: false });
18if (posts.length) {
19await discordWebhook({
20url: process.env.mentionsDiscord,
21content: text,
22});
stevensDemoREADME.md1 match
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.
1314SQLite 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.
1516## Queries
Discord-to-LinearREADME.md11 matches
1# Discord Reaction to Linear Ticket Automation
23**How it works:** React to any Discord message with a configured emoji (like `:huss:` or `๐งฟ` - used as an example in this val) and it automatically becomes a Linear ticket with context from the Discord thread.
45_Team members can use custom emojis to identify themselves as the ticket creator._
67
89## Environment Variables
11Before you can run this cron, you must add the following Environment Variables (via left sidebar of this val):
1213- `DISCORD_BOT_TOKEN`: Your Discord bot token
14- Go to [Discord Developer Portal](https://discord.com/developers/applications) โ Create application โ Complete the steps โ Go to `Bot` on the sidebar โ Copy token (or `Reset Token` and then `Copy` if you didn't copy it the first time)
15- **Important:** Enable "Message Content Intent" in Bot โ Privileged Gateway Intents
16- `DISCORD_SERVER_ID`: Your Discord server ID (right-click server name โ Copy ID)
17- `DISCORD_MONITORED_CHANNELS`: Comma-separated channel IDs to monitor (right-click channel โ Copy ID)
18- Example: `1327384540187983926,1327384540187983927`
19- `LINEAR_API_KEY`: Your Linear API key
23- Example: `6312a2a0-633b-47dc-a225-81d5d1759bf4`
2425## Discord Bot Setup
26271. **Create bot:** [Discord Developer Portal](https://discord.com/developers/applications) โ New Application โ Bot
282. **Set permissions:** OAuth2 โ URL Generator โ selecting `bot` unfurls a Bot Permissions dropdown below โ Select `View Channels`, `Read Message History`, `Add Reactions`
293. **Enable intents:** Bot โ Privileged Gateway Intents โ โ Message Content Intent
37```typescript
38TARGET_EMOJIS: {
39"huss": "Huss", // Custom Discord emoji :huss:, use just the name without colons (e.g., `"huss"` for `:huss:`)
40"nas": "Nas", // Custom Discord emoji :nas:
41"๐งฟ": "Team", // Unicode built-in emoji, use the actual emoji (e.g., `"๐งฟ"`)
42}
Discord-to-Linearlinear.tsx1 match
3132// Create a new ticket
33async createDiscordTicket(
34title: string,
35description: string,
Discord-to-Linearmain.tsx17 matches
1import { blob } from "https://esm.town/v/std/blob";
2import { CONFIG } from "./backend/config.tsx";
3import { DiscordAPI } from "./backend/discord.tsx";
4import { LinearSDK } from "./backend/linear.tsx";
56/**
7* Cron job to check for new Discord reactions and create Linear tickets
8* Runs every minute to check for messages with the target emoji reaction
9*/
10export default async function() {
11console.log(`๐ Discord reaction cron job started at ${new Date().toISOString()}`);
1213// Get configuration directly
14const serverId = Deno.env.get("DISCORD_SERVER_ID")!;
15const channelsString = Deno.env.get("DISCORD_MONITORED_CHANNELS")!;
16const monitoredChannels = channelsString.split(",").map(id => id.trim());
17const teamId = Deno.env.get("LINEAR_TEAM_ID")!;
2425// Initialize services
26const discord = new DiscordAPI();
27const linear = new LinearSDK();
283233try {
34await processChannelReactions(discord, linear, serverId, channelId, teamId);
35} catch (error) {
36console.error(`โ Error processing channel ${channelId}:`, error);
38}
3940console.log(`โ Discord reaction cron job completed at ${new Date().toISOString()}`);
41}
4245*/
46async function processChannelReactions(
47discord: DiscordAPI,
48linear: LinearSDK,
49serverId: string,
51teamId: string,
52): Promise<void> {
53const messages = await discord.getChannelMessages(channelId, CONFIG.MAX_MESSAGES_TO_CHECK);
54console.log(`๐ Processing ${messages.length} messages...`);
5556for (const message of messages) {
57const reactionResult = discord.findTargetReaction(message);
58if (!reactionResult) continue;
597273try {
74// Generate Discord message URL and ticket details
75const discordUrl = discord.formatMessageUrl(serverId, channelId, message.id);
76const title = discord.generateTicketTitle(message, CONFIG.MAX_TITLE_LENGTH);
77const description = discord.formatMessageContent(message, discordUrl, createdBy);
7879// Create Linear ticket
80const issue = await linear.createDiscordTicket(
81title,
82description,
95emoji_used: emojiName,
96processed_at: new Date().toISOString(),
97discord_message: discordUrl,
98message_author: message.author.username,
99message_content_preview: message.content?.substring(0, 100) || "No content",