Example code for running a Discord Bot that uses OpenAI's DALL-E api to generate AI images.
This bot uses OpenAI's NodeJS SDK, and v14 of discord.js, and is written in Typescript.
This repo is not accepting Pull Requests. Please fork this repo if you want to add or change features.
- draw command to generate images (1 to 9) using the generations endpoint
- save button to send images to user's DMs
- reroll button to rerun that generation
- expand button to zoom out of the image by using the edits (inpaint) endpoint
https://discordjs.guide/preparations/setting-up-a-bot-application.html
Your bot needs the following bot permissions:
- Send Messages
- Use Slash Commands
- Attach Files
Use the invite link in src/Bot.ts
, which includes the above permissions.
- Go to
src/utils/constants.ts
and follow the comments to createsrc/utils/config.json
- Copy your bot's client id and token into
config.json
- Copy your server's id into
config.json
(https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-) - Copy your OpenAI API key into
config.json
(https://beta.openai.com/account/api-keys)
- install brew if you don't have it (https://docs.brew.sh/Installation)
brew install npm
if you don't have itnpm install
in repo rootnpm run start
in repo root