Node.js Discord Bot.
- AI chat completion using GPT-4
- AI image generation using DALL·E
- Meme creator
- Translate messages to several languages
- Weather report
- ... lot's more fun interactions for your server
Certain features require setting a third-party API key:
- OpenAI (GPT-4 and DALL·E) requires paid API access. Set
OPENAI_API_KEY
in.env
to enable. - DeepL (translation) requires free API access. Set
DEEPL_AUTH_KEY
in.env
to enable.
Operating System: 🍏 macOS or 🐧 Linux. 🪟 Windows has only been tested using WSL2.
Runtime: Node 20+, pnpm
Additional Packages: graphicsmagick
- Ensure Node 20+ and pnpm are available. If Node is not installed or less than the required version, you can run
./setup.sh
which will download a compatible runtime using nvm. - Clone the repository and open a terminal in the project directory.
- Run
pnpm install
to download package dependencies. - Copy
.env.sample
to.env
. - If you have an existing discord application you wish to use, set
DISCORD_TOKEN
in.env
, e.g.DISCORD_TOKEN=abc
. Otherwise, proceed to the next section.
- Create a new Application using the Developer Portal.
- Navigate to the Bot section.
- Click Reset Token and ensure you Copy the token, it can only be viewed once.
- Edit
.env
and setDISCORD_TOKEN
, e.g. if your token isabc
, you should setDISCORD_TOKEN=abc
. - Disable Public Bot under Authorization Flow.
- Enable Message Content Intent under Privileged Gateway Intents.
- Click Save Changes.
- Navigate to the OAuth2 section of your Application from the Developer Portal.
- Copy the Client ID.
- Replace
1122334455
in the following URL with your Client ID:https://discord.com/api/oauth2/authorize?client_id=1122334455&permissions=274877959232&scope=bot
. - Visit the URL using a browser which is signed in to your Discord account.
- Select the server to add the bot to and then Authorize.
For reference, &permissions=274877959232
in the URL maps to the following permissions:
Read Messages/View Channels, Send Messages, Send Messages in Threads, Embed Links, Attach Files, Add Reactions
Run pnpm start
to start the bot.
Command | Description |
---|---|
pnpm run build |
Compile prod version to ./out |
pnpm run lint |
Run ESLint |
pnpm run lint:fix |
Run ESLint and attempt fixes |
pnpm run typeorm -- [options] |
Run TypeORM cli commands |
pnpm run start |
Start the bot |
pnpm run watch |
Start the bot and restart on file changes |