How to make a discord bot: Everything in between

quotebot being tested in a discord channel designed for testing bots

In my experience with writing QuoteBot, I’ve been stuck in a dead end more than once because I hit something I didn’t really know how to tackle. This guide will hopefully help you avoid some of the pitfalls that I’ve got stuck on when making my discord bot.

Discord bots are an exciting project to take on, you can learn new things while scratching that itch that current discord bots just don’t get. ‘How to make a discord bot’ is still searched often, and there are many guides on the internet covering many languages. However these guides only go so far, so I wanted to write this to fill the gap. I’ll be going over all the stuff I ran into and had absolutely no idea what to do, and how to get past it.

This post isn’t for those who want to just make a small discord bot for you and your friends. This post is for people who want their discord bot to used by anyone in any server at anytime. It goes over everything from starting out, getting verified and more.

It’s been 8 months since I decided to make QuoteBot open to anyone to add to their servers. It has a total of over 1800 servers. It’s been given its own website and is now one of the biggest UNDERTALE themed bots on discord. But it didn’t come without it’s challenges. A lot of these can be disheartening first time making a discord bot, as most of the tutorials only cover the basics of creating a bots code. After that, it can very much feel like you’re on your own.

General stuff to know to make a discord bot

It goes without saying you need some initiative to learn coding. It might seem obvious but you’d be surprised how many people expect others to built their bot for them. It’s alright to ask for help, but always at least try googling first.

If you want to share your bot, it needs to have a name and profile picture. You should do a search to see if any sites or users already have the same name already exist. This may not seem like a huge issue, but you can be up against these people in search rankings when people search for your bot. There’s also the risk of trademarked words, and passing off that you need to beware off. A similar approach should be taken with profile pictures.

It’s generally standard to have a support server for your bot which is easily accessible to people who need it. It doesn’t need to be an elaborate discord, the general channel will be the most used anyway. I recommend having an announcement channel in it for updates for your bot. I’ve also added an upvote channel to my discord, so it pings users with a thank you message when they upvote. More info about that here.

Hosting

Something I often see around bot making discord servers is mentions of services like Heroku, repl.it and other free services that offer to run your code. These are appealing because of them being free, but you have to ask yourself why they are free.

This is usually because it’s limited, either you have restricted features or limited uptime per month. Or it’s paid in ads, you have to watch ads to pay for uptime. There’s also the risk of your bots token becoming compromised. Which can do massive damage depending on what permissions your bot has in its servers. These free services are good for the development version of your bot, or if its a personal bot / bot for you and your friends. But for a bot you allow anyone to add to their servers is not really up to standard.

From experience I know the hardest part of paid hosting is committing to paying for it. Or even putting your card details in. A lot of this comes from the idea that you might be overpaying or not getting a good service. Which is why it’s important to do research on a host and see how people review them.

When choosing a hosting plan, you don’t need a lot, usually the smallest plan is fine. Bots do not take a lot of resources to run. But make sure to account for things like the memory the operating system and database will use. I would advise buying enough power so that your server can still run with at least 10% of resources free, preferably more.

My first server was a low power CPU with 2GB of ram, which was three times more than enough power. My bot would only use no more than 20GB of data a month. Which sounds like a lot but standard packages come with around one terabyte of data anyway.

I use a DigitalOcean server, a VPS with 2GB RAM and basic CPU. It’s hosting my bot, it’s dashboard and this blog. You might need something more powerful if your bot performs heavy tasks (QuoteBot relies a lot on API calls so most work is done by another server).

Getting people to add your bot / Promoting it

Getting enough servers to be verified is arguably the hardest part of starting off. A bot with few servers doesn’t look trustworthy and people may be reluctant to add it. This is a reason you need to need to put effort into promoting your bot. It will eventually pick up momentum once it has enough servers and promoting will be easier.

You can always share on social media. Twitter is good for this since there is twitter bots that will automatically retweet any tweets with a certain hashtag. It’s much easier to market your bot if you know what type of people would like to use it. I used to market QuoteBot using the #UNDERTALE hashtag, since there was bots known to retweet that. The RTUndertale bot retweeted it and that tweet got over 200 impressions.

You can use a custom website to advertise your bot. It’s not advisable to buy a domain for your bot right off the mark. Since a domain can be wasted money if you need to change the name or branding of your bot. That being said there is free options like GitHub pages which allow hosting on your own subdomain, which is good to get your bot on google. If you already own a domain for a blog or something, you can always use a subdomain. If you choose one of these options you can always just redirect to a proper domain later.

Some good free web options exist, as mentioned GitHub pages gives you your own subdomain with free hosting. You can only host static content like HTML and images but it does well. Although you can’t do things like server side redirects so you have to use JavaScript. There’s also Heroku and W3Spaces which are similar but have limits imposed on them. You can also use free available APIs to make the content look professional. I wrote an article on how to make a shields io server badge, just like the one on GiveawayBot’s site.

If you’ve looked for discord bots to add to your server, you’ve no doubt encountered the bot listing sites like top.gg and discordbotlist.com. You can submit your bot to these sites and have it displayed in categories and show up when people search. These sites as a rule of thumb will generally want to review your bot before they allow it to show as the site. This is too prevent look-a-likes of big bots that nuke a server on being added.

