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.
stevekrouse
twitterAlert
Cron
Twitter/𝕏 keyword alerts Custom notifications for when you, your company, or anything you care about is mentioned on Twitter. If you believe in Twitter/𝕏-driven development, you want to get notified
when anyone is talking about your tech, even if they're not tagging you. To get this Twitter Alert bot running for you,
fork this val and modify the query and where the notification gets delivered. 1. Query Change the keywords for what you want to get notified for
and the excludes for what you don't want to get notified for. You can use Twitter's search operators to customize your query, for some collection of keywords, filtering out others, and much more! 2. Notification Below I'm sending these mentions to a public channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever. Twitter Data & Limitations The Twitter API has become unusable. This val gets Twitter data via SocialData ,
an affordable Twitter scraping API. In order to make this val easy for
you to fork & use without signing up for another API, I am proxying
SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy
100 times per day, so be sure not to set this cron to run more than once every 15 min. If you want to run it more, get your own SocialData
API token and pay for it directly.
4
jonbo
MADBOTS
Cron
MAD BOTS (Multi-functional Alerting & Diagnostics Bot Operations Tracking System) This val runs every two minutes and makes sure a supabase realtime websocket listener is still alive. on spawn, checks to see if acknowledged_by_server == true if not, send a message to discord update the row (id=1) in supabase with acknowledged_by_server: false to reset for next run this will be responded to by the supabase handler. code snippet below: .on(
"postgres_changes",
{
event: "UPDATE",
schema: "public",
table: "uptime",
},
async (payload) => {
// this means we just acknowledged it
if (payload.new.acknowledged_by_server) {
console.log('uptime check already acknowledged - skipping');
return;
};
console.log('incoming uptime check request', payload);
if (!payload.new.acknowledged_by_server) {
await supabaseAdminClient.from('uptime').update({ acknowledged_by_server: true, acknowledged_at: new Date() }).eq('id', payload.new.id);
console.log('uptime check acknowledged');
}
}
)
note: this will keep alerting every two minutes until acknowledged. something to resolve in the next version.
0