Good Morning from my Robotics Lab! This is Shadow_8472, and today I’m coding Discord dice bot to a practical state. Let’s get started!
Discord Bot Communication Skills
When last I wrote about this bot, I described a custom development environment: a custom OCI container with Python with Discord.py installed and a directory mounted from the host machine. To update the bot, I save the new source file from the host and restart it from within the container.
Programming is boring to describe, so I’ll spare myself writing all the details. Long story short, I needed to translate user requests into a form the core function understood. I used Regular Expressions (Regex) to both separate intended inputs from potential garbage and to extract the kind and number of dice to roll. regex101.com [1] was of great help in testing these expressions.
On one minor note: I got the bot into a Git repository, but I am nothing but a bumbling beginner.
My goal for next time is to produce a container with my code internalized. I’m also scheming something that will let my group know when I’m “playing around with the source code” or the bot is running from within a production container.
Commenting System
Any good program has comments left by its developer – notes for future work on the project. Wise use of comments can speed up development.
by reminding a programmer where work left off or clearly marking off major sections. Working on the command line with the Nano text editor, colors are nicely highlighted, but with all the comments I’m leaving, a simple note left to myself looks no different than commented out code blocks yet to be implemented or scheduled for deletion.
#A simple comment is useful for a quick note.
Basic comments can be anything from programmer notes on how some code works to incomplete or defunct chunks of code that shouldn’t be executed yet/anymore. Programmers must use them unless the objective is for God alone to know how their programs work.
################################### #A title marks out major sections.# ###################################
Note: In the editor, I’m using “verse” formatting to represent code. In a fixed width text like you will find in a terminal, the lines should be the same length.
Editors that color code parts of your code are nice, but source files begin to look the same after they’re several screens of scrolling. Marking off large groups of functions keeps them organized like chapters in a book. I like to use spam a bunch of comment characters (# in Python) for extra visibility while flipping between places in the code.
################################################ #A broken pattern marks out scheduled changes.# The quick, brown fox jumped over the lazy dog. The little dog laughed to see such a sight. ################################################ #The quick, brown fox got distracted. #The cow jumped over the candlestick. ################################################ ################################################
I’d be surprised if I’m the first to invent a way to partition off major blocks of code for redevelopment. Not only can I quickly revert to old code without much thought, its a landmark for showing which sections are actively being worked on.
3D Printing Corner
It’s been a few weeks since I said I wanted to print something each week. This week is no different, but at least I tried.
Gluing a 3D printed object together from smaller parts allows you to overcome print volume limitations of your printer, a valuable skill to have. As I was browsing Thingiverse for something Sonic the Hedgehog related to print, I found a model of Sonic someone split front to back to require almost no support material.
Slic3r was something else. I had a difficult time getting both front and back on the plate at the same time while avoiding the damaged section. Auto-generated Supports ended up in more places than they needed to be. Sonic’s pupil even needlessly generated one with a corner sticking out of his face. I had to shift the halves around multiple times to accommodate the skirt within the print area while still avoiding the damaged spot in the middle – a challenge, but one I accomplished nonetheless. Setting supports to snug cleaned up most wayward supports, but I had to paint on support blockers around Sonic’s cuffs and fingers.
Optimizing for few supports in this way has a major tradeoff: a much more difficult first layer. I didn’t have the patience, so I left the project for another week.
Takeaway
Basic projects are often less exciting than any creative techniques devised to work on them.
Final Question
How have you used comments in creative ways?
Work Cited
[1] F. Dib, regex101.com, [Online]. Available: https://regex101.com/ [Accessed Feb.
28, 2022]