Back to APIs list

Discord API examples & templates

Use these vals as a playground to view and fork Discord API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
charmainetest avatar
charmainetest
tangibleBlackTiger
Cron
Forked from valdottown/templateRedditAlert
0
malloc avatar
malloc
examplebot_endpoint
Script
An interactive, runnable TypeScript val by malloc
0
valdottown avatar
valdottown
templateTwitterAlert
Cron
Twitter/𝕏 Keyword Alerts [TEMPLATE] Get custom notifications when you, your company, or anything you care about is mentioned on Twitter/X, even if they don't tag you directly. This template will help you: Search for specific mentions on Twitter/X using customizable keywords. Deliver notifications wherever you'd like (email, Discord, Slack, Telegram, etc). Example This 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. To see exactly how we use this template at Val Town: https://www.val.town/v/stevekrouse/twitterAlert Set Up 1. Fork this Val To use this template, fork this val on the top right corner of this page. 2. View Source Code The CODE box shows you the the full source code of this val, you may need to scroll down to see it. 3. Customize Query Define what you want to search for by modifying query : const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity -from:val__run"; Refer to Twitter's search operators to fine-tune your query. 4. Test API call Set isProd = false in the code if you are testing, to ensure there are enough tweets to display. Toggle it back to true when you're ready to run this cron job in production and actuall send notifications. 5. Choose Notification Method This template uses a Discord webhook for notifications, but you can update this to your preferred platform by replacing the discordWebhook call with a call to Slack , @std/email , etc. Create a Discord webhook following this guide . Save your Discord Webhook URL in your Val Town environment variables : Key: mentionsDiscord Value: Your Discord webhook URL. Notifications will be sent using this function: await discordWebhook({ url: Deno.env.get("mentionsDiscord"), content, }); 🎉 Congrats! You now have a val running that ensures you never miss another Twitter/X mention. 🎉 NOTE: Usage Limits This val uses the SocialData API for Twitter data: Proxies via Val Town's SocialDataProxy : Limited to 10 cents per day for Val Town Pro users . This API is only for Pro users. Need more calls? Sign up for your own SocialData API token and configure the socialDataSearch function.
0
stevekrouse avatar
stevekrouse
hnValTown
Cron
An interactive, runnable TypeScript val by stevekrouse
0
stevekrouse avatar
stevekrouse
handleOnboardingReferral
RPC (deprecated)
// Triggered when someone tells us how they hear about VT on onboarding
0
stevekrouse avatar
stevekrouse
blueskyAlert
Cron
Forked from buttondown/runner
0
charmainetest avatar
charmainetest
templateRedditAlert
Cron
Forked from valdottown/templateRedditAlert
0
augustveix avatar
augustveix
OpticonReminder
HTTP
Forked from stevekrouse/newStripeSubscriber
0
marianogenovese avatar
marianogenovese
twitterAlert
Cron
Forked from stevekrouse/twitterAlert
0
stevekrouse avatar
stevekrouse
newStripeSubscriber
HTTP
New Stripe Subscription Handler This val processes new Stripe subscribers to Val Town Pro. It sends our team a Discord notifcation and sends a welcome email to the new subscriber. It takes a couple of steps if you'd like to set up something similar for your own Stripe account. Setup Fork this HTTP val Create a new webhook in Stripe Add your val's HTTP endpoint URL into the Stripe webhook Select customer.subscription.updated as the only event to listen to (more on this below) Add your stripe_sk_customer_readonly to your Val Town Env Variables Add your webhook's signing secret as STRIPE_WEBHOOK_SECRET to you Val Town Env Variables How the code is structured Verifies the signature to make sure it's really from Stripe Filters out only newly created subscriptions Sends off the Discord message & email Which Stripe event type to listen to Stripe sends webhooks for many different kinds of events. Relevant for us here are: customer.subscription.created (what we used to listen for) customer.subscription.updated (what we're currently listening for) The issue with customer.subscription.created is that it triggers too early, before the user's payment actually goes through. This is a problem because in early Nov 2024 we started getting credit card fraudsters testing cards using our service. We started getting lots of notifications for new subscriptions that never actually became active. Note: if anyone knows good ways to prevent that sort of behavior at the root, please let me know by commenting on this val! In order to only get notified on a valid subscription, we now subscribe to customer.subscription.updated . This event happens on any subscription change, including renewals and cancellations, so now we have to filter those events to only get new subscriptions, ie where: event.data.previous_attributes.status === 'incomplete' && event.data.object.status === 'active'
2
hyusap avatar
hyusap
tldc_discord
HTTP
Forked from steveruizok/tldraw_computer_example
0
geoffreylitt avatar
geoffreylitt
twitterDailyDigest
Cron
Forked from stevekrouse/twitterAlert
3
newbee avatar
newbee
FaucetShardeum
Cron
An interactive, runnable TypeScript val by newbee
0
mattx avatar
mattx
examplebotendpoint
Express (deprecated)
An interactive, runnable TypeScript val by mattx
0
kos0616 avatar
kos0616
callMe
Script
An interactive, runnable TypeScript val by kos0616
0
dhruv avatar
dhruv
twitterAlert
Cron
Forked from stevekrouse/twitterAlert
0
…
8
…
Next