A GPT-3 Discord chat bot in TypeScript with OpenAI

Alessandro Raffa
4 min readJan 29, 2023

Creating a Discord chat bot using TypeScript and OpenAI with a GPT-3 model is a great way to add interactive and personalized functionality to a Discord server.

In this article, I will go through the steps to create a simple Discord chat bot that responds to users’ messages.

Step 1: Set up a new Discord bot

To set up a new Discord bot, you will first need a Discord account and create a new application on the Discord Developer Portal.

Once you have created the application, in the General Information section, keep note of the APPLICATION ID as of YOUR_DISCORD_BOT_ID.

Now you can then create a new bot associated with that application. Once you have created the bot, you will be given a token that you will use to authenticate the bot with the Discord API. Keep note of that token as of YOUR_DISCORD_BOT_TOKEN.

Under the Authorization Flow section, you can decide if your bot is public or private. Under the Privileged Gateway Intents section you must check at least the MESSAGE CONTENT INTENT.

Authorization Flow and Privileged Gateway Intents sections of a Discord Bot

--

--

Alessandro Raffa
Alessandro Raffa

Written by Alessandro Raffa

Coder since 1989, software developer, husband, dad. Music, acoustic guitar, bike, kayak, cooking, meditation, science, astronomy. Running infobiotech in Sicily.

Responses (1)