Readme

Sends a message to a Discord channel at an interval with a running count of the number of GitHub stars a GitHub repository has.

See the Discord documentation for generating a webhook address here. Remember to store it as a secret environment variable (named here as DISCORD_WEBHOOK_URL) so that others cannot find your URL and post unwanted messages to your channel!

See the documentation on scheduling and https://crontab.guru/ to configure how often the updates are posted.

image.png

Extension ideas πŸ’‘

  • Record the difference in stars (using persistent storage to store data between runs)
  • Print the value of the open_issues_count field to track the number of issues on the GitHub repository
  • Look at the GitHub events API and for example print new and closed pull requests in the span of a week
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook?v=3";
// Your GitHub repository here:
const repository = "kaleidawave/ezno";
const webhook_url = Deno.env.get("DISCORD_WEBHOOK_URL");
export default async (interval: Interval) => {
const response = await fetch(`https://api.github.com/repos/${repository}`);
const { stargazers_count } = await response.json();
const content = `**${repository}** repository has **${stargazers_count}** stars 🌟🌟🌟`;
await discordWebhook({
url: webhook_url,
content,
});
};
πŸ‘† This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data β€” all from the browser.