Please be advised that this blog discusses topics like suicide, which some readers may find disturbing or triggering.
My name is Liv, and I’m a college student. In addition to classes, my academic year consists of a job at an IT helpdesk where I answer the phone, respond to emails, and even walk or drive to fix issues on-site. This job aligns well with my skills because even before college, I was always the person my family would call for technology help. Turns out, I can help people with just technology alone.
On weekends and academic breaks, I love to work on projects. Sometimes, these end up as folders on my desktop with 12 lines of code, abandoned partway and never visited again. Other times, they grow to consist of hundreds of files that end up published to GitHub.
One of these projects has certainly stood the test of time as the most highly used and well-received of my endeavors. For the past 5 years, I‘ve been developing and maintaining a Discord bot that helps prevent suicide.
Originally, I was looking for a way to learn Discord bot development. The best way was to identify a problem or gap in society that can benefit from the efficiency of a bot. I searched and researched until I discovered a project idea that was a little out of my comfort zone. I was fairly certain that the project had never been attempted, but I believed I could be the one to bring it to life. I couldn’t shake the feeling that I had to do something about the fact that every year, over 700,000 people die by suicide. If something I made could decrease that number by even 1, it would be worth it.
The first iteration of the bot was built with DiscordJS, and all the bot did was scan the chat for messages with certain keywords and key phrases. If the bot detected anything, it would reply with a message displaying lifelines in three surrounding countries and a link to a list with more options. I was initially satisfied with how this bot performed, so I launched it via a post on Reddit.
My bot hit the 100-server limit almost immediately.
Turns out, Discord caps a bot‘s server enrollment to 100 unless the bot is “verified.”
In classic Discord fashion, it took them a month to actually verify my bot’s legitimacy. However, the wait time was well spent. Because the bot was open source, a lot of people reached out wanting to collaborate and improve on its first iteration. Together, we worked to add more languages, more lifelines, and more features.
By May 2021, the bot was in a much more stable and fleshed-out state than it had been just a month prior. Users could now manually direct the bot to help people when the keyword–list system didn‘t work, and users could now opt out of being responded to if they found it annoying.
The bot grew quickly in popularity. We passed 500 servers and then 1000 servers in a very short time, meaning we needed a scalable solution. A single-threaded bot would only hold up for so long. Luckily, DiscordJS has a built-in sharding system, requiring only a small amount of modification to implement.
Another issue we encountered as we built in more scalable features was the technical debt that we were quickly incurring. The first iteration of the bot looked like it had been written by someone who had never made a Discord bot before—because that’s exactly what had happened. Additionally, there were a bunch of different people who were all trying to lend their help by committing code, but almost none had built a Discord bot before either. This led to an enormous amount of spaghetti code to parse through and organize.
So, I took it upon myself to rewrite it from scratch. I deleted it all and started over—new DB (MySQL), new DiscordJS structure, and new classification system.
By using (everybody’s favorite new buzzword) ✨AI✨, also known as “binary text classification through TensorFlow,” I was able to build a new classification system that did away with the terrible keyword–list situation. The problem is, I couldn’t exactly train a model without collected data on users. Luckily, there are public datasets for exactly this kind of classification. Ultimately, I combined a few of the datasets together and trained the AI model. After a bit of trial and error, I had the model honed down to something reasonably accurate.
Now, what happens when the bot finds a message showing signs of suicidal ideation?
Who could have guessed?
The United Nations states that there exist 193 nations. Unfortunately, this information is not very helpful for listing suicide lifelines relevant to each country or geographical area. Some countries have overseas territories on the opposite side of the globe. A lifeline that has operating hours meant for locals living on the mainland isn’t exactly helpful to someone living on an island thousands of miles away.
I found a country list online that I used as a vague starting place, though I added quite a few locations. All in all, I came up with a list of 240 locations. One example is Norfolk Island (population 2,188), which I added because despite being a territory of Australia, it has an independent phone number for reaching a mental health counselor.
How did I find this out? Because I googled the names of all 240 areas followed by “suicide lifeline.” The most disheartening part of the search was to see that nearly half of these locations yielded no results at all. Sometimes, I couldn‘t find a hotline because I was searching in English, or other times, simply no organizations that provide assistance existed. New organizations may have popped up since my initial search, so I‘ll need to update the list at some point.
Small snippet of the number-tracking spreadsheet
I collected more than just the phone numbers of lifeline centers. I linked as many lifeline centers as I could to their websites, as well as donation links and any other information people may want before they called.
My personal favorite, if I had to pick a favorite suicide lifeline, is that of Tonga, a small island nation of just over 100,000 people. It’s run by a church, was built with Blogspot, and uses a Calligraphy font for the entire website. Perfection. In all seriousness, I commend the organization endlessly for starting up such a service, especially when my city alone outnumbers their entire country 40-to-1.
If there’s one lesson I want people, especially beginner engineers, to take away from this story, it’s that it’s okay to just start making stuff. The way I first approached this was not structured very well. I wasn‘t following any kind of tutorial or video, and it certainly showed. The lessons I learned along the way have really stuck with me more than any lesson from a book or an article. For example, I couldn‘t have handled the refactor, machine learning, and database if I didn’t start with a simple keyword list and convoluted code. I had to learn this through trial and error, but now I will never forget what I’ve learned.
If you have an idea you’ve wanted to try or a topic you’ve wanted to learn, you’re not going to get anywhere by reading blog posts (unless you’re reading Bugcrowd’s, of course). Just go make stuff. You don’t need to know what you’re doing. Learn by doing and figuring things out yourself.
Take this sentence as your sign to start that project idea you’ve been considering.
Today, this bot is humming away on my desk. I host it at home on dedicated hardware—an old Dell OptiPlex I saved from being e-waste. It now has a new life saving the lives of others, and I’ve received several thank-you messages from people.
I plan to keep hosting and maintaining it for as long as suicide is a problem.
17% of deaths in those aged 15–19 (large demographic of Discord users) are from suicide. It’s the third most common reason for someone aged 15–29 to die. It’s not just youth either. 42% of suicides are committed by those over 50. Overall, more than 700,000 people take their own lives each year.
This month, there is one especially important group of people to highlight. In June 2021, during Pride Month, the bot icon gained a couple of Pride flags, and they are still visible four years later. This is because suicide among LGBTQIA+ people always deserves visibility. About 80% of trans people will consider suicide, and half of those will attempt it. Suicide prevention among LGBTQIA+ people needs to be highlighted, no matter the month.
I’d like to thank Bugcrowd for giving me the opportunity to highlight my project, especially Emma, who has been incredible at engaging the online Bugcrowd community.