Uploaded July 2023 | Updated September 2026, 1 week ago
Create a simple ChatGPT bot using Discord.JS v14 and the OpenAI API.
🧠 Learn website dashboards + bot monetization ➡ levelupyourbot.com
🔥 Source code download ➡ wornoffkeys.com/code?yt=HHtMPTnIm0M
🙋♂️ Need help? Ask in our Discord community:
wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
wornoffkeys.com/playlist/djs
💡 Request new video ideas here:
wornoffkeys.com/content-request
📺 Subsribe for new videos here:
youtube.com/@WornOffKeys?sub_confirmation=1
🔗 Regex for counting tokens:
gist.github.com/AlexzanderFlores/580a8b90ababdca81f4f84ad542264c3
------------------------------
In this video tutorial, we will learn how to create a ChatGPT bot using Discord.JS v14. We will start by logging into our OpenAI account and generating API keys. Then, we will set up our project by creating a .env file to store our Discord token and OpenAI API key.
Next, we will listen for new messages in our chatgpt channel and ensure that our bot doesn't respond to itself. We will fetch recent messages in the channel to provide context for the conversation.
To avoid exceeding the token limit set by OpenAI, we will count the tokens in our messages using a regex string. We will install the OpenAI package and create a file to handle API calls.
In our main index file, we will import the necessary files and create variables to hold messages, maximum tokens, and current tokens. We will process messages based on token count and role (bot or human).
Finally, we will call the OpenAI API and send the response to the user in Discord. We will also add a typing indicator to make the bot appear more realistic.
Watch this tutorial to learn how to create a ChatGPT bot using Discord.JS and OpenAI. Customize your bot further with buttons by checking out the next video.
------------------------------
🕒 Timestamps:
00:00 Introduction
00:31 Listening for messages from the "chatgpt" channel
01:35 Counting tokens
02:19 OpenAI Setup
03:23 Putting it all together
05:11 Replying in the channel
05:25 Making your bot type
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos.
Create a simple ChatGPT bot using Discord.JS v14 and the OpenAI API.
🧠 Learn website dashboards + bot monetization ➡ levelupyourbot.com
🔥 Source code download ➡ wornoffkeys.com/code?yt=HHtMPTnIm0M
🙋♂️ Need help? Ask in our Discord community:
wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
wornoffkeys.com/playlist/djs
💡 Request new video ideas here:
wornoffkeys.com/content-request
📺 Subsribe for new videos here:
youtube.com/@WornOffKeys?sub_confirmation=1
🔗 Regex for counting tokens:
gist.github.com/AlexzanderFlores/580a8b90ababdca81f4f84ad542264c3
------------------------------
In this video tutorial, we will learn how to create a ChatGPT bot using Discord.JS v14. We will start by logging into our OpenAI account and generating API keys. Then, we will set up our project by creating a .env file to store our Discord token and OpenAI API key.
Next, we will listen for new messages in our chatgpt channel and ensure that our bot doesn't respond to itself. We will fetch recent messages in the channel to provide context for the conversation.
To avoid exceeding the token limit set by OpenAI, we will count the tokens in our messages using a regex string. We will install the OpenAI package and create a file to handle API calls.
In our main index file, we will import the necessary files and create variables to hold messages, maximum tokens, and current tokens. We will process messages based on token count and role (bot or human).
Finally, we will call the OpenAI API and send the response to the user in Discord. We will also add a typing indicator to make the bot appear more realistic.
Watch this tutorial to learn how to create a ChatGPT bot using Discord.JS and OpenAI. Customize your bot further with buttons by checking out the next video.
------------------------------
🕒 Timestamps:
00:00 Introduction
00:31 Listening for messages from the "chatgpt" channel
01:35 Counting tokens
02:19 OpenAI Setup
03:23 Putting it all together
05:11 Replying in the channel
05:25 Making your bot type
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos.
![Discord JS - Calling APIs (2020) [Episode #53]
Learn how APIs can add new and unique features to your Discord bot.
🔥 Source code download ➡ https://wornoffkeys.com/code?yt=IF3aEg35eKA
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Introduction
00:38 Creating the cat command
03:03 Calling the API
10:32 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. Discord JS - Calling APIs (2020) [Episode #53]](https://i.ytimg.com/vi/IF3aEg35eKA/mqdefault.jpg)
![MongoDB in NodeJS - Primary Keys and Unique IDs (2020) [Episode #18]
In this video we go over what primary keys and unique IDs are and how to use our own within MongoDB in Node JS.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
🖥️ Source code:
https://github.com/AlexzanderFlores/Worn-Off-Keys-MongoDB-NodeJS
🖥️ BSON Documentation:
https://en.wikipedia.org/wiki/BSON
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Introduction
00:43 Explaining primary keys in Mongo
04:06 Outro
#mongodb #javascript #nodejs #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. MongoDB in NodeJS - Primary Keys and Unique IDs (2020) [Episode #18]](https://i.ytimg.com/vi/IRVEJDzGVmg/mqdefault.jpg)
![Discord JS Bot and API Ping/Latency Command (2020) [Episode #35]
Learn how to check the ping for your Discord bot.
🔥 Source code download ➡ https://wornoffkeys.com/code?yt=Iq0rcuafZ3k
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Introduction
00:29 Creating our ping command
03:24 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. Discord JS Bot and API Ping/Latency Command (2020) [Episode #35]](https://i.ytimg.com/vi/Iq0rcuafZ3k/mqdefault.jpg)
![How to make a Discord bot - Discord JS v13 [Ep. 1]
Learn how to create and setup your own Discord bot with Discord JS v13.
🔥 Source code download ➡ https://wornoffkeys.com/code?yt=JMmUW4d3Noc
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Creating our Discord bot and test server
04:17 Installing the necessary tools
05:30 Setting up our project (IMPORTANT)
08:24 Writing the code
15:15 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. How to make a Discord bot - Discord JS v13 [Ep. 1]](https://i.ytimg.com/vi/JMmUW4d3Noc/mqdefault.jpg)
![Discord.JS Basic Command Handler (2020) [Episode #3]
New to command handlers? This is where to start.
🔥 Source code download ➡ https://wornoffkeys.com/code?yt=JViwytLWflw
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Introduction
0:17 Creating our command utility
05:08 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. Discord.JS Basic Command Handler (2020) [Episode #3]](https://i.ytimg.com/vi/JViwytLWflw/mqdefault.jpg)

![Discord.JS v13 - WOKCommands Introduction [Ep. 5]
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Introduction
00:43 Installing WOKCommands
03:15 Making a simple command
05:40 Making a slash command
08:34 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. Discord.JS v13 - WOKCommands Introduction [Ep. 5]](https://i.ytimg.com/vi/J_fJq7zWfWE/mqdefault.jpg)
![Discord.JS v13 - Give, Remove, and Has Role Command [Ep. 15]
Lets manage Discord roles through commands using Discord.JS.
🔥 Source code download ➡ https://wornoffkeys.com/code?yt=JfRqhrNfj_E
🧠 Learn website dashboards + bot monetization ➡ https://levelupyourbot.com
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here:
https://wornoffkeys.com/playlist/djs
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
🕒 Timestamps:
00:00 Creating our project
01:15 Creating the role command
06:28 Outro
#discordjs #discordbots #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. Discord.JS v13 - Give, Remove, and Has Role Command [Ep. 15]](https://i.ytimg.com/vi/JfRqhrNfj_E/mqdefault.jpg)


![MongoDB in NodeJS - Deleting Data (2020) [Episode #6]
In this video we go over how to delete data within MongoDB.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
🖥️ Source code:
https://github.com/AlexzanderFlores/Worn-Off-Keys-MongoDB-NodeJS
🙋♂️ Need help? Ask in our Discord community:
https://wornoffkeys.com/discord
💡 Have an idea for a video or course? Request it here:
https://wornoffkeys.com/content-request
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
🕐 Timestamps:
00:00 Introduction
00:33 Using deleteOne
01:57 Using deleteMany
02:58 Outro
#mongodb #javascript #nodejs #wornoffkeys
FTC Legal Disclaimer - Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos. MongoDB in NodeJS - Deleting Data (2020) [Episode #6]](https://i.ytimg.com/vi/KvaBCnP3tTY/mqdefault.jpg)