Bots for Business
A Guide to Building Bots for Discord
Gamers love talking shop on Discord. Launched initially as an alternative to big-name, catch-all communication apps like Skype, its primary audience consists of video game enthusiasts. It also happens to be a place where chatbots abound. Let’s take a closer look at Discord. We’ll consider why you might want to build a chatbot for the […]
September 17, 2019
Gamers love talking shop on Discord. Launched initially as an alternative to big-name, catch-all communication apps like Skype, its primary audience consists of video game enthusiasts. It also happens to be a place where chatbots abound.
Let’s take a closer look at Discord. We’ll consider why you might want to build a chatbot for the platform—and how. In addition, we’ll look at some examples of bots that live on Discord and explore how they provide value to users.
What is Discord?
Discord is a unique communication channel. For one thing, it’s laser-focused on a single user demographic: gamers. Of course, not all gamers have the same interests, and there’s a lot of diversity among the gaming public. Thankfully, Discord architecture caters to virtually all of them.
The platform is also a hybrid experience with regard to what it offers. Discord is part voice and text chat, but it’s also a game store and a social network. Similar to Facebook groups, Discord offer various communities (known as servers) within the app. The servers make it possible for any gamer to find his or her community and to join the conversation.
What Slack is to work-related conversations, Discord is to game-related conversations. One could nitpick that comparison and point out differences—and there are some—but, at a fundamental level, it holds true.
Discord is also very popular. With 14 million daily players and 325 million messages sent per day, there are plenty of conversations to join—and many of those conversations feature chatbots. Discord bots do lots of things, but their main goal is to enhance the overall experience of using the app.
Discord chatbot examples
There are all sorts of chatbots on Discord, and there are so many that it’s difficult to definitively count them. The magic of bots for Discord is that they can do pretty much anything you want them to do. They handle tasks like:
- Moderating conversations
- Playing music
- Managing communities
- Weeding out spam
To get a sense of the sheer variety of Discord chatbots, browse the Discord Bot List. Discord also creates great tutorials on building bots with varying sets of tools. For instance, there are how-to guides for building a Discord bot with Java and with Node.js.
Server moderation bots
Described by some critics as a “do everything bot,” Aethex serves up welcome messages, displays user stats, and can even allow users to add friends to a game. Of course, Aethex also helps with basic moderation tasks, such as muting, removing, or banning users, as needed.
Another option is Dyno. With this bot, you get automatic spam filtering and member role management. You can also issue custom commands to communicate with members, add playlists, and perform tasks related to server moderation.
Rythm allows Discord users to play music during gameplay. Users can activate the bot to play music from YouTube, SoundCloud, Twitch, and other music services. To play a song with Rythm, just issue a simple command that includes the name of the track you’d like to hear.
If you want a music bot that does a little more than just play your music requests, Bastion might be what you need. Although music is the Bastion go-to feature (and it does a lot of the same things Rythm does), it also allows users to gamble with virtual currencies, upvote all types of content posted by users, or manage user feedback.
Other Discord bots
Lots of Discord bots handle server management and music, and there are many other bots that perform more specialized functions. For example, Medalbot helps users record gameplay and submit the recordings to Medal, an app that aggregates compelling game clips.
But what if you want to do more than view users’ game clips and share your own? What if you want to connect directly with those users? You might need Stranger. Through Stranger, users can hold anonymous chats with other users or turn server channels into special chat groups.
How to make a Discord bot
Discord bot-building tools
When building Discord bots, you have a lot of freedom. Use any set of tools you want, and connect your bot to Discord via the Discord API.
Regardless of which tools you use, be sure to deploy your bot both to Discord and to a dedicated domain. Chances are that some of your bot’s features will be relevant in contexts beyond Discord—even if you initially set out to build a bot just for that platform. A .BOT domain, in particular, is a great place to deploy your bot to ensure it always has a home. Over time, your bot might outgrow Discord. A dedicated, bot-focused domain, on the other hand, can grow with your chatbot.
How to add bots to Discord
To get a sense of what it takes to deploy your bot to Discord, let’s consider the steps involved when using Discord.js:
- Complete basic setup steps on Discord to create an application for the platform and designate a user. (In Discord, this is a Bot User.)
- Install Node.js, and sign up for ZEIT, Heroku, or another deployment platform.
- Program the bot to behave as you desire. This is where the Discord.js library comes into play.
- Deploy your bot via your deployment platform (the tutorial suggests ZEIT).
Note that these steps omit the optional step of building a language model for your bot. By using a full-featured chatbot framework, you can create a bot that’s powered by a natural language processing (NLP) engine.
Frameworks to use when building a Discord bot
You can build your Discord bot on any major chatbot framework. For an overview of what’s involved in creating a Discord bot with Dialogflow, one of the most popular frameworks, consider this Discord and Dialogflow tutorial. The basic steps are as follows:
- Create a Discord server.
- Create an app using the Discord native configuration tools.
- Create a bot user for your app.
- Add the bot to your server.
- Get a Glitch account so that you can execute your code. Create a project, and locate the archive file for the project.
- Add Discord credentials to the archive file.
- Create a Dialogflow account, run through the configuration prompts, and get a client access token.
- Add the token to the archive file inside your Glitch project. This connects the Dialogflow NLP to your bot’s codebase.
- Use the Dialogflow NLP engine to build out a language model for your bot.
Although there are many ways to make a bot for Discord, these steps are similar to the process you’ll follow when using any bot-building framework.
Getting started with Discord bots
Start with documentation for the Discord API. That should give you a good sense of what’s involved in building a bot for Discord. Even if you’re not sure whether you will use it, the Discord.js library is a great resource, since it was created to work with the Discord API. If you’re on a time crunch, the Discord.js library could speed up your development process.
Another way to get a feel for the bot landscape on Discord is to simply use the app. Join a server, chat with users, and send commands to a bot. This “learning through doing” approach can teach you a lot about how users and bots interact on the platform.