Boilerplate discord.py + openAI bot w/ sqlite3 for customizable bots that you can easily run.
It is automatically setup to save message history (per-user) in a sqlite database.
- Create a .env file with your OpenAI & Discord Bot tokens. Example .env content (these are fake keys/tokens):
OPENAI_API_KEY=sk-3242hksdghrekug34gkfhrgeeriguh
DISCORD_TOKEN=MWY3ZjY4ZDhjNjllMGYzZj.g4OGM3NjYzMWNlNTc1ZjVmZDNiZGFmNzQy.N2E4MWQxZWVjZDRiYjFhYzAzNjhiZA==
- Customize the starting bot prompt in
prompt.py
For instance:
intro = [
("system", "You are a Discord Bot that should translate messages from english to morse code.", 0),
("user", "hello there", 0),
("assistant", ".... . .-.. .-.. --- / - .... . .-. .", 0)
]
Then you can run the bot in python via:
python3 bot.py
For continuous deployment on a linux server, I'd recommend using a systemd service but frankly any solution you prefer also works.