A multi-purpose Discord bot built with discord.js, TypeScript
- A dedicated member welcoming and leaving system, server logging system, moderation system, AFK (Away From Keyboard) system, emote management utility
- Fully-featured chatbot system which leverages OpenAI's
gpt-3.5-turbo
model - Makes use of Discord's new bot-user interactions: slash commands, buttons and select menus, context menus and modals
- Provides a centralised logging solution with the use of Logtail
-
Clone the repository and
cd
into it:git clone https://github.com/nine96as/baloo-bot-final cd baloo-bot-final
-
Install required
npm
dependencies:npm install #install dependencies from package.json
-
Complete the steps in the Configuration section, then run the bot with:
npm run start:dev #nodemon listens for file changes
Note: The
start:dev
script will run the bot with nodemon, which will automatically restart the bot when changes are made to the source code.
The bot requires a Discord bot token to use the Discord API, the bot's APPLICATION_ID
to be able to deploy commands, an OpenAI API key to enable the chatbot functionality, a DATABASE_URL
to enable Prisma to interact with a database, and a sourceToken
to be able to transport logs to Logtail.
-
Fetch the Discord bot token by creating a discord bot application, using this guide.
Warning: It is vital that you do not ever share your bot token with anybody, purposely or accidentally. If someone does manage to get a hold of your bot's token, they can use your bot as if it were theirs. If you accidentally share your token, revoke it immediately and generate a new one.
-
Fetch the
APPLICATION_ID
by accessing the Discord Developer Portal, selecting your newly generated bot application, and looking at the General Information page. -
Fetch the OpenAI API key using this guide.
Warning: It is imperative that you do not ever share OpenAI API key with anybody, purposely or accidentally. If you accidentally commit your token, revoke it immediately and generate a new one.
-
Fetch the
DATABASE_URL
using this guide, where PlanetScale is used as the database provider. -
Fetch the
sourceToken
using this guide, where Pino is used as the logging solution. -
After you've acquired all the required values, create a
.env
file, and fill it in as shown below:token='token' clientId='APPLICATION_ID' openAIKey='openAIApiKey' logtailSourceToken='sourceToken' databaseUrl='DATABASE_URL'
To deploy the bot for production, run the below commands.
npm run build #builds ts code into js
npm run start #runs js compiled code