{"id":29016425,"url":"https://github.com/ellettie/custom-ai-bot","last_synced_at":"2026-05-11T07:48:50.344Z","repository":{"id":300911031,"uuid":"1006632189","full_name":"ellettie/custom-ai-bot","owner":"ellettie","description":"a simple ai bot for discord","archived":false,"fork":false,"pushed_at":"2025-06-24T07:40:12.000Z","size":48,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-24T08:31:24.879Z","etag":null,"topics":["discord","discord-bot","discord-bot-template","discord-py","docker","flyio","gemini-api","genai","genai-chatbot","google","python","python-discord-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ellettie.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,"zenodo":null}},"created_at":"2025-06-22T17:25:49.000Z","updated_at":"2025-06-24T07:34:30.000Z","dependencies_parsed_at":"2025-06-24T08:43:11.136Z","dependency_job_id":null,"html_url":"https://github.com/ellettie/custom-ai-bot","commit_stats":null,"previous_names":["ellettie/custom-ai-bot"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ellettie/custom-ai-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellettie%2Fcustom-ai-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellettie%2Fcustom-ai-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellettie%2Fcustom-ai-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellettie%2Fcustom-ai-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ellettie","download_url":"https://codeload.github.com/ellettie/custom-ai-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellettie%2Fcustom-ai-bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261960448,"owners_count":23236575,"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":["discord","discord-bot","discord-bot-template","discord-py","docker","flyio","gemini-api","genai","genai-chatbot","google","python","python-discord-bot"],"created_at":"2025-06-25T22:08:18.082Z","updated_at":"2026-05-11T07:48:50.337Z","avatar_url":"https://github.com/ellettie.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# custom-ai-bot\n\n## 概要\nこのプロジェクトは、Google Gemini APIを活用したAI Discordボットです。テキスト質問や画像生成、ファイル（画像・音声）を使ったAI応答が可能です。  \n![Image](https://github.com/user-attachments/assets/ef7d2a7a-ba23-4c94-bf1b-737bde73758e)\n\n## 主な機能\n- `/ask`：AIにテキストで質問できます（画像・音声ファイルは主要な形式に対応）[Grounding with Google Search](https://ai.google.dev/gemini-api/docs/google-search?hl=ja)による検索と[URL Context](https://ai.google.dev/gemini-api/docs/url-context?hl=ja)によるWebへのアクセスに対応\n- `/image`：AIによる画像生成（Geminiの画像生成モデルを利用）\n- `/info`：利用中のモデル情報表示\n- `/help`：コマンド一覧の表示\n- Discordの埋め込みメッセージ([Embed](https://discord.com/safety/using-webhooks-and-embeds))によるリッチな応答\n\n## セットアップ・デプロイ方法\n\n### 1. Discord側の準備\n\n#### 1.1 Discord Botの作成\n1. [Discord Developer Portal](https://discord.com/developers/applications)にアクセス\n2. 「New Application」をクリックして新しいアプリケーションを作成\n3. アプリケーション名を入力して「Create」をクリック\n4. 左側のメニューから「Bot」を選択\n5. 「Add Bot」をクリックしてBotを作成\n6. 「Token」セクションで「Reset Token」をクリックしてトークンを生成・コピー\n   - このトークンが環境変数 `TOKEN` に必要です\n\n#### 1.2 Bot権限の設定\n1. プライベートなコミュニティでの利用では、PUBLIC BOTをオフにすることを推奨します。\n   - 「Installation」ページの「Install Link」をNoneに設定\n   - 「Bot」ページの「PUBLIC BOT」をオフにする\n2. 「OAuth2」→「OAuth2 URL Generator」\n3. 「Scopes」で「bot」と「applications.commands」をチェック\n4. 「Bot Permissions」で以下の権限をチェック：\n   - View Channels\n   - Send Messages\n   - Send Messages in Threads\n   - Manage Messages\n   - Embed Links\n   - Attach Files\n   - Read Message History\n5. 生成されたURLをコピー\n\n#### 1.3 BotをDiscordサーバーに招待\n1. 上記で生成したURLをブラウザで開く\n2. Botを追加したいDiscordサーバーを選択\n3. 「認証」をクリックしてBotをサーバーに追加\n\n#### 1.4 サーバーIDの取得\n1. Discordで開発者モードを有効化：\n   - ユーザー設定 → 詳細設定 → 開発者モード をオンにする\n2. Botを追加したサーバー名を右クリック\n3. 「IDをコピー」を選択\n   - このIDが環境変数 `GUILD_ID` に必要です\n\n### 2. Google Gemini APIの準備\n1. [Google AI Studio](https://aistudio.google.com/)にアクセス\n2. Googleアカウントでログイン\n3. 「Get API key」をクリック\n4. 新しいAPIキーを作成してコピー\n   - このAPIキーが環境変数 `GEMINI_API_KEY` に必要です\n\n### 3. 必要な環境変数\n- `TOKEN`：Discord BotのトークンSD（上記1.1で取得）\n- `GUILD_ID`：Botを動作させるDiscordサーバID（上記1.4で取得）\n- `GEMINI_API_KEY`：Google Gemini APIキー（上記2で取得）\n- `MODEL`：（任意）テキスト生成モデル名（例: gemini-2.0-flash-exp）\n- `IMAGE_MODEL`：（任意）画像生成モデル名（例: imagen-3.0-generate-001）\n\n### 4. Dockerでのローカル実行\n1. リポジトリのClone\n```bash\ngit clone https://github.com/ellettie/custom-ai-bot\ncd custom-ai-bot\n```\n2. .env.exampleに従い.envをプロジェクトルートに配置\n3. イメージをbuildしコンテナを作成、起動\n```bash\ndocker build -t custom_ai_bot .\ndocker run --env-file .env custom_ai_bot\n```\n\n### 5. GitHub Actions + fly.io でのデプロイ\n1. このリポジトリをforkする\n2. [fly.io](https://fly.io/)でアカウントを作成し、アプリを作成\n3. GitHubのリポジトリ設定から「Settings」→「Secrets and variables」→「Actions」を選択\n4. 以下のシークレットを追加：\n   - `FLY_API_TOKEN`：Fly.ioのAPIトークン\n   - `TOKEN`：Discord Botのトークン\n   - `GUILD_ID`：DiscordサーバーID\n   - `GEMINI_API_KEY`：Gemini APIキー\n   - `MODEL`：使用するテキスト生成モデル名\n   - `IMAGE_MODEL`：使用する画像生成モデル名\n5. `main`ブランチにpushすると、`.github/workflows/fly-deploy.yml` により自動的にfly.ioへデプロイされます\n\n詳細は[fly.io公式ドキュメント](https://fly.io/docs/)や[fly.io公式のGitHub Actionsによるデプロイ手順](https://fly.io/docs/launch/continuous-deployment-with-github-actions/)を参照してください。\n\n### 6. その他クラウドサービスへのデプロイ\nDockerイメージを利用できる任意のクラウドサービス（例: AWS ECS, Google Cloud Run, Azure Container Apps等）でも同様にデプロイ可能です。各サービスの方法で必要な環境変数を設定してください。\n\n## 使用方法\nBotがサーバーに追加され、正常に起動すると、以下のスラッシュコマンドが使用できます：\n\n### コマンド一覧\n- `/ask テキストでAIに質問 画像、音声ファイルの添付に対応`\n- `/image 画像を生成`\n- `/info モデル情報表示`\n- `/help コマンド一覧表示`\n\n### 使用例\n```\n/ask 今日の天気について教えて\n/ask 画像を説明して（画像ファイルを添付）\n/image 美しい夕日の風景\n/info\n```\n\n## 依存ライブラリとライセンス\n- **discord.py==2.5.2**\n  - [MITライセンス](https://github.com/Rapptz/discord.py/blob/master/LICENSE)\n- **google-genai==1.21.1**\n  - [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n- **Pillow==11.2.1**\n  - [MITライセンス（PIL \u0026 Pillow）](https://github.com/python-pillow/Pillow/blob/master/LICENSE)\n\n\u003e これらのライブラリは商用利用も可能ですが、再配布時は各ライセンス条項に従ってください。\n\n## ファイル構成\n- `run.py`：エントリーポイント\n- `bot/`：Bot本体・AI連携・ユーティリティ\n  - `__init__.py`：Discordコマンド・Bot本体\n  - `gemini.py`：Gemini API連携\n  - `myutils.py`：メッセージ分割等の補助関数\n- `discord.log`：Botのログ\n- `Dockerfile`：Docker用設定\n- `.github/workflows/fly-deploy.yml`：GitHub ActionsによるFly.io自動デプロイ\n\n## ライセンス\nこのプロジェクト自体はMITライセンスです（[LICENSE](./LICENSE)ファイル参照）。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fellettie%2Fcustom-ai-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fellettie%2Fcustom-ai-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fellettie%2Fcustom-ai-bot/lists"}