Create & Build Your Own Discord Bot

Discord is a well-known voice and text chat application that is utilized by gamers, open-source groups, and conference organizers. Its popularity has grown as a result of features such as superior audio chat, several text channels, and extensibility through automated assistants or “Kahoot smasher bots

Create & Build Your Own Discord Bot

This article will walk you through the process of developing a Discord bot in Python and deploying it on an Ubuntu 20.04 server. You’ll be programming your bot using the Discord Python package, discord.py.

Requirements

To finish this lesson, you will need the following:

One server running Ubuntu 20.04 with a sudo non-root user and a firewall. This may be accomplished by following our Ubuntu 20.04 first server configuration instructions.
Python3 should already be installed on your local system. For precise instructions, see one of our Python installation guides for Windows, Mac, or Linux.
A Discord account and an admin-level Discord guild. To download the app and create a free account, visit [Discord’s Getting Started]((https://support.discord.com/hc/en-us/articles/360033931551-Getting-Started)) page. Then establish a Guild. If you form your own Discord Guild, you will have the appropriate rights to add a bot. * Your preferred text editor, such as Visual Studio Code, Atom, Sublime, or Nano.
Step 1 — Creating a Discord Guild Bot User
You must first build and register your bot in the Discord developer site before you can begin coding.

To begin, log in to the developer portal and select the New Application icon. A Discord application provides access to the Discord API. Bots are application-specific; this is how they operate.

To create a new application, click the New Application Button.

See also  How To Start Your Own Daycare Business

Then, in the modal, give the application a name and click the Create button. For the sake of this lesson, we’ll call ours SammySharkBot.

Your Application’s Name

Discord will automatically generate your application. Following that, you’ll see a page containing information about your bot. You may opt to use a photo as the bot’s symbol. In the App Icon area of the page, click the Choose a Neat Icon option. This is not necessary.

Optionally, provide an icon for your bot.

If you did upload an icon, a dialog box requesting you to save your modifications would appear. To save your icon, click Save Changes.

Conserve your modifications

After you’ve created your application, it’s time to construct a bot to go along with it. Navigate to the Bot link in the left-hand Navigation pane of the screen.

Incorporate a bot into your application

To add the bot to your application, click the Add Bot button.

Confirm the bot’s creation

After you’ve done so, a Bot with the optional icon you specified before will display. Keep this page in mind; you’ll need it later to get the API Token.

Confirmation page for bot

You’ll be greeted with a window that reads Adding a bot user provides visibility for your app on Discord. This action, however, is irreversible! Make an informed choice. Proceed and click Yes, create the bot user!

Then, on the left-hand side of the screen, scroll to the OAuth2 link in the Settings navigation pane. You must add the necessary permissions in order for your bot to work correctly.

See also  8 Survival skills more important than content

Navigate to the OAuth2 menu item.

You’ll need to specify the scopes within which your bot may operate. Select just the bot option, since this is all that you want this bot to accomplish. To learn more about the additional scopes, please go to the Discord OAuth2 Documentation.

Include a bot designation.

Scroll down and provide the following rights to your bot: View Channels, Send Messages, and Read Message History. This limits the actions that your bot can execute. If you wish to develop an unrestricted bot, you may choose the Administrator option; however, this is not encouraged.

Once you’ve done so, a Discord URL will display followed by a Copy button. To copy the URL and open it in a new window in your browser, click that button.

Add permissions for the bot and copy the link

A window will appear requesting that your bot connect to your Guild. Due to the possibility that you have authority to install bots in numerous Guilds, you may indicate more than one here. Click Authorize after selecting the Guild in which you desire to install your bot.

Include a bot in your Guild

Before a bot is joined to your Guild, Discord displays all of the bot’s permissions. This guarantees that you are informed of the installation process. You may uncheck any permissions that you do not want the bot to have. However, do not do so with this bot, since it will not function otherwise. Accept and add the bot to your Guild by clicking Authorize.

Authorize permissions for bots

Return to your Guild and check the channel for new member announcements. You’ll see that your bot has become a member of your Guild. Additionally, your bot will appear in the member list on the right-hand side, but it will initially seem offline; this will change once the bot code is started.

See also  More Fun Computers

Verify that your bot has joined your guild.

After adding your bot to your Guild, it’s time to bring it to life with some Python code.