You’ll have to provide a set of information about your bot. Like its commands, its prefix, what it does etc. This is generally checked as well to make sure people put some level of effort into their bots. There is also upvoting on these sites. Upvoting determines how high your bot shows on the bot list, the more, the better. You are generally encouraged to reward users for upvoting your bot, consistent upvotes will show your bot higher on the front page. Which brings me onto my next topic : Vote rewards.

Vote rewards

I wrote a small guide on this some time ago, since it’s often confused with discord webhooks. I’m not going to repeat the guide here, so here are the links. If you choose to run your bot on a server that can not host a web server, you might benefit from using this guide. If you can host a web server, you should use this guide.

Locking commands to users who voted is used a lot and a good tactic. However you’re advised to not lock basic commands behind vote rewards. I personally have an extra feature to include colour in textboxes in my bot. If you want this feature you have to vote for the bot. This lets users use the main feature of the bot and then opt for an additional feature. Try to entice users into voting by showing how good your bot is beforehand.

Store these ID’s in a database, I used to use sqlite which did the job. But when I made the QuoteBot dashboard, I migrated to MySQL. If you want your bot to store a lot of data or share it with other apps. It’s probably better to use something like MySQL over sqlite.

You may have also seen some bots reward voting by giving currency of some kind to users. This is an effective tactic and encourages users to keep voting for your bot. It also encourages users to vote across multiple platforms to get more currency at once.

Technical knowledge

This section depends a lot on what you choose to host your bot on, and how ambitious it is. But in general most bots are hosted on Linux servers, which you need some Linux knowledge to get the most out of. It’s helpful to know the command line, since you won’t have GUI access to all servers. But it’s also helpful to know a few tricks about screen or systemctl.

screen and systemctl are two Linux apps that are very different but good for running your bot. Generally you’ll be running your bot via an SSH terminal, and running the code then leaving the window minimized is a bad idea. Your code will stop if SSH becomes disconnected for any reason, and you might not notice this for a while. You can start a separate terminal in screen, and then detach and then disconnect. The separate terminal will keep running your code, until you tell it otherwise.

Or you can setup a systemctl service which will run your code as a background service. I prefer this method, since it starts on boot. It will also automatically restart your code when it crashes, leading to less downtime. I wrote a guide on systemctl here.

Privacy policy

Discord requires all bots to have a privacy policy no matter what data they collect. While this isn’t a no one will tell you this thing, it’s not clear unless you actively look for it, which is why I’m including it.

A pinned message in the official discord developer server says :

Privacy Policy Expectations

We expect that a basic privacy policy would at minimum include the following:

1) What data do you collect, including but not limited to personal identifying information?

2) Why do you need the data?

3) How do you use the data?

4) Other than Discord the company and users of your own bot on Discord the platform, who do you share your collected data with, if anyone?

5) How can users contact you if they have concerns about your bot?

6) If you store data, how can users have that data removed?

If you do not store data, you still need a privacy policy, even if that policy says “We do not store data” before still providing users with a way to contact you about their concerns.

We do not have any specific expectations with regard to how you make your privacy policy available. We simply expect that you do your best to make it available to your users however you see fit. This can be a link to a website, a command in your bot, a link to a Pastebin, the option for users to request it via DM, or pretty much anything that empowers users to go find your policy if they should want it.

Will this cover every legal obligation you may or may not have as a software developer working with user information at scale? We can’t really speak to this, and if you are concerned about your legal obligations regarding GDPR, CCPA, and other regional data regulations, we would advise speaking with a lawyer. Would this cover our expectations for you as a user of our API? Yes.

kadybat, dev support team

Verification

If you manage to get enough servers that you get the wonderful email that your bot has been added to over 75 servers, congratulations! You’ll be asked to verify to continue your bot growth. Once you get to 100 servers, until discord has verified your bot, anyone who tries to add it will encounter an error message. This can be frustrating since you may be stuck at 100 servers for some time, missing out on potential growth while your verification application is being processed. This delay can be longer if you don’t fill out your application form properly. So make sure you fill in as much info as possible about your bot. A bot website or page on a website is good for this situation.

There is also intents you can request for your bot to function. It’s important to understand these because you will need to give discord a reason to let you have them. A good explanation of intents by advaith is here :

This is an old guide, it does not account for the new intent coming into affect in April 2022, but discord have a support article on this.

You also need to provide ID to discord, unfortunately people under 16 can not get their bot verified. Discord’s recommended solution to this is to transfer the bot to a parent or guardian. Then they can verify and transfer the bot back to you.

Do not try to cheat the system. discord verification has a system in place to check when people have made servers specifically for the bot to gain servers. If you attempt this, your verification may be declined before you even apply.

I got verified, what now?

Congratulations! You’ve made a bot that is used by many people in many servers, and you have the checkmark to prove it. Where you take your bot now is up to you. It might be worth setting up a feedback system, which allows users to suggest new ideas.

Earlier I pointed out the fact that you shouldn’t buy a domain right as you start. Since you may need to change the bots branding. But once you are verified you can not change your bots name, so it may be worth it then.

If your bot grows very large, you might need to consider sharding it. Which runs separate instances of the bot and divides the bots servers between them. Although you don’t need to do this unless your bot is in thousands of servers.

I’ve seen people host giveaways for premium services on their bots. This seems to be a good way to encourage interaction and people to come to a server.

Things that no one tells you about making a discord bot Click To Tweet

It can be challenging to build something so widely used for the first time. So what’s your advice for new bot makers?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.