How to Create a Bot on Discord (with Pictures)

Table of contents:

How to Create a Bot on Discord (with Pictures)
How to Create a Bot on Discord (with Pictures)

Video: How to Create a Bot on Discord (with Pictures)

Video: How to Create a Bot on Discord (with Pictures)
Video: How to Use Kik Messenger 2024, December
Anonim

Discord is a popular chat program that gamers often use and love. Discord users can create their own Discord channel for free and invite people to join the channel. Some people use bots on Discord to play music, greet new users on the channel, and more. This wikiHow teaches you how to create a bot for Discord. However, you should at least be a bit familiar with coding because bots work via JavaScript.

Step

Part 1 of 6: Preparing the Computer

Create a Bot in Discord Step 1
Create a Bot in Discord Step 1

Step 1. Download Node.js from

Node.js is the free JavaScript runtime you need to build bots. You can choose the installation file for Windows or MacOS, as well as the version you want. For this process, it is recommended that you choose the LTS version.

Create a Bot in Discord Step 2
Create a Bot in Discord Step 2

Step 2. Run the installation file

On a Windows computer, simply click the downloaded file to run the installation. On a Mac, you will need to extract the files and find the application/installation file. Make sure you read all the agreements before doing the installation.

Create a Bot in Discord Step 3
Create a Bot in Discord Step 3

Step 3. Create a Discord account (optional)

If you don't have a Discord account yet, you can create one at

Create a Bot in Discord Step 4
Create a Bot in Discord Step 4

Step 4. Sign in to your Discord account and channel

Open the Discord application on your computer and open the channel you want to add the bot to.

Part 2 of 6: Creating Bots on Discord

Create a Bot in Discord Step 5
Create a Bot in Discord Step 5

Step 1. Visit https://discord.com/developers/applications/me via a web browser

You may already be able to access your account through the app, but log back in if prompted. In this section, you create a bot-enabled application. This means you will be building apps and bots.

Create a Bot in Discord Step 6
Create a Bot in Discord Step 6

Step 2. Click the blue New Application button

It's on the right side of your browser. A pop-up window for your app name will appear.

Type in the name of the application and click “Create”. Choose a descriptive name (e.g. "Greeterbot") if your app's bot works to greet users. However, a name like "Greeterbot" can trigger errors because it is such a popular name. Therefore, add a string of numbers to the end of the name (eg "Greeterbot38764165441")

Create a Bot in Discord Step 7
Create a Bot in Discord Step 7

Step 3. Click Bots on the left menu

This menu is indicated by a jigsaw puzzle piece icon.

Create a Bot in Discord Step 8
Create a Bot in Discord Step 8

Step 4. Click Add Bot

This button is below the “Build-A-Bot” heading.

  • Click “Yes, do it!” in the pop-up window to confirm the action.
  • If you get an error message about a name that is too popular, go back to the application page and change the name. For example, the name “Music Bot” was deemed too popular. However, you can add some numbers to the end of the app name.
Create a Bot in Discord Step 9
Create a Bot in Discord Step 9

Step 5. Click Click to Reveal Token

This post is in the bot information area. When the text is clicked, you can see a series of letters and numbers.

Click “Copy” to copy all the text. You can paste it on a sticky note or note app, but make sure you can access the code and don't give it to anyone. Anyone with the code can control the bot. The code will always be displayed on this page when you need it

Part 3 of 6: Sending Bots to Discord Server Servers or Channels

Create a Bot in Discord Step 10
Create a Bot in Discord Step 10

Step 1. Click General Information

It's in the menu on the left side of the screen.

Create a Bot in Discord Step 11
Create a Bot in Discord Step 11

Step 2. Click Copy under the “Client ID” section

This option is in the middle of the web page.

Create a Bot in Discord Step 12
Create a Bot in Discord Step 12

Step 3. Paste the ClientID you copied into the following URL:

“https://discord.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=8”

For example, if your ClientID is “000000000000000001”, the URL will look like:

Create a Bot in Discord Step 13
Create a Bot in Discord Step 13

Step 4. Paste the URL into the address bar of the browser

You will be taken to a new page that will allow you to add bots to your channel.

  • Click the drop-down box to display all compatible channels.
  • Click “Authorize” to continue. You will get a confirmation message that the bot has been added and the active tab can be closed.

Part 4 of 6: Coding Bots

Step 1. Create a folder for bot codes on the desktop

You will create code files that will later be added to the folder.

  • The code shown in this article is taken from
  • You can search the internet for other bot codes if you want, such as codes for playing music continuously. This wikiHow uses sample code for bots that respond to text or commands that start with "!"

