{"id":964,"date":"2022-02-07T12:00:00","date_gmt":"2022-02-07T20:00:00","guid":{"rendered":"https:\/\/letsbuildroboticswithshadow8472.com\/?p=964"},"modified":"2022-02-07T11:50:12","modified_gmt":"2022-02-07T19:50:12","slug":"i-buildah-discord-bot","status":"publish","type":"post","link":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2022\/02\/07\/i-buildah-discord-bot\/","title":{"rendered":"I Buildah Discord Bot"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Good Morning from my Robotics Lab! This is Shadow_8472, and today I am working on a dice bot for a role play on Discord for a few friends. Let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Seeking a Container<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Many projects are like a tree in terms of having a general sense of progression up from the root and the fine details take most of the work to perfect. This week, my project was a rose bush. I have an end-goal in mind, but I want to run it from a container, a technology I still haven\u2019t fully introduced myself to.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My plan started out simple: find a Discord dice bot already in a container and get it on the server. DockerHub, a sizable repository of OCI (Open Container Initiative) container images. (Most places call them Docker Containers due to its popularity over the past ten+ years. Searches for help should be worded accordingly.) I located about the only one that met all my simple criteria and made myself a bot account for it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Discord bot accounts are more similar to human accounts than I gave them credit for. The only big differences are that bot accounts log in with a token instead of a username\/password and the interface is different to accommodate a program instead of a human. Just as you only interface with your account to make posts, so too does a bot interface with its account to make posts. Give the login to someone or something else, and Discord shouldn\u2019t care.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Long story short, the bot was set up to use an environment variable when using the image to make a container. Once I got it logged in, it ran into other problems I wasn\u2019t prepared to diagnose.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning to Build Containers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With my only obvious option a bust, I set my sights on a Discord dice roller I\u2019ve used in the past made by SkyJedi for the Star Wars tabletop RPG\u2019s and a generic spinoff called Genesys. The game I\u2019ll be running is GURPS, which focuses on using 6-sided dice. Plus it has an interesting turn counter system for combat I\u2019d like to try using. The rest is fluff to me this time around, so long as I get it working.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A quick tell of an intense week is when I spend a whole day watching tutorials on the same subject over and over again until I find one at my level. This was one of those weeks. I remember there being one breakthrough video right at my beginner level that let me go back and follow the logic of more advanced tutorials that previously dazed me. During this intense study session, I puzzled together how to use Buildah at a beginner level, what a Dockerfile does, and went from muck to murk in my understanding of Javascript.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Buildah is a for making OCI containers Podman can later run and another tool I haven\u2019t yet explored can edit. Like Podman, Buildah\u2019s corner of their ecosystem aims to replace Docker commands one for one. It\u2019s a win for people switching from Docker, and a win for newcomers like me who can look back at pertinent Docker documentation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker \u2013at least\u2013 takes a layered approach to making containers. Using a Dockerfile (one word, also its file name with no extension) lets you build start with a base image and build it up layer by layer, one command at a time. Parts can then be swapped out and the image rebuilt as needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Star Wars dice bot is written in Javascript. If there\u2019s one thing I learned about Javascript this week, it\u2019s that there are several \u201cframeworks\u201d for both front-end development (used to make things look nice for users) and back-end development (used for internal logic). More specifically: I needed to look into NodeJS, a back-end framework. Node has a few different base images on DockerHub, so I worked with the full one with the intent to swap it out for smaller ones for a much smaller image.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Assembling My Own Containers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It took a very special set of circumstances during my self-study for containers to really click. First, I\u2019ve been working through the Podman plugin for Cockpit. Individual images and containers are presented in an intuitive way. Each container has tabs for info, logs, and console access. The life cycle of a container is tied to executing a single command, but if that command is to start a shell, I can interact directly with the container like I would at any other command line. I could test commands from there, and if I got something right, I could add it to the Dockerfile for my next iteration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I was actually able to find SkyJedi\u2019s Discord server and contact him directly. He wasn\u2019t familiar with containers enough to help me, but he did direct me to a much simpler bot of his I was rapidly able to package into a Node container \u2013 and later a Node:Alpine container.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The difference was login token. No matter what I tried, the full dice bot would not accept its login token. I was not able to figure this out, though I came quite close.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Side Project<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I\u2019m considering a new weekly segment where I work with my 3D printer a little bit each week. This week, I printed up a calibration cube using everything I\u2019ve learned so far. It\u2019s still far from perfect. I still need to tune in my Z-braces, as I can tell from some faint ringing I can more easily feel by running my thumbnail across it. I still need to calibrate my E-steps, a process I may need to repeat a few times as I come up with interesting, new ways to improve my printer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Takeaway<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After all that, I looked ahead at a the database I\u2019d need to deal with once I get the bot logging in, and I\u2019m almost certain now that my time will be better served making my own bot in Python. Of minor interest, I was able to learn the <strong>curl<\/strong> command better. Rocky Linux apparently doesn\u2019t come with <strong>wget<\/strong>, the terminal program I usually use to download files. Curl \u2013on the other hand\u2013 copies the contents of links to the stream. When directed to a file, it does the same job as Wget. A cool trick I pulled off involved manually following a redirect link.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Question<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I feel like a rose bush gardener with nothing to show for his work but the tools he\u2019s learned to use along the way. What projects have you farmed up a bunch of dead ends on?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Good Morning from my Robotics Lab! This is Shadow_8472, and today I am working on a dice bot for a role play on Discord for a few friends. Let\u2019s get started! Seeking a Container Many projects are like a tree in terms of having a general sense of progression up from the root and the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/2022\/02\/07\/i-buildah-discord-bot\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;I Buildah Discord Bot&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[92,2,9],"tags":[],"class_list":["post-964","post","type-post","status-publish","format-standard","hentry","category-discord-bot","category-linux","category-programming"],"_links":{"self":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/comments?post=964"}],"version-history":[{"count":3,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/964\/revisions"}],"predecessor-version":[{"id":967,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/posts\/964\/revisions\/967"}],"wp:attachment":[{"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/media?parent=964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/categories?post=964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/letsbuildroboticswithshadow8472.com\/index.php\/wp-json\/wp\/v2\/tags?post=964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}