How to write a bot for discord

Anonim

How to write a bot for discord

Step 1: Choosing the Topic Bott

If you create a bot for commercial purposes, but do not have a technical task, first to understand what functions are planned to be implemented at all. It can be a bot to administer, play music or entertaining with mini-games. Usually, at the stage of learning, an idea appears for implementation or is offered as a home task on courses.

An excellent source for searching for an idea is absolutely any popular site with a list of bots. On it you can set the sorting in popularity and find out what is the most popular. On project pages there is a description of the functions and principles of work, which will also help to figure out how your future bot should look.

Viewing popular projects to create a bot in Discord

As soon as the topic is selected or it is decided to copy the existing code already by editing it, proceed to writing your own bot.

Step 2: Creating a bot application

The next step is to create an application on the official portal for Discord developers. It is necessary that the bot began its existence and acquired a unique token used at the invitation. Already, the project name is selected, the installation of permits and logo.

Go to the site of Discord Developer Portal

  1. Open the link above and log in on the developer portal under the profile that you will use for the test server when you first authorize and check the bot.
  2. Authorization on the developers portal to create a bot in Discord

  3. Once on the main page, click on the "New Application" button.
  4. Transition to the creation of a new application on the developers portal to create a bot in Discord

  5. Enter your name and confirm the creation.
  6. Creating a new application on the developers portal to create a bot in Discord

  7. Expand the menu of the site by pressing the button with three horizontal lines.
  8. Opening the menu on the developers portal to create a bot in Discord

  9. In the "SETTINGS" block, select "Bot".
  10. Go to the section with a bot parameters on the developer portal to create a bot in Discord

  11. Confirm the construction of a new bot for the application.
  12. Button to create a new bot on the site of the developer portal to create a bot in Discord

  13. In the pop-up window, click on "Yes, Do IT!".
  14. Notification with confirmation of the creation of a new application on the developer portal to create a bot in Discord

  15. At this stage, you can change the name of the bot and download it to the avatar if it is ready. Please note that the in the same section is also a token with the "Copy" button, which is responsible for copying it to the clipboard. This action will have to do more than once during operation with the project code.
  16. The main parameters of the created application for creating a bot in Discord

  17. Expand the menu again and go to the OAuth2 section.
  18. Transition to the choice of type of additional application on the developer portal to create a bot in Discord

  19. In the SCOPES parameter list, find the "Bot" item and mark it with a check mark.
  20. Select the type of application used on the developer portal to create a bot in Discord

  21. Immediately find another block with the name "Bot Permissions". Activate all permissions, pushing out the actions performed by this bot.
  22. Adding permissions to create a bot in Discord

  23. Do not forget about permissions for text and voice channels. However, they will not be needed to activate if the administrator's right to immediately provide the application.
  24. Choosing other permissions for custom applications on the developer portal to create a bot in Discord

  25. Raise the "Scopes" block again and copy the automatically generated link to the bike authorization.
  26. Link to the first bike authorization on the server to create a bot in Discord

  27. Scroll through it and select the server to add an application.
  28. Authorization on the server to create a bot in Discord

  29. Confirm the provision of appropriate rights (all permissions marked with checkboxes are displayed in the window. Click "Authorize" to go to the next step.
  30. View a list with available permissions to create a bot in Discord

  31. Enter the captcha to complete the procedure.
  32. Confirmation of captcha at first authorization to create a bot in Discord

  33. Scroll to the server and make sure that the bot is now displayed in the list of participants. Now he is offline, because its code has not yet been written.
  34. Checking the list of participants of the selected server to create a bot in Discord

Step 3: Select Development Environment

It's time to do the hardest stage of creating a bot - writing code. To do this, select one of the supported programming languages. Most often use JavaScript with an extension in the form of Node.js or Python. The selection depends exclusively on your knowledge or in which format is the botline of the bot, if it comes to copying it to further refinement. For different languages, various development environments are needed with syntax support and additional useful features. You can learn about the most popular of these in the articles on the links below.

Read more:

Selecting the development environment for programming

Text editors for Windows

Selecting a development environment while writing a code to create a bot in Discord

Step 4: Writing Code

There are many different lessons and demonstrations of how to write bots to Discord a different level of complexity. There are even whole projects for playing music or administration, so sometimes banal copying sometimes. However, if you decide to write the code yourself, you need to master Python or JavaScript.

Using Python Programming Language To create a bot in Discord

In another article, we described in detail about how the basis of the bot is created and basic commands are added, breaking the two mentioned programming languages ​​at once. You only have to choose the best and understand how the principles create files and write their contents.

Read more: Writing a bot in Discord

Using JavaScript Programming Language To create a bot in Discord

Step 5: Distribution of Bot

Simply, no one will know about your bot, because he is simply missing on the network. If the creation occurs solely for a personal project, the promotion is not needed, but it is often pursued by the goal of earning a bot. Open sites are considered the best means of distribution, where you can download it for free or by subscription to download your bot, thus opening it to search. We will analyze this on the example of one popular site.

  1. At first, you will need to authorize through the discord account by clicking "Login".
  2. Authorization on the selected site to promote the bot in Discord

  3. When a new tab appears, confirm the action using the "Authorize" button.
  4. Confirmation of authorization on the selected site to promote the bot in Discord

  5. On the main file page, find the section responsible for adding a bot.
  6. Transition to the adding project section to promote the bot in Discord

  7. Enter its ID by defining this parameter through the Discord Developer Portal, which we have already written earlier.
  8. Enter the name of the project to promote the bot in Discord

  9. Be sure to specify the prefix used.
  10. Choosing a Project Prefix for Bot Promotion in Discord

  11. Add a description, specify the tags and other parameters affecting the display of the bot's page on the site.
  12. Filling out the basic information on the site to promote the bot in Discord

  13. If the invitation link is already there, insert it into the appropriate field or go to "Invite Generator" to generate it.
  14. Insert Invitation Links on the site to promote the bot in Discord

  15. Check the correctness of the data entered and click on "Submit".
  16. Confirmation of adding a project to promote the bot in Discord

The principle of basic actions is approximately the same on all sites for monitoring bots and servers, the difference lies only that some allow free to place their own projects and promote them to the top for a fee, while others require the acquisition of a subscription at the project registration stage. Here are already focusing on your own preferences and formed advertising budget.

Step 6: Placing a bot on VPS

It will not be able to work constantly on a local computer - sooner or later the operating system will go on a reboot, which means it will turn off and the bot, since the "command line" will close with the application. All large-scale projects are connected to the VPS with the support of the programming language used. If you are at the level when you need to use such services, explain the principle of their work no longer makes sense, because the necessary knowledge is most likely already acquired. Instead, we recommend always to pay attention to the support of the selected Yap and, if possible, use the test period to check the work of the bot on the selected VPS. Do not forget that there are support services on such sites, whose specialists are quickly responsible for any questions. After connecting the bot to the VPS, it will always be in active condition and you do not have to store it with files on the local PC.

Using the VPS to ensure the battery permanent operation in Discord

Read more