{"id":92397,"date":"2023-08-25T12:41:47","date_gmt":"2023-08-25T12:41:47","guid":{"rendered":"\/tutorials\/?p=92397"},"modified":"2026-01-13T12:09:59","modified_gmt":"2026-01-13T12:09:59","slug":"how-to-host-discord-bot","status":"publish","type":"post","link":"\/tutorials\/how-to-host-discord-bot","title":{"rendered":"How to Host a Discord Bot: Making and Deploying Your Own Bot to VPS"},"content":{"rendered":"<p>Adding bots to your Discord server lets you automate tasks and add new features. While there are many popular Discord bots that are ready to use, you may need to create one for your specific needs.<\/p><p>In this article, we will explain how to host a discord bot with Hostinger&rsquo;s virtual private server hosting plan. First, we will explore the steps to develop your own Discord bot from scratch.<\/p><p>Then, we will explain how to purchase a VPS hosting plan from Hostinger and configure the server environment for your Discord bot. Moreover, you will learn about Discord bot performance optimization and monitoring.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/public\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-make-a-discord-bot\">How to Make a Discord Bot<\/h2><p>Hosting your own Discord bot that is tailored to your preferences requires it to be developed manually. The steps may differ depending on your bot&rsquo;s functionality and programming language, but the general procedure is similar.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-create-a-discord-bot-account\">1. Create a Discord Bot Account<\/h3><p>To start making a Discord bot, create a <a href=\"https:\/\/discord.com\/developers\/\" target=\"_blank\" rel=\"noreferrer noopener\">Developer Portal<\/a> account. In this platform, you will create the bots, manage their settings, and generate the authentication link for inviting them to your Discord server.<\/p><p>To create a Discord account, go to the <a href=\"https:\/\/discord.com\/register\" target=\"_blank\" rel=\"noreferrer noopener\">registration page<\/a>. You will automatically log in to the new Discord account if you open the Developer Portal. Then, follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>On the sidebar, click <strong>Applications<\/strong>.<\/li>\n\n\n\n<li>Select <strong>New Application <\/strong>in the right corner.<\/li>\n\n\n\n<li>Enter your <strong>bot name<\/strong> and check the <strong>privacy policy box<\/strong>. Click <strong>Create<\/strong>.<\/li>\n\n\n\n<li>Change the <strong>App Icon<\/strong>. Enter the <strong>Description <\/strong>and <strong>Tags<\/strong>. Click <strong>Save Changes <\/strong>to confirm.<\/li>\n\n\n\n<li>Copy the <strong>Application ID<\/strong> and save it to your computer. We need it later to enable Developer Mode.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\"><img decoding=\"async\" width=\"1024\" height=\"342\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\/public\" alt=\"Discord Developer Portal's application management page\" class=\"wp-image-92435\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-development-portal-application-management-page.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Then, configure your bot token &ndash; an authentication key that enables your application to communicate with the Discord bot API. Here&rsquo;s how to do it:<\/p><ol class=\"wp-block-list\">\n<li>Navigate to the sidebar &rarr; <strong>Bot<\/strong>.<\/li>\n\n\n\n<li>Change your bot <strong>username.<\/strong><\/li>\n\n\n\n<li>Click <strong>Reset Token<\/strong>. Click <strong>Yes, do it! <\/strong>to confirm.<\/li>\n\n\n\n<li>Copy the<strong> bot token<\/strong> and save it to your computer.<\/li>\n<\/ol><p>We&rsquo;ll insert this token into the bot&rsquo;s source code. Also, keep the code safe since leaking it may expose your bot and Discord server to security risks.<\/p><p>Now, enable the Developer Mode to bypass your Discord bot SKUs-related payment. Here&rsquo;s how to do it:<\/p><ol class=\"wp-block-list\">\n<li>Log in to your <strong>Discord <\/strong>application &rarr; <strong>User settings <\/strong>&rarr; <strong>Advanced<\/strong><\/li>\n\n\n\n<li>Toggle the <strong>Developer Mode<\/strong> on.<\/li>\n\n\n\n<li>Enable the <strong>Application Test Mode<\/strong> switch<\/li>\n\n\n\n<li>Enter your <strong>Application ID<\/strong>. Set the <strong>URL Origin Type<\/strong> as <strong>Localhost<\/strong> and <strong>Port Number<\/strong> as <strong>8080<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Activate<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\"><img decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\/public\" alt=\"The Developer Mode switch in the Discord application\" class=\"wp-image-92438\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/developer-mode-switch-in-discord.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-2-set-bot-permissions\">2. Set Bot Permissions<\/h3><p>After setting up the application, configure your Discord bot account permissions and authentication method. Here&rsquo;s how to do it:<\/p><ol class=\"wp-block-list\">\n<li>On the <strong>Applications<\/strong> page, select <strong>OAuth2 &rarr; General <\/strong>from the sidebar.<\/li>\n\n\n\n<li>Under the <strong>Default Authorization Link<\/strong>, select <strong>In-app Authorization <\/strong>as the method.<\/li>\n\n\n\n<li>Check the <strong>bot <\/strong>box.<\/li>\n\n\n\n<li>Select the <strong>Bot Permissions<\/strong> according to your needs.<\/li>\n\n\n\n<li>Click <strong>Save changes<\/strong>.<\/li>\n\n\n\n<li>Navigate to the sidebar &rarr; <strong>OAuth2 &rarr; URL Generator<\/strong>.<\/li>\n\n\n\n<li>Check <strong>bot <\/strong>as your application&rsquo;s scope.<\/li>\n\n\n\n<li>Recheck the same boxes for the <strong>Bot Permissions<\/strong>.<\/li>\n\n\n\n<li><strong>Copy<\/strong> the <strong>Generated URL <\/strong>and save it to your computer. It should contain your bot&rsquo;s <strong>Client ID<\/strong>.<\/li>\n<\/ol><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> Avoid giving a bot Administrator permissions, as it can modify your server settings.<\/p><\/div>\n\n\n\n<\/p><p>In addition, go to the <strong>Bot <\/strong>section from the sidebar and grant the bot <strong>Privileged Gateway Intents<\/strong>. Enable all intents if you are unsure which one your bot will use. However, keep in mind that it will grant the bot access to various Discord data.<\/p><p>Now, open the authentication link<strong> <\/strong>using a web browser to invite the bot to your Discord server and grant the necessary permissions.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\"><img decoding=\"async\" width=\"1024\" height=\"518\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\/public\" alt=\"The Discord bot invitation page\" class=\"wp-image-92440\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/discord-bot-invitation-page.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>From the dropdown menu, select the server you want to add the bot into and click <strong>Continue<\/strong>. Review the permissions you will grant to the bot. If you wish to revoke any of them, uncheck the boxes. Then, click <strong>Authorize <\/strong>to confirm.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-choose-a-programming-language\">3. Choose a Programming Language<\/h3><p>JavaScript and Python are popular programming languages for creating a Discord Bot. While you can use C++, the available Discord API wrappers only support these languages.<\/p><p>Discord API wrappers simplify the interaction between the software and your code, making the development easier. Since the language and wrapper don&rsquo;t affect your bot&rsquo;s functionality, choose one based on your familiarity and preferences.<\/p><p>For a beginner, we recommend using Python, one of the simplest and <a href=\"\/tutorials\/best-programming-languages-to-learn\">best programming languages to learn<\/a>. It is easier to read and maintain than JavaScript, simplifying the debugging process. We will also use Python for this tutorial.<\/p><p>Before proceeding, <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">download Python<\/a> and a code editor. When choosing a code editor, pick one with features that help simplify your coding process, like syntax highlighting, auto-completion, error detection, and module integration.<\/p><p>We recommend <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Visual Studio Code<\/a> as it is free and offers various features.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-code-the-bot\">4. Code the Bot<\/h3><p>Once the software and tools are ready, create a folder for your Discord bot files. Then, open VSCode to access the folder and create working files:<\/p><ol class=\"wp-block-list\">\n<li>Click <strong>File &rarr; Open Folder<\/strong><\/li>\n\n\n\n<li>Navigate to your new folder directory. Select the folder and click <strong>Select Folder<\/strong>.<\/li>\n\n\n\n<li>Go to the <strong>Explorer<\/strong> sidebar and click the <strong>add new file icon<\/strong>.<\/li>\n\n\n\n<li>Create a <strong>main.py <\/strong>file to store all your bot codes. For an advanced bot, you may need multiple files and that are linked to <strong>main.py<\/strong>.<\/li>\n\n\n\n<li>Create a <strong>.env <\/strong>file to store your bot token. Your Python code will call this file to authenticate the connection to the Discord API.<\/li>\n<\/ol><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> Leave the <strong>.env<\/strong> file name blank. Otherwise, the bot code won&rsquo;t find it and read the environment variable.<\/p><\/div>\n\n\n<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\"><img decoding=\"async\" width=\"1460\" height=\"810\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/public\" alt=\"Visual Studio Code user interface\" class=\"wp-image-92441\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/visual-studio-code-user-interface.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><\/a><\/figure><\/div><p>Depending on your Discord bot functionality, the code differs. For this tutorial, we will show you how to make a Discord bot that replies to a simple command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Import the required modules\nimport discord\nimport os\nfrom discord.ext import commands \nfrom dotenv import load_dotenv\n\n# Create a Discord client instance and set the command prefix\nintents = discord.Intents.all()\nclient = discord.Client(intents=intents)\nbot = commands.Bot(command_prefix='!', intents=intents)\n\n# Set the confirmation message when the bot is ready\n@bot.event\nasync def on_ready():\n    print(f'Logged in as {bot.user.name}')\n# Set the commands for your bot\n@bot.command()\nasync def greet(ctx):\n    response = 'Hello, I am your discord bot'\n    await ctx.send(response)\n\n@bot.command()\nasync def list_command(ctx):\n    response = 'You can use the following commands: \\n !greet \\n !list_command \\n !functions'\n    await ctx.send(response)\n\n@bot.command()\nasync def functions(ctx):\n    response = 'I am a simple Discord chatbot! I will reply to your command!'\n    await ctx.send(response)\n\n# Retrieve token from the .env file\nload_dotenv()\nbot.run(os.getenv('TOKEN'))<\/pre><p>Here is the explanation of how the code snippet works:<\/p><ul class=\"wp-block-list\">\n<li>The<strong> import <\/strong>keywords retrieve code from a module and add it to your bot&rsquo;s file, allowing you to use a function without writing it manually. For example, we import the <strong>Discord.py<\/strong> library to enable the<strong> bot.command<\/strong> decorator.<\/li>\n\n\n\n<li>We define the variables the code will use. In our case, they are the Discord bot <strong>intents<\/strong>, <strong>client<\/strong>, and <strong>bot<\/strong>.<\/li>\n\n\n\n<li>The <strong>@bot.event<\/strong> decorator defines events that trigger the coroutine function. In the snippet, we instruct the bot to print a confirmation message once it runs successfully.<\/li>\n\n\n\n<li>The <strong>@bot.command <\/strong>decorator sets the command that triggers the bot. We also determine how and when the bot responds.<\/li>\n\n\n\n<li>The <strong>load_dotenv <\/strong>function reads the environment variable from the <strong>.env <\/strong>file. In this case, it retrieves the token.<\/li>\n\n\n\n<li>Using the <strong>os.getenv <\/strong>method, the code extracts the token value and uses it to run the bot with the <strong>bot.run <\/strong>decorator.<\/li>\n<\/ul><p>In addition to responding to commands, you can add advanced features such as voice control or input field. To learn more about the functions, read the <a href=\"https:\/\/discordpy.readthedocs.io\/en\/stable\/\" target=\"_blank\" rel=\"noreferrer noopener\">discord.py documentation<\/a>.<\/p><p>On the <strong>.env <\/strong>file, paste the following snippet. Replace <strong>yourtoken<\/strong> with the authentication key:<\/p><pre class=\"wp-block-preformatted\">TOKEN=yourtoken<\/pre><p>To check whether your code runs properly, click the <strong>Run Python File <\/strong>button on the top right of VSCode. However, you must install the dependencies to run the bot.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>If you are in a team environment and are continuously updating the Discord bot, we recommend creating a Git repository to simplify the development process. Read our <a href=\"\/tutorials\/git\">Git tutorials<\/a> to learn more about it.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-host-a-discord-bot\">How to Host a Discord Bot<\/h2><p>Host your Discord bot to make it accessible 24\/7. For this tutorial, we will use a Hostinger VPS hosting plan running <strong>Ubuntu 22.04<\/strong>. For other hosting service providers and operating systems, the steps may differ.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-get-vps-hosting\">1. Get VPS Hosting<\/h3><p>While you can create a Discord bot hosting server on your local computer, the system must run 24\/7. It can cause hardware damage in the long run and requires much effort to manage.<\/p><p>A Discord bot hosting service like a <a href=\"\/tutorials\/what-is-vps-hosting\">VPS is<\/a> more convenient and time-efficient. The provider manages the server, allowing you to focus on developing and optimizing your bot.<\/p><p>However, choosing one can be difficult since various providers offer Discord bot hosting servers. To pick the best VPS hosting for Discord bots, consider their features, security, uptime, and price.<\/p><p>Check out our <a href=\"\/tutorials\/best-vps-hosting\">10 best VPS hosting providers<\/a> tutorial to learn more about the options. For instance, Hostinger offers <a href=\"\/vps-hosting\">VPS hosting plans<\/a> starting at <strong>$6.49\/month<\/strong> with various features:<\/p><ul class=\"wp-block-list\">\n<li><strong>Snapshot<\/strong>. Users can capture their server&rsquo;s current state for easy restoration.<\/li>\n\n\n\n<li><strong>Reliable hardware. <\/strong>Hostinger VPS uses SSD storage and a high-performance CPU to ensure optimal performance and uptime.<\/li>\n\n\n\n<li><strong>Multiple data centers<\/strong>. Hostinger users can choose from <a href=\"https:\/\/support.hostinger.com\/en\/articles\/1583267-where-are-hostinger-servers-located\" target=\"_blank\" rel=\"noopener\">various data center locations<\/a> to minimize latency.<\/li>\n\n\n\n<li><strong>DDoS protection<\/strong>. Our VPS uses a firewall and built-in traffic filtering for DDoS protection.<\/li>\n\n\n\n<li><strong>SSH support<\/strong>. Users can connect to their VPS using <a href=\"\/tutorials\/ssh-tutorial-how-does-ssh-work\">secure shell protocol<\/a> (SSH) to efficiently manage their remote server.<\/li>\n\n\n\n<li><strong>FTP access<\/strong>. All Hostinger VPS plans support FTP, allowing users to easily transfer files between systems.<\/li>\n\n\n\n<li><strong>Dedicated IP<\/strong>. Users get a dedicated IP address to eliminate Cloudflare and Discord server rate limiting.<\/li>\n<\/ul><p>As different servers invite your bot, you need more resources to handle the requests. At Hostinger, our VPS plans are also easily upgradable to ensure your Discord Bot scalability.<\/p><p>After you buy a hosting plan from Hostinger, select your new server from the <strong>VPS<\/strong> menu on the top bar. Then, complete the Hostinger VPS setup process via <strong>hPanel<\/strong>, our custom-made intuitive control panel.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-2-configure-the-vps-environment\">2. Configure the VPS Environment<\/h3><p>Discord bot deployment on VPS requires setting up the hosting environment to ensure the necessary software is installed. The software differs depending on your bot&rsquo;s language and functionality.<\/p><p>For a <strong>Discord.js<\/strong> bot, install<strong> <\/strong><a href=\"\/tutorials\/what-is-node-js\"><strong>Node.js<\/strong><\/a> and <strong>Node Package Manager<\/strong>. Meanwhile, here is what you need for a Python one:<\/p><ul class=\"wp-block-list\">\n<li><strong>Python interpreter<\/strong>. An environment that converts your Python code into a machine-readable format, allowing your Discord bot to run.<\/li>\n\n\n\n<li><strong>Pip package manager<\/strong>. A package management system used to install modules and dependencies for your Python application.<\/li>\n\n\n\n<li><strong>Virtualenv<\/strong>.<strong> <\/strong>A tool for creating an isolated virtual private environment for your Python application. It lets you avoid installing the Python packages globally, which may break other projects.<strong><\/strong><\/li>\n<\/ul><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Before proceeding, read our <a href=\"\/tutorials\/linux-commands\">Linux Commands tutorial<\/a> to learn more about their functions.<\/p>\n                <\/div>\n\n\n\n<\/p><p>To install the components, connect to your server <a href=\"\/tutorials\/how-to-use-putty-ssh\">using SHH applications like PuTTY<\/a> or Terminal. Hostinger users can find the login credentials at the bottom of their VPS overview menu.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e1085c461ee\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"1041\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/public\" alt=\"SSH login credentials on hPanel's VPS overview menu\" class=\"wp-image-125811\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/10\/vps-ssh-username-and-ip-address-on-hpanel.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Once connected, run the following commands to update your package manager and install the required software for hosting your Discord bot:<\/p><pre class=\"wp-block-preformatted\">sudo apt update<\/pre><pre class=\"wp-block-preformatted\">sudo apt upgrade<\/pre><pre class=\"wp-block-preformatted\">sudo apt-get install software-properties-common -y<\/pre><pre class=\"wp-block-preformatted\">sudo add-apt-repository ppa:deadsnakes\/ppa -y<\/pre><pre class=\"wp-block-preformatted\">sudo apt install python3 python3-dev python3-venv python3-pip -y<\/pre><p>Then, follow these steps to create a virtual environment for your Python project:<\/p><ol class=\"wp-block-list\">\n<li>Run this command to create a new directory to store the files:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo mkdir DiscordBot<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Change the current directory to the new folder using this command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">cd DiscordBot<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Set the new virtual environment with the <strong>venv<\/strong> argument:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo python3 -m venv .\/venv<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Activate the virtual environment using the <strong>source <\/strong>command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">source .\/venv\/bin\/activate<\/pre><p>Your command line should now start with <strong>(venv)<\/strong>. If the source command isn&rsquo;t found, navigate to the <strong>~\/DiscordBot\/venv\/bin<\/strong> directory path using the <strong>cd <\/strong>command and run the following:<\/p><pre class=\"wp-block-preformatted\">source activate<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-venv-command-line.png\"><img decoding=\"async\" width=\"564\" height=\"29\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-venv-command-line.png\/public\" alt=\" PuTTY showing the venv command line\" class=\"wp-image-92446\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-venv-command-line.png\/w=564,fit=scale-down 564w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-venv-command-line.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-venv-command-line.png\/w=150,fit=scale-down 150w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/a><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-3-upload-the-discord-bot\">3. Upload the Discord Bot<\/h3><p>After setting the virtual environment, move the token and bot files into the new directory. You can do so using the <strong><a href=\"\/tutorials\/how-to-use-rsync\">rsync<\/a> <\/strong>command, <strong>scp <\/strong>protocol, or an <strong>SFTP<\/strong> client.<\/p><p>We recommend using <a href=\"\/tutorials\/how-to-use-sftp-to-safely-transfer-files\/\">Secure File Transfer Protocol<\/a> (SFTP) as it offers a graphical user interface and is more secure than standard FTP. The visual interface makes the process simpler and beginner-friendly.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\"><img decoding=\"async\" width=\"1460\" height=\"910\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/public\" alt=\"The FileZilla SFTP client main dashboard\" class=\"wp-image-92447\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/filezilla-sftp-client-main-dashboard.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><\/a><\/figure><\/div><p>For this tutorial, we will use <strong>FileZilla <\/strong>to transfer the files via SFTP. Here are the steps:<\/p><ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/filezilla-project.org\/download.php?type=client\" target=\"_blank\" rel=\"noreferrer noopener\">Download and install <strong>FileZilla<\/strong><\/a><strong>.<\/strong><\/li>\n\n\n\n<li>Open <strong>FileZilla<\/strong>. Enter your server<strong> IP address<\/strong>, <strong>username<\/strong>, <strong>password<\/strong>, and <strong>port number<\/strong>. By default, the port number is <strong>22<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Quickconnect<\/strong>.<\/li>\n\n\n\n<li>Once connected, locate the new <strong>.\/venv<\/strong> directory under the <strong>Remote site <\/strong>tab.<\/li>\n\n\n\n<li>Drag and drop the bot files from your local computer to the remote directory.<\/li>\n<\/ol><p>Wait until the process is complete. The file transfer status is in the box under the connection tab.<\/p><p>Then, return to your SSH client or Terminal. Move to the bot directory and install all the dependencies. In this tutorial, we will install the <strong>discord.py <\/strong>wrapper and <strong>dotenv<\/strong> using this command:<\/p><pre class=\"wp-block-preformatted\">sudo pip install discord.py python-dotenv<\/pre><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>Having difficulty writing bash commands or managing your Linux VPS? Enter <a href=\"\/tutorials\/ai-prompts-for-vps-management\">AI prompts for VPS management in Hostinger VPS assistant<\/a> to easily generate commands or code.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-4-start-the-bot\">4. Start the Bot<\/h3><p>To run the bot, set the current directory to the<strong> main.py <\/strong>file location and run the following command. If you use another file name, change it accordingly:<\/p><pre class=\"wp-block-preformatted\">python3 main.py<\/pre><p>Terminal should return the confirmation message written in the bot&rsquo;s file, similar to the following:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\"><img decoding=\"async\" width=\"1158\" height=\"112\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/public\" alt=\"PuTTY showing that the Discord bot is successfully running\" class=\"wp-image-92449\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/w=1158,fit=scale-down 1158w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/putty-showing-the-discord-bot-is-running.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1158px) 100vw, 1158px\" \/><\/a><\/figure><\/div><p>If you open the Discord server where the bot is located, it will appear online. To check If your bot runs properly, enter a command, and it should reply accordingly.<\/p><p>However, this bot is only active on your current session. If you close the SSH client or Terminal, the session will end and shut down the bot. You can use different tools to keep your bot running:<\/p><ul class=\"wp-block-list\">\n<li><strong>Linux Screen<\/strong>. A tool that lets users create multiple virtual Terminals inside a session. The virtual Terminals processes run in the background after you close the session and disconnect from the server.<\/li>\n\n\n\n<li><strong><a href=\"\/tutorials\/tmux-beginners-guide-and-cheat-sheet\/\">tmux<\/a><\/strong>. Terminal Multiplexer works similarly to Screen, allowing users to create virtual sessions and run processes in the background. It is more user-friendly than Screen but lacks some features and is less stable.<\/li>\n\n\n\n<li><strong>PM2<\/strong>. A Node.js application process manager that keeps your application running constantly. It is native to JavaScript but works with other programming languages, including Python.<\/li>\n\n\n\n<li><a href=\"\/tutorials\/what-is-docker\">Docker<\/a>. A containerization tool that turns your Discord bot into a <a href=\"https:\/\/bash.cyberciti.biz\/guide\/Daemons\" target=\"_blank\" rel=\"noreferrer noopener\">daemon<\/a>. It allows your bot to run in the background and automatically reboot after a system failure.<\/li>\n<\/ul><p>In this tutorial, we will use <a href=\"\/tutorials\/how-to-install-and-use-linux-screen\/\">Linux Screen<\/a>, which is the simplest and most compatible with different environments. Here are the steps to install and use Screen to run your Discord bot on Ubuntu VPS:<\/p><ol class=\"wp-block-list\">\n<li>On Terminal or SSH application, run this command to install Screen:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt-get install screen<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Run this command to create a new session:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">screen<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Use this command in the virtual Terminal to change the working directory:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">cd \/DiscordBot\/venv<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Start your Discord bot using the following:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">python3 main.py<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Once the bot is running, press <strong>Ctrl + A + D <\/strong>to detach the Screen session.<\/li>\n<\/ol><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> For Red Hat Enterprise Linux (RHEL) derivatives like AlmaLinux and CentOS, use <strong>yum<\/strong> instead of <strong>apt<\/strong> to install Screen.<\/p><\/div>\n\n\n\n<\/p><p>Now, the session will remain running in the background after disconnecting from the server. To reconnect to Screen, open your Terminal or SSH application and enter:<\/p><pre class=\"wp-block-preformatted\">screen -r<\/pre><p>Screen lets you create multiple sessions to run other Discord bots using this command:<\/p><pre class=\"wp-block-preformatted\">screen -S session1<\/pre><p>Replace <strong>session1 <\/strong>with your session name. Use a descriptive name to help you easily identify them and their process. To list the current user&rsquo;s sessions, use the following:<\/p><pre class=\"wp-block-preformatted\">screen -ls<\/pre><h3 class=\"wp-block-heading\" id=\"h-5-monitor-and-maintain-bot-performance\">5. Monitor and Maintain Bot Performance<\/h3><p>After deploying the Discord bot, regularly monitor it to ensure optimal performance. In addition, it helps you catch potential issues quickly before they affect your bot&rsquo;s usability.<\/p><p>The first monitoring task is to enable the <strong>logging <\/strong>Python module to track your Discord bot&rsquo;s events and errors. It provides insights into your bot&rsquo;s functionality for easier debugging and troubleshooting.<\/p><p>For example, add the following code snippet to your bot file to log command execution errors in a<strong> bot.log <\/strong>file and Discord server:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Import the Python logging module\nimport logging\n# Set the logging settings\nlogging.basicConfig(level=logging.INFO,\n   format='[%(asctime)s] [%(levelname)s]: %(message)s',\n   handlers=[\n      logging.FileHandler('bot.log'),  # Save logs to a file\n      logging.StreamHandler()         # Display logs in the console\n])<\/pre><p>Then, add the following <strong>bot.event<\/strong> decorator to print the error message on your Discord server:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Set what the bot does when encountering an error\n@bot.event\nasync def on_command_error(ctx, error):\n   error_message = f&rsquo;Error occurred while processing command: {error}&rsquo;\n   logging.error(error_message)\n   await ctx.send(error_message)<\/pre><p>In addition, use tools like <a href=\"https:\/\/uptimerobot.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">UptimeRobot<\/a> for Discord bot uptime monitoring. To track its usage and activity, use an application performance monitoring (APM) tool like <a href=\"https:\/\/grafana.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Grafana<\/a>. Since each tool&rsquo;s setup process differs, check their manual for instructions.<\/p><p>Also, monitor your VPS hardware usage to ensure the bot has enough resources to perform optimally. Several important metrics to track include CPU usage, RAM consumption, storage load, and network condition.<\/p><p>If your server doesn&rsquo;t have a control panel, use Python&rsquo;s<strong> psutil<\/strong> or Linux commands like<strong> vmstat<\/strong>. These methods don&rsquo;t offer a graphical user interface (GUI), making the process complicated and not beginner-friendly.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e1085c4b64a\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"665\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/public\" alt=\"hPanel's server usage monitor\" class=\"wp-image-125819\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/08\/hpanel-server-usage-monitor.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Web hosting providers usually provide a dashboard for tracking their server usage. For example, Hostinger offers a <a href=\"https:\/\/support.hostinger.com\/en\/articles\/4725768-how-to-check-vps-resources-usage\" target=\"_blank\" rel=\"noopener\">VPS resource usage<\/a> monitor feature in <strong>hPanel<\/strong>.<\/p><p>Hostinger users can also ask the <strong>Kodee AI assistant <\/strong>to check their VPS resource usage. Simply ask, &ldquo;Summarize information about my VPS&rsquo; operating system memory, processes, interrupts, paging and block,&rdquo; and Kodee will return the resource consumption information. <\/p><p>We recommend submitting your application to a bot list website like <a href=\"https:\/\/top.gg\/\" target=\"_blank\" rel=\"noopener\">top.gg<\/a> to make it accessible to other Discord users.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Inviting bots to your Discord server lets you add new features and simplify moderation tasks. While many pre-programmed Discord bots are available, you may need to create a custom one for your particular use case.<\/p><p>In this article, we have explained the steps to create and host a Discord bot on Linux VPS. Here is the recap:<\/p><ol class=\"wp-block-list\">\n<li>Create a Discord account and application in the developer portal.<\/li>\n\n\n\n<li>Set the bot permissions and invite it to your Discord server.<\/li>\n\n\n\n<li>Choose a programming language and IDE.<\/li>\n\n\n\n<li>Write your Discord bot code.<\/li>\n\n\n\n<li>Purchase a Discord bot hosting service, like Hostinger&rsquo;s VPS.<\/li>\n\n\n\n<li>Install dependencies to configure the hosting server environment.<\/li>\n\n\n\n<li>Upload the bot and token files via SFTP.<\/li>\n\n\n\n<li>Start your Discord bot and use Screen to keep it running 24\/7.<\/li>\n\n\n\n<li>Monitor and maintain the bot&rsquo;s performance.<\/li>\n<\/ol><p>We hope this article helped you develop and host your Discord bot. If you have any questions, leave a comment below. Good luck!<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-host-a-discord-bot-faq\">How to Host a Discord Bot FAQ<\/h2><p>In this section, we will answer several common questions about custom Discord bot development and hosting.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1692942992326\"><h3 class=\"schema-faq-question\">What Is a Discord Bot?<\/h3> <p class=\"schema-faq-answer\">Discord bots are applications you can invite to your server to run specific tasks. Popular examples include scheduling, moderation, and music bots.&nbsp;Bot list websites like <a href=\"http:\/\/top.gg\" target=\"_blank\" rel=\"noreferrer noopener\">top.gg<\/a> have pre-built ones ready to use. However, you may want to make and host your own Discord bot from scratch.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1692943004499\"><h3 class=\"schema-faq-question\">How Do I Choose the Right VPS Hosting for My Discord Bot?<\/h3> <p class=\"schema-faq-answer\">To pick the right Discord bot hosting service, consider its server resources, security, customer service, and built-in features.&nbsp;For example, Hostinger VPS offers features like 24\/7 support, SSH support, and DDoS protection. It has a 99.9% uptime guarantee to ensure your Discord bot is constantly running.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1692943005498\"><h3 class=\"schema-faq-question\">What Programming Language Should I Use to Build My Discord Bot?<\/h3> <p class=\"schema-faq-answer\">You can code a Discord bot using JavaScript or Python. Since the language doesn&rsquo;t affect the bot&rsquo;s functionality, choose one according to your expertise and preferences.&nbsp;For beginners, we recommend Python as it is easier to learn, read, and maintain than JavaScript, simplifying the bot development process.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1692943013470\"><h3 class=\"schema-faq-question\">Can I Run Multiple Discord Bots on the Same Server?<\/h3> <p class=\"schema-faq-answer\">Yes, you can host multiple bots on the same server so long as it has sufficient storage and processing power. Otherwise, your bots will slow down or become offline.&nbsp;In addition, you may need to use a container or virtual environment to avoid incompatibility issues between bots.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Adding bots to your Discord server lets you automate tasks and add new features. While there are many popular Discord [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-host-discord-bot\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":87036,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Host a Discord Bot","rank_math_description":"Check this article to learn how to host your own Discord Bot: 1. Get a VPS hosting 2. Configure the VPS 3. Upload the Discord bot + more.","rank_math_focus_keyword":"how to host a discord bot","footnotes":""},"categories":[22645,22644],"tags":[],"class_list":["post-92397","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps-use-cases","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-criar-bot-no-discord","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/heberger-un-bot-discord","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-alojar-un-bot-de-discord","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-alojar-un-bot-de-discord","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-alojar-un-bot-de-discord","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-alojar-un-bot-de-discord","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-criar-bot-no-discord","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-host-discord-bot","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-host-discord-bot","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/92397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=92397"}],"version-history":[{"count":21,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/92397\/revisions"}],"predecessor-version":[{"id":139027,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/92397\/revisions\/139027"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media\/87036"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=92397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=92397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=92397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}