Saturday, February 13, 2021

Discord Bot Creation

I usually only make blog posts about art here, but since I'm not making a ton of blog posts anymore, I decided to switch things up! This might mean more frequent blog posts about various processes, even if they're not solely art-related. But this is going to be a rather lengthy text post.

tldr; I used to use mIRC commands to make my characters talk, but now I'm learning how to implement that into Discord through creating my own bot.

Here's the difference:


Discord has been the main platform that I use for communication for the past few years, not too long after it was released. And in the past year, I've started to finally learn how to code, mostly in JavaScript. So creating a Discord bot is something I've been interested in for awhile.

So I'm going to talk a little bit about how I got here and where I started actually, when it comes to programming.

The Origin: mIRC

Back in 2002, I came across Pojo's DBZ website (which I guess still exists?) and entered into their chatroom. From there, I learned what chatrooms were and quickly made some cool friends on there, (some of which I still talk to this day!) and downloaded mIRC, since it was an easier way to access more servers than what was just on that website. And once the main server I used went down, I had to figure out ways to keep in touch with these friends, most of which I only had access to their IRC username, and no other form of contact with them.

But with mIRC at my disposal, I started to learn very basic programming commands, just by poking around in the Alias files or various other areas. I downloaded some bots to play fancy games and a lot of the friends I met on there were programmers or had some knowledge in the field, and were able to answer some of my questions.


Eventually, in 2006, my brother and I decided to go on a server where we would make our characters talk, much like we used to do when we played with action figures as kids. Some servers would ban your IP address if you had multiple accounts logged in at once, so we were really pushing it just by having the two of us log in on the same IP address. So we wondered... how can we make multiple characters talk without having to type and format their text every single time? Well, poking around in the alias files, our questions were answered.

Alias Files in mIRC

mIRC has some default commands programmed like opping someone or kicking someone from a channel. So I ended up copying some of that code and realizing that I could use the same command used to op a user to type /characterName and print something.



Eventually, I modified the kick command to create a pop-up window to allow the user to type in a text instead of a reason for kicking them. So with all of that, I knew how to type /characterName and have it print out text that the user typed!


Eventures

So this is what led to my current writing style, actually (which I call writing Eventures). I join a server and type commands for my characters to speak, and it prints out nicely with their text colors and everything. I save out the logs and view them in Patchou IRC Log Viewer whenever I want to view them as if it's on mIRC. We're probably the only ones on the planet that write our story fully this way, but it's really the only way I can get in the zone!

Transition to Discord

mIRC had been my main communication platform until 2011, when I slowly started to use newer social media platforms to communicate with people I knew in real life. Because let's face it, none of my real-life friends had ever heard of IRC or wanted to use it, but I did still use it to communicate with my online friends. I was constantly trying to find something that felt as much like home as mIRC did, but nothing really did. My college friends used Facebook Messenger and Skype to communicate for years, and looking back at it, I can't imagine using either of those to keep in touch with people now.

Finally, Discord came around and it had a lot of similar features to mIRC, which made me really like how it functioned, and it started to feel like a home, just like how mIRC has always felt. And when I got a smartphone, I got spoiled being able to talk to my friends on mobile and PC (which mIRC was unfortunately lacking). Even my online IRC friends moved to Discord so I can still keep in touch with them there. Discord was still missing a bit of customization though. I couldn't just pop open the Alias files and type my own commands easily like mIRC did, and I couldn't change the color of text.

For years I had been wishing that Discord would add something like this. So finally I decided to research bots and see what I could do with them. While it ended up being much more complicated than one line of code like mIRC had, it's getting closer to what I was hoping for. And now that I understand programming a bit more, I'm capable of making a bot myself that does close to what mIRC could accomplish.

The Discord Bot

I started by watching Drew Conley's tutorial video on how to set up Discord.js. I learned a bunch of the basics like using VS Code's terminal to have the bot join the server and sending messages to the channel. From there, I knew enough to start experimenting on my own.

I started to research webhooks, and had something working pretty easily where each webhook could be associated with a different character, and it would show their icon and name. This was pretty much exactly what I wanted, aside from the names not having role colors.


But then I found out you're limited to 10 webhooks per server, and I have over 50 characters that I wanted to include in this, so that wasn't going to work. I then started to read through Discord.js documentation to see what I could do, when I came across embeds. I then worked through various stages of how I wanted it to look until I ultimately got to where I'm at now.

This was mostly through just trial and error. I eventually made a webhook for each color, then used embeds, functions, and roles to accomplish what I wanted.




I'm still looking into ways of hosting the bot online so I don't have to run the terminal every time I want to use these commands, but I'm getting there and this was a fun learning experience for the past week!

Thanks for reading through this long process! Not a lot of people know about my origins with mIRC, and it was really what started my interest in programming at the young age of 9-years-old. I probably wouldn't have as much interest in pursuing it further if it wasn't such a big part of my childhood. 

If you want to see more coding process blog posts, let me know, and that might be something I do more of in the future!

No comments:

Post a Comment