Step 2. Open a text editing program

You can use a lower-end text-editing program like Notepad for Windows, or TextEdit for Mac.

Step 3. Enter the following code:

    { “token”: “Your Bot Token” }

  • Make sure you enter the Bot Token number obtained from the previous steps in quotation marks in the code text.

Step 4. Save the file as “auth.json”

Make sure the file is not saved with a.txt extension.

Step 5. Create a new document

You can create one by pressing the shortcut Ctrl+N (Windows) or Cmd+N (Mac), or clicking the “New” option from the “File” tab.

Step 6. Type the following code:

    { “name”: “greeter-bot”, “version”: “1.0.0”, “description”: “My First Discord Bot”, “main”: “bot.js”, “author”: “Your name”, “dependencies”: {} }

  • Make sure you replace the “Your Name” entry with your name. You can also change the “description” entry if you don't want to use “My First Discord Bot.”

Step 7. Save the file as “package.json”

Make sure the file is not saved with a.txt extension.

Step 8. Create a new document

You can create one by pressing the shortcut Ctrl+N (Windows) or Cmd+N (Mac), or clicking the “New” option from the “File” tab.

Step 9. Type in the bot code

For example, if you want to create a bot that responds to messages or commands that begin with the "!" symbol, type the following code:

    var Discord = require('discord.io'); var logger = require('winston'); var auth = require('./auth.json'); // Configure logger settings logger.remove(logger.transports. Console); logger.add(new logger.transports. Console, { colorize: true }); logger.level = 'debug'; // Initialize Discord Bot var bot = new Discord. Client({ token: auth.token, autorun: true }); bot.on('ready', function (evt) { logger.info('Connected'); logger.info('Logged in as: '); logger.info(bot.username + ' - (' + bot.id + ')'); }); bot.on('message', function (user, userID, channelID, message, evt) { // Our bot needs to know if it will execute a command // It will listen for messages that will start with `!` if (message.substring(0, 1) == '!') { var args = message.substring(1).split(' '); var cmd = args[0]; args = args.splice(1); switch(cmd) { // !ping case 'ping': bot.sendMessage({ to: channelID, message: 'Pong!' }); break; // Just add any case commands if you want to. } } });

Create a Bot in Discord Step 14
Create a Bot in Discord Step 14

Step 10. Save the file as “bot.js”

Make sure the file is not saved with a.txt extension.

You can close your text-editing program at this point

Part 5 of 6: Installing a Support Bot

Create a Bot in Discord Step 15
Create a Bot in Discord Step 15

Step 1. Open a Command Prompt window

On Windows, you can use the keyword "Cmd" in the Windows search field in the "Start" menu. On a Mac, you can search for “Command Prompt” through Spotlight.

Create a Bot in Discord Step 16
Create a Bot in Discord Step 16

Step 2. Access the bots folder on the desktop

For example, you could type cd\Users\Default Desktop\Desktop\FolderDiscordBotName.

Create a Bot in Discord Step 17
Create a Bot in Discord Step 17

Step 3. Type npm install discord.io winston –save and press Enter

Once Node.js is installed, this command line will automatically download the support or dependency for the bot to the desktop folder.

Create a Bot in Discord Step 18
Create a Bot in Discord Step 18

Step 4. Type in npm install and press Enter.

The code will ensure that there are no other elements or programs that you need to install for the bot to work.

Now you have the code for the bot and will test that the code can work in the next method

Part 6 of 6: Running the Bot

Create a Bot in Discord Step 19
Create a Bot in Discord Step 19

Step 1. Type in node bot.js and press Enter in the Command Prompt window

If you get an error message, you are doing something wrong with the bot code.

Create a Bot in Discord Step 20
Create a Bot in Discord Step 20

Step 2. Type “!Intro” into Discord

Enter the command on the channel that contains the bot. The sample code shown in this article instructs the bot to respond to commands or posts that begin with the symbol “!” with the word "Pong!". To test if the bot is working, type “!Intro” and wait for a reply or response from the bot.

Create a Bot in Discord Step 21
Create a Bot in Discord Step 21

Step 3. Check the code if you get no response

If the bot doesn't respond to the "!Intro" message on Discord, re-read this wikiHow and make sure the bot is set up properly. In addition, make sure:

  • Node.js installed correctly.
  • The Bot Token is correctly inserted in the auth.json file.
  • You are on the same channel as bot
  • The bot is already on the server.
  • The code included in the auth.json, bot.js, and package.json files is correct.
  • You have downloaded all the supports or dependencies for the bot to work using the Command Prompt (after Node.js is installed).

Recommended: