mirror of
https://github.com/mikndotdev/discord-avatar.git
synced 2026-08-18 02:47:46 +00:00
Cloudflare Worker that will redirect users to a Discord avatar link when provided with a User ID.
- TypeScript 100%
| .idea | ||
| src | ||
| .gitignore | ||
| biome.json | ||
| bun.lock | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| wrangler.toml | ||
Discord Avatar Cloudflare Worker
Get a user's Discord avatar by their ID. This worker allows CORS from any origin, and can be embedded into websites, using your Discord profile as a sort of proto-Gravatar.
Usage
https://your.workers.dev/(id)
Optional parameters
| Parameter | Default |
|---|---|
| format | png |
| resolution | 1024 |
Deployment
This project uses Upstash Redis to cache the avatars. You can get a free account here.
- Create a new Upstash Redis instance, and save the URL and password.
- Create a Discord bot and save the token. No intents are required.
- Fork this repository, and deploy it to Cloudflare Workers.
- Go to the Worker settings and add the following secrets:
UPSTASH_REDIS_URL: The URL of the Upstash Redis instance.UPSTASH_REDIS_TOKEN: The password of the Upstash Redis instance.DISCORD_TOKEN: The token of the Discord bot.
- Redeploy the Worker, and optionally set up Workers Builds.
- Enjoy!