{"id":23273121,"url":"https://github.com/statusfailed/example-rust-discord-image-bot","last_synced_at":"2025-04-06T10:23:19.360Z","repository":{"id":268568010,"uuid":"904780179","full_name":"statusfailed/example-rust-discord-image-bot","owner":"statusfailed","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-17T14:42:58.000Z","size":449,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T15:53:13.944Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statusfailed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-12-17T14:38:38.000Z","updated_at":"2024-12-18T16:06:16.000Z","dependencies_parsed_at":"2024-12-17T15:41:35.323Z","dependency_job_id":"6d0532b1-db72-47fc-b8a3-b9dfdfea1b35","html_url":"https://github.com/statusfailed/example-rust-discord-image-bot","commit_stats":null,"previous_names":["statusfailed/example-rust-discord-image-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fexample-rust-discord-image-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fexample-rust-discord-image-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fexample-rust-discord-image-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fexample-rust-discord-image-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statusfailed","download_url":"https://codeload.github.com/statusfailed/example-rust-discord-image-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247465484,"owners_count":20943183,"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","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":[],"created_at":"2024-12-19T19:32:38.617Z","updated_at":"2025-04-06T10:23:19.343Z","avatar_url":"https://github.com/statusfailed.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"assets/henlo.png\" height=200 /\u003e\n\u003ch1\u003eBuild a Discord Image Bot in Rust\u003c/h1\u003e\n\u003c/div\u003e\n\nIn the [hellas.ai Discord](https://discord.gg/YWZCWPrNTb), we have an image\ngeneration bot called `@henlo`.\nMessage `@henlo` or DM it your prompt, and it will respond with an image.\n\nThis repo will let you **create your own bot** in 5 minutes using:\n\n- The Discord API via Rust's [serenity](https://docs.rs/serenity/latest/serenity/) library.\n- [flux schnell](https://huggingface.co/black-forest-labs/FLUX.1-schnell) running on [ezgen](https://ezgen.net).\n\n# Run\n\nAfter cloning this repository, you'll need two API keys in the `.env` file:\n\n    EZGEN_TOKEN=\n    DISCORD_TOKEN=\n\nSet these, then run the bot with\n\n    cargo run\n\nTo get the two API keys, follow the instructions below.\n\n# Create a Discord App \u0026 Bot\n\nGo to the discord [applications page](https://discord.com/developers/applications),\nclick \"New Application\" and choose a name.\n\nIn the \"OAuth2\" tab, under \"OAuth2 URL Generator\", select the `bot` permission.\n\n\u003cimg src=\"assets/discord-oauth-bot.png\" /\u003e\n\nCopy the generated URL at the bottom of the page, and open in your browser to\nadd the bot to a server you are admin of.\n\n\u003cimg src=\"assets/discord-oauth-url.png\" /\u003e\n\nLastly, to get the bot token go to \"Bot\", then click \"Reset Token\":\n\n\u003cimg src=\"assets/discord-bot-token.png\" /\u003e\n\nAdd this to `DISCORD_TOKEN` in the bot's .env file.\n\n# Set up ezgen\n\nNext, use my [referral link](https://ezgen.net/signup?referred_by=42da63dd-d6c2-4c08-8044-0e92dbbf0d12)\nto sign up for ezgen.net.\nThis should get you 20 free credits.\n\nNext, create an API key by clicking \"New API Key\" and choosing a name for the key.\n\n\u003cimg src=\"assets/create-api-key.png\" /\u003e\n\nCopy the secret (starting with `key_`) and make sure to save it as the `EZGEN_TOKEN` field in `.env`.\n\n# Run the bot\n\nYou should now be able to run the bot:\n\n    cargo run\n\nYou should see something like this:\n\n    \u003ecargo run\n    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s\n    Running `target/debug/example-discord-image-bot`\n    \u003cyourbotname\u003e is connected!\n\nTo generate an image, either DM the bot directly, or @mention it in a channel.\nThe bot will give a thumbs-up to show it's working, and then reply to your\nmessage with the result.\n\n\u003cimg src=\"assets/bot-demo.png\" /\u003e\n\n# Modify the bot\n\nThe main bot code is in [./src/bot.rs](./src/bot.rs) in the `impl EventHandler for Bot`.\nThe code is intended to show a few different features of [serenity](https://docs.rs/serenity/latest/serenity/):\n\n- [Getting message metadata](https://github.com/statusfailed/example-discord-image-bot/blob/main/src/bot.rs#L39)\n- [Reacting to a message](https://github.com/statusfailed/example-discord-image-bot/blob/main/src/bot.rs#L48)\n- [Replying to a message with an image](https://github.com/statusfailed/example-discord-image-bot/blob/main/src/bot.rs#L92)\n\nYou should probably start by playing with this file first.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fexample-rust-discord-image-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatusfailed%2Fexample-rust-discord-image-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fexample-rust-discord-image-bot/lists"}