{"id":15041892,"url":"https://github.com/discord/avatar-remix-bot","last_synced_at":"2025-10-26T04:32:35.870Z","repository":{"id":137882732,"uuid":"608761799","full_name":"discord/avatar-remix-bot","owner":"discord","description":"This project contains code for a Discord bot that will edit friends' profile pictures in fun and sometimes unexpected ways.","archived":false,"fork":false,"pushed_at":"2025-08-11T16:09:11.000Z","size":120,"stargazers_count":130,"open_issues_count":3,"forks_count":10,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-10-02T04:32:52.996Z","etag":null,"topics":["bot","samples"],"latest_commit_sha":null,"homepage":"https://discord.com/blog/ai-on-discord-your-place-for-ai-with-friends","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discord.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-02T17:24:28.000Z","updated_at":"2025-08-11T16:09:15.000Z","dependencies_parsed_at":"2023-10-13T12:56:46.734Z","dependency_job_id":"62d0626a-bebf-480f-9d92-3bd8a62d7f7e","html_url":"https://github.com/discord/avatar-remix-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/discord/avatar-remix-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Favatar-remix-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Favatar-remix-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Favatar-remix-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Favatar-remix-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discord","download_url":"https://codeload.github.com/discord/avatar-remix-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Favatar-remix-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281059645,"owners_count":26437056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","samples"],"created_at":"2024-09-24T20:46:36.312Z","updated_at":"2025-10-26T04:32:35.575Z","avatar_url":"https://github.com/discord.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Avatar Remix\n\nThis project contains code for a Discord bot that will edit friends' profile pictures in fun and sometimes unexpected ways.\n\n![avatar remix example](https://www.ianww.com/avatar-remix/catluvr2.png)\n\n## Try it out\n\n[Replicate](https://replicate.com?utm_source=project\u0026utm_campaign=avatar-remix-bot-repo) has provided a hosted version of this bot. You can [invite the hosted bot to your Discord server](https://discord.com/oauth2/authorize?client_id=1083422468263387227\u0026scope=applications.commands+bot), or follow this README to set up and host your own custom version.\n\n## How it works\n\nThe main functionality of Avatar Remix is provided by [instruct-pix2pix](https://www.timothybrooks.com/instruct-pix2pix), a model based on Stable Diffusion fine-tuned on a large dataset of example prompts generated by GPT-3.\n\nDiscord profile pictures are often pretty small, so if necessary it uses [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) to upscale for better results.\n\nThis app runs as a Cloudflare Worker and uses the [Replicate](https://replicate.com?utm_source=project\u0026utm_campaign=avatar-remix-bot-repo) API to run the above models serverlessly.\n\n![request flow](https://kroki.io/mermaid/svg/eNqVjzEOwjAMRfecIhfowlqJEzBxActNTCkNSbFjwfFJIgZQqRCDh299-_83Mi5nezj2xqgQA9NNSbLtur11Iak_BWSCe-KZuDerVTOi95ATlEul8oiER4zgMIQB3fzfL8nIGaYomdVlWKbHrgxc0tCb1fZXxFYGRV9IRUOuvSt4rR0bgK9ZzdYkuBRFr8TmU76VffG2ipumr0RPimmNGA==)\n\n## Setup\n\n### Install dependencies\n\nThis bot runs on Node and its package manager, npm. If you don't already have node and npm set up, [following this guide](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).\n\nInstall the bot's dependencies by running:\n\n```bash\nnpm install\n```\n\n### Set up external accounts\n\nThis bot uses [Cloudflare Workers](https://workers.cloudflare.com/) and [Replicate](https://replicate.com?utm_source=project\u0026utm_campaign=avatar-remix-bot-repo). You'll need to:\n\n- Set up `wrangler` locally ([see Cloudflare docs](https://developers.cloudflare.com/workers/wrangler/install-and-update/))\n- Get a [Replicate API token](https://replicate.com/account?utm_source=project\u0026utm_campaign=avatar-remix-bot-repo)\n\n### Create a Discord application\n\nCreate a new application on the [Discord Developer portal](https://discord.com/developers/applications). Give it a name like `avatar-remix-bot`.\n\nThen, in the \"Bot\" settings tab of your application, click \"Add Bot\" (we don't actually need this bot user, but we use its token for convenience...)\n\nSee the [Getting Started](https://discord.com/developers/docs/getting-started) guide on the Discord developer portal for more details.\n\n\u003chttps://user-images.githubusercontent.com/310310/223584110-296e5ef3-d37c-482f-9b4d-04f52a3dbab0.mp4\u003e\n\n**NOTE: if you use the code in this project to build or operate an app or bot on Discord, you will need to comply with Discord’s [Developer Terms of Service and Policy](https://discord.com/developers/docs/policies-and-agreements/developer-terms-of-service). Use of this code does not guarantee compliance.**\n\n### Envars and secrets\n\nSet up envars in `wrangler.toml`:\n\n- Rename `example.wrangler.toml` to `wrangler.toml`\n- Update `DISCORD_APPLICATION_ID` and `DISCORD_PUBLIC_KEY` with values from the application you created in the previous step.\n- Update `WORKER_BASE_URL` with the URL of your Cloudflare worker. By default, this URL takes the form `https://avatar-remix-bot.\u003cyour worker username\u003e.workers.dev`.\n\nUse wrangler to store secret tokens for your bot by running the following commands:\n\n- `wrangler secret put DISCORD_BOT_TOKEN` - obtain this token by clicking \"View Token\" on the Bot page\n- `wrangler secret put REPLICATE_API_TOKEN` - obtain this token from your [Replicate account settings](https://replicate.com/account?utm_source=project\u0026utm_campaign=avatar-remix-bot-repo)\n\nIf you want to run the app locally, rename `example.dev.vars` to `.dev.vars`, and update the variables with the appropriate secrets.  **ENSURE `.dev.vars` is in your `.gitignore`, and do not share these secrets**.\n\n### KV store and Queues\n\nThis bot uses Cloudflare to host some serverless infrastructure.\n\nFirst, it uses [Workers KV](https://developers.cloudflare.com/workers/runtime-apis/kv/) in order to track Replicate jobs and match callbacks with the original jobs. Run the following command to create the KV namespace:\n\n```sh\nwrangler kv:namespace create AVATAR_REMIX_FOLLOWUPS\n```\n\nTake the output and paste it into `wrangler.toml`, replacing the placeholder binding for `AVATAR_REMIX_FOLLOWUPS`.\n\nSecond, it uses [Cloudflare Queues](https://developers.cloudflare.com/queues/platform/javascript-apis/) to stay within Replicate rate limits during periods of heavy load (this isn't necessary unless you think a lot of people will use your app):\n\n```bash\nwrangler queues create avatar-remix-jobs\n```\n\nNote that Cloudflare Queues are in beta!  You might have to enable them manually in the [Cloudflare dashboard](https://dash.cloudflare.com/) by going to Workers \u003e Queues.\n\n### Publish the Cloudflare Worker\n\nIt's time to bring your worker online! Run the following:\n\n```bash\nwrangler publish\n```\n\nIf all went according to plan, you should see something like this:\n\n```text\nUploaded avatar-remix-bot (1.16 sec)\nPublished avatar-remix-bot (0.67 sec)\n  https://avatar-remix-bot.\u003cyourname\u003e.workers.dev\n  Consumer for avatar-remix-jobs\nCurrent Deployment ID: f5d24e08-a211-4bae-a573-e513b5355910\n```\n\nIf you go to `https://avatar-remix-bot.\u003cyourname\u003e.workers.dev`, you should see the message \"greetings\". That means your web application is online and ready to talk with Discord :)\n\n### Register your Interactions Endpoint URL\n\nOn the \"General Information\" tab of your Application's settings in the developer portal, scroll down and set the \"Interactions Endpoint URL\" to the URL of your Cloudflare Worker.\n\nThe URL was outputted in the previous step, and typically it is of the form `https://avatar-remix-bot.\u003cyourname\u003e.workers.dev`.\n\n![here's where the interaction endpoint url is set](https://user-images.githubusercontent.com/310310/223584868-ce3bc51d-fe8c-4255-a1d0-7c528d8c06f8.png)\n\nOnce you've clicked Save Changes, Discord will test your endpoint and you will get a success message in the dev portal indicating that your changes have been saved.\n\n### Register slash commands\n\nThis bots uses a `/remix` slash command, and you must register the slash command before using it for the first time. Register it by hitting the register endpoint with a `POST` request:\n\n```sh\ncurl -X POST https://avatar-remix-bot.\u003cyourname\u003e.workers.dev/register\n```\n\nThe response will just say \"Registered commands\".\n\nIn the future, you'll have to do this any time you've made a change to `commands.ts`.\n\n### Invite it to your server\n\nYour bot is ready to go! Invite it to your server by constructing an invite URL:\n\n```text\nhttps://discord.com/oauth2/authorize?client_id=\u003cyour discord application id\u003e\u0026scope=applications.commands+bot\n```\n\nReplace the `client_id` above with the `DISCORD_APPLICATION_ID` you recorded earlier.\n\nThat's all! Use the `/remix` command and start remixing to your heart's content.\n\n![partially typed remix command](https://user-images.githubusercontent.com/310310/223583186-269e875b-19b6-4fc5-8832-843bdd60cfec.png)\n\nREMINDER: Make sure your bot complies with the [Discord Developer Terms of Service and Policy](https://discord.com/developers/docs/policies-and-agreements/developer-terms-of-service).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Favatar-remix-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscord%2Favatar-remix-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Favatar-remix-bot/lists"}