For any problems running this specific bot: Discord Project Post
For general OpenAI API problems or questions: Discord API Discussions
For bugs in the template code: create an Issue
For feature requests: this repo is not accepting feature requests, you can discuss potential features in Discord Project Post
For PRs: only bug fix PRs wil be accepted. If you are implementing a new feature, please fork this repo.
Thank you!
Example Discord bot written in Python that uses the chat completions API to have conversations with the gpt-3.5-turbo model, and the moderations API to filter the messages.
This bot uses the OpenAI Python Library and discord.py.
/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./chatconfig.yamlgpt-3.5-turbo.env.example to .env and start filling in the values as detailed belowOPENAI_API_KEYDISCORD_BOT_TOKENDISCORD_CLIENT_IDALLOWED_SERVER_IDS. If you want to allow multiple servers, separate the IDs by "," like server_id_1,server_id_2pip install -r requirements.txt
python -m src.main
You should see an invite URL in the console. Copy and paste it into your browser to add the bot to your server.
Note: make sure you are using Python 3.9+ (check with python --version)SERVER_TO_MODERATION_CHANNEL. This should be of the format: server_id:channel_id,server_id_2:channel_id_2src/config.yaml and edit the instructionssrc/constants.py. A higher value means less chance of it triggering, with 1.0 being no moderation at all for that category.Why isn't my bot responding to commands?
Ensure that the channels your bots have access to allow the bot to have these permissions. - Send Messages - Send Messages in Threads - Create Public Threads - Manage Messages (only for moderation to delete blocked messages) - Manage Threads - Read Message History - Use Application Commands
$ claude mcp add gpt-discord-bot \
-- python -m otcore.mcp_server <graph>