{"id":13467225,"url":"https://github.com/openai/gpt-discord-bot","last_synced_at":"2025-05-15T10:07:10.264Z","repository":{"id":65034882,"uuid":"580951674","full_name":"openai/gpt-discord-bot","owner":"openai","description":"Example Discord bot written in Python that uses the completions API to have conversations with the `text-davinci-003` model, and the moderations API to filter the messages.","archived":false,"fork":false,"pushed_at":"2024-06-07T10:53:58.000Z","size":16,"stargazers_count":1809,"open_issues_count":14,"forks_count":671,"subscribers_count":35,"default_branch":"main","last_synced_at":"2025-04-14T16:54:16.121Z","etag":null,"topics":[],"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/openai.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":"2022-12-21T21:53:06.000Z","updated_at":"2025-04-11T16:46:05.000Z","dependencies_parsed_at":"2024-01-14T09:24:26.387Z","dependency_job_id":"8b89dd8a-5d38-490b-89c9-487b2af18d0a","html_url":"https://github.com/openai/gpt-discord-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fgpt-discord-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fgpt-discord-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fgpt-discord-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openai%2Fgpt-discord-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openai","download_url":"https://codeload.github.com/openai/gpt-discord-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319720,"owners_count":22051073,"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-07-31T15:00:54.230Z","updated_at":"2025-05-15T10:07:05.245Z","avatar_url":"https://github.com/openai.png","language":"Python","funding_links":[],"categories":["Bots","Chatbots","Python"],"sub_categories":["Self Host-able Bots"],"readme":"# Please read!\n\n\n**For any problems running this specific bot:** [Discord Project Post](https://discord.com/channels/974519864045756446/1055336272543092757)\n\n**For general OpenAI API problems or questions:** [Discord API Discussions](https://discord.com/channels/974519864045756446/1037561178286739466)\n\n**For bugs in the template code:** create an Issue\n\n**For feature requests:** this repo is not accepting feature requests, you can discuss potential features in [Discord Project Post](https://discord.com/channels/974519864045756446/1055336272543092757)\n\n**For PRs:** only bug fix PRs wil be accepted. If you are implementing a new feature, please fork this repo.\n\nThank you!\n\n---\n# GPT Discord Bot\n\nExample Discord bot written in Python that uses the [chat completions API](https://platform.openai.com/docs/api-reference/chat/create) to have conversations with the `gpt-3.5-turbo` model, and the [moderations API](https://beta.openai.com/docs/api-reference/moderations) to filter the messages.\n\nThis bot uses the [OpenAI Python Library](https://github.com/openai/openai-python) and [discord.py](https://discordpy.readthedocs.io/).\n\n\n# Features\n\n- `/chat` starts a public thread, with a `message` argument which is the first user message passed to the bot. You can optionally also adjust the `temperature` and `max_tokens` parameters.\n- The model will generate a reply for every user message in any threads started with `/chat`\n- The entire thread will be passed to the model for each request, so the model will remember previous messages in the thread\n- when the context limit is reached, or a max message count is reached in the thread, bot will close the thread\n- you can customize the bot instructions by modifying `config.yaml`\n- you can change the model, the default value is `gpt-3.5-turbo`\n\n# Setup\n\n1. Copy `.env.example` to `.env` and start filling in the values as detailed below\n1. Go to https://beta.openai.com/account/api-keys, create a new API key, and fill in `OPENAI_API_KEY`\n1. Create your own Discord application at https://discord.com/developers/applications\n1. Go to the Bot tab and click \"Add Bot\"\n    - Click \"Reset Token\" and fill in `DISCORD_BOT_TOKEN`\n    - Disable \"Public Bot\" unless you want your bot to be visible to everyone\n    - Enable \"Message Content Intent\" under \"Privileged Gateway Intents\"\n1. Go to the OAuth2 tab, copy your \"Client ID\", and fill in `DISCORD_CLIENT_ID`\n1. Copy the ID the server you want to allow your bot to be used in by right clicking the server icon and clicking \"Copy ID\". Fill in `ALLOWED_SERVER_IDS`. If you want to allow multiple servers, separate the IDs by \",\" like `server_id_1,server_id_2`\n1. Install dependencies and run the bot\n    ```\n    pip install -r requirements.txt\n    python -m src.main\n    ```\n    You should see an invite URL in the console. Copy and paste it into your browser to add the bot to your server.\n    Note: make sure you are using Python 3.9+ (check with python --version)\n\n# Optional configuration\n\n1. If you want moderation messages, create and copy the channel id for each server that you want the moderation messages to send to in `SERVER_TO_MODERATION_CHANNEL`. This should be of the format: `server_id:channel_id,server_id_2:channel_id_2`\n1. If you want to change the personality of the bot, go to `src/config.yaml` and edit the instructions\n1. If you want to change the moderation settings for which messages get flagged or blocked, edit the values in `src/constants.py`. A higher value means less chance of it triggering, with 1.0 being no moderation at all for that category.\n\n# FAQ\n\n\u003e Why isn't my bot responding to commands?\n\nEnsure that the channels your bots have access to allow the bot to have these permissions.\n- Send Messages\n- Send Messages in Threads\n- Create Public Threads\n- Manage Messages (only for moderation to delete blocked messages)\n- Manage Threads\n- Read Message History\n- Use Application Commands\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fgpt-discord-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenai%2Fgpt-discord-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenai%2Fgpt-discord-bot/lists"}