{"id":6536,"date":"2025-08-20T09:44:29","date_gmt":"2025-08-20T00:44:29","guid":{"rendered":"https:\/\/dandelions.co.jp\/blog\/?p=6536"},"modified":"2025-08-20T09:44:29","modified_gmt":"2025-08-20T00:44:29","slug":"engineer-blog-creating-a-discord-bot-free-24-7-operation","status":"publish","type":"post","link":"https:\/\/dandelions.co.jp\/blog\/blog\/2025\/08\/20\/engineer-blog-creating-a-discord-bot-free-24-7-operation\/","title":{"rendered":"Engineer Blog &#8211; Creating a Discord BOT (Free 24\/7 Operation)"},"content":{"rendered":"\n<p>I introduce the learning topics I&#8217;m working on daily in my engineer blog. Recently, I personally created a Discord bot and successfully ran it for free, 24\/7, so I&#8217;d like to share that experience with you this time.<\/p>\n\n\n\n<h2>What&#8217;s Discord?<\/h2>\n\n\n\n<p>Before diving into the main topic, let me give a brief overview of Discord. Discord is a communication service developed in the United States that supports text, voice, and video interactions. I mainly use it as a call app while working.<\/p>\n\n\n\n<p>Here are the main features of Discord (only those relevant to the main topic have been extracted)<\/p>\n\n\n\n<p><strong>\u25c6 Server<\/strong><br>A server is a feature similar to group chats, allowing multiple users to interact through text chats and voice communication. Servers are categorized into Open Servers (which can be made publicly available through application, searchable within Discord, or announced on bulletin sites for recruiting members) and Private Servers (accessible only by invitation unless applied for).<\/p>\n\n\n\n<p><strong>\u25c6 Text<\/strong><br>Channel This is a group chat feature within a server where members can communicate with each other through text.<\/p>\n\n\n\n<p><strong>\u25c6 Voice<\/strong><br>Channel This is a group call feature within a server, allowing members in the channel to communicate and share their screens.<\/p>\n\n\n\n<p><strong>\u25c6 BOT<\/strong><br>By introducing a BOT, you can enhance the functionality of your server. Inviting publicly available BOTs allows you to add useful features like music playback, text-to-speech, timers, and schedule management. You can also invite and operate your own custom-made BOT.<\/p>\n\n\n\n<h2>From Creating to Operating a BOT<\/h2>\n\n\n\n<p>The BOT I created this time is a &#8216;Voice Channel Entry Notification BOT&#8217; for private servers.<\/p>\n\n\n\n<p><strong>\u25c6 Inspiration<\/strong><br>In Discord, when someone enters a voice channel, there is no built-in feature to notify other server members. As a result, someone might be waiting without realizing they\u2019re working alone. That&#8217;s when I thought, &#8216;Wouldn&#8217;t it be useful to have a BOT that sends notifications for channel entries?&#8217; And so, I decided to create one.<\/p>\n\n\n\n<p><strong>\u25c6 Implementation Details<\/strong><br><strong>\u2460Determine the BOT&#8217;s features and coding<\/strong><br>Create a <code>main.js<\/code> file in JavaScript to align with sites that allow free 24\/7 BOT operation.<\/p>\n\n\n\n<p>Features included:<\/p>\n\n\n\n<ul><li>When the number of users in the &#8216;Working&#8217; voice channel changes from 0 to 1, automatically send a recruitment message to the &#8216;Call Recruitment (Auto)&#8217; text channel.<\/li><li>If the number drops from 1 to 0, delete the recruitment messages previously sent to &#8216;Call Recruitment (Auto)&#8217; entirely.<\/li><li>From 1 to 2 or more users, no recruitment messages are sent to &#8216;Call Recruitment (Auto)&#8217;.<\/li><\/ul>\n\n\n\n<p>Below is part of the actual coding.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"727\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-1-1024x727-1.png\" alt=\"\" class=\"wp-image-6537\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-1-1024x727-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-1-1024x727-1-300x213.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-1-1024x727-1-768x545.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><strong>\u2461 Create a BOT Account on Discord Developer Portal<\/strong><br>Access the Discord Developer Portal, create a BOT account from &#8216;New Application,&#8217; and obtain the token.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"522\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-2-1024x522-1.png\" alt=\"\" class=\"wp-image-6538\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-2-1024x522-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-2-1024x522-1-300x153.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-2-1024x522-1-768x392.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>Enable the following in the BOT&#8217;s permission settings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"414\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-4-1024x414-1.png\" alt=\"\" class=\"wp-image-6539\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-4-1024x414-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-4-1024x414-1-300x121.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-4-1024x414-1-768x311.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"429\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-5-1024x429-1.png\" alt=\"\" class=\"wp-image-6540\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-5-1024x429-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-5-1024x429-1-300x126.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-5-1024x429-1-768x322.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"651\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-9-1024x651-1.png\" alt=\"\" class=\"wp-image-6541\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-9-1024x651-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-9-1024x651-1-300x191.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-9-1024x651-1-768x488.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>After configuring the BOT&#8217;s permissions, invite the BOT to your server using the generated URL.<\/p>\n\n\n\n<p><strong>\u2462 Create a Repository on GitHub and Upload the Source Code<\/strong><br>I used Git, which I\u2019ve previously introduced on my <a href=\"https:\/\/dandelions.co.jp\/blog\/blog\/2025\/04\/23\/engineer-blog-the-basics-of-git\/\">engineer blog<\/a> and discussed during an <a href=\"https:\/\/dandelions.co.jp\/blog\/blog\/2025\/06\/25\/in-house-study-session-about-git\/\">internal workshop<\/a>. <br>Create a repository on GitHub and upload the source code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"552\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-6-1024x552-1.png\" alt=\"\" class=\"wp-image-6542\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-6-1024x552-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-6-1024x552-1-300x162.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-6-1024x552-1-768x414.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><strong>\u2463 Link Deno.deploy with GitHub and Log In<\/strong><br>Create a project in Deno.deploy and import the repository created on GitHub. <br>Set the token obtained in step \u2461 as an environment variable.<\/p>\n\n\n\n<p><strong>\u2464 Add Deno.cron at the End of the Source Code to Enable 24\/7 Operation<\/strong><br>To ensure the BOT doesn\u2019t stop, add a periodic process (Cron job) at the end of the source code that performs light operations every 2 minutes on Deno.deploy..<br>This allows the BOT to operate 24\/7.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"772\" height=\"491\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-8-1.png\" alt=\"\" class=\"wp-image-6543\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-8-1.png 772w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-8-1-300x191.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-8-1-768x488.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><strong>\u2465 Test on the Discord Server<\/strong><br>Enter the voice channel and check if it operates as expected.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"800\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-11-1024x800-1.png\" alt=\"\" class=\"wp-image-6544\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-11-1024x800-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-11-1024x800-1-300x234.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-11-1024x800-1-768x600.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>When the voice channel has no members, the text channel has no messages.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"824\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-12-1024x824-1.png\" alt=\"\" class=\"wp-image-6545\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-12-1024x824-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-12-1024x824-1-300x241.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-12-1024x824-1-768x618.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>When you join the voice channel and the number of members in the voice channel changes from 0 to 1, a call recruitment message is sent to the text channel.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"722\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-13-1024x722-1.png\" alt=\"\" class=\"wp-image-6546\" srcset=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-13-1024x722-1.png 1024w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-13-1024x722-1-300x212.png 300w, https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2025\/08\/image-13-1024x722-1-768x542.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>When you leave the voice channel and the number of members in the voice channel decreases from 1 to 0, the message in the text channel is automatically deleted.<\/figcaption><\/figure>\n\n\n\n<p>It has been confirmed to be working as expected, so it will be completed once the BOT is checked to ensure it is not offline the next morning.<\/p>\n\n\n\n<p>That wraps up the discussion on creating a Discord BOT and achieving free 24-hour operation.<\/p>\n\n\n\n<p>Stay tuned for the next technical blog<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I introduce the learning topics I&#8217;m working on daily in my engineer blog. Recently, I personally created &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/dandelions.co.jp\/blog\/blog\/2025\/08\/20\/engineer-blog-creating-a-discord-bot-free-24-7-operation\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Engineer Blog &#8211; Creating a Discord BOT (Free 24\/7 Operation)&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[8],"tags":[9],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paR9rw-1Hq","_links":{"self":[{"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/6536"}],"collection":[{"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=6536"}],"version-history":[{"count":1,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/6536\/revisions"}],"predecessor-version":[{"id":6547,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/6536\/revisions\/6547"}],"wp:attachment":[{"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=6536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=6536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=6536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}