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.
MIT License
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./chat
config.yaml
gpt-3.5-turbo
.env.example
to .env
and start filling in the values as detailed belowOPENAI_API_KEY
DISCORD_BOT_TOKEN
DISCORD_CLIENT_ID
ALLOWED_SERVER_IDS
. If you want to allow multiple servers, separate the IDs by "," like server_id_1,server_id_2
pip 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.SERVER_TO_MODERATION_CHANNEL
. This should be of the format: server_id:channel_id,server_id_2:channel_id_2
src/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.