How to make a Discord bot
Update 8/21/2018: Made some changes to code, added some additional instructions to resolve two common errors some readers encountered during the tutorial.
The rise of Discord, a chat and voice program favored among gamers, has made it fairly common for Internet denizens to find themselves hanging around “Discord servers” based on a variety of topics. One of the best things about Discord, in fact, is that you can easily make a free server of your own, deck it out with channels, and invite whoever you want to take part in it.
(If you’re not up on Discord, read our full rundown of what the service is and how it works.)
One of Discord’s coolest features is the ability to create automated users — bots — that can perform various functions. Those bots are coded in JavaScript, and can become rather complex. They do things like play music for users in a server, greeting new users when they arrive, and more.
Creating your own Discord bot doesn’t take much effort, even if you’re new to coding and JavaScript in general. Here’s everything you need to know to make a (super, super simple) Discord bot of your own.
Step 1: Download Node.js and set up a Discord account if you haven’t
Node.js is a JavaScript runtime that’s free and open source, and you’ll need it to actually make your bot, uh, work. Download it at nodejs.org and install it before you get started on anything else.
Obviously, you’ll also need a Discord account, and your own server to use to test your bot. If you haven’t created one yet, go to Discordapp.com and create one. If you do have one, login to your account and open up the server in which you want your bot to live.
You’ll also need a text editor program, like Notepad++ on Windows, to code with.
Step 2: Create your bot
Now you’ll need to create an “application” on Discord to make your bot work. This takes a little doing, but it’s not too complex. The goal here is to get an “authorization token” for the bot so that Discord recognizes your code and adds it to the bot on its servers.
First, head to discordapp.com/developers/applications/me. Your account should be logged in, so you’ll go straight to your account’s list of applications. Hit “New Application” to get started. Give the bot a name, then hit the button marked “Save Changes.”
Now, on the right-hand menu, click “Bot.” Once in the new menu, click “Add Bot” under the Build-a-bot option. If you only have one application — the one we just made — it should appear automatically. Otherwise, select it.
Step 3: Get your bot’s authorization token
In the box marked “App Bot User,” look for the words “Token: Click to reveal.” Click that link and you’ll reveal a string of text. That’s your bot’s authorization token, which allows you to send it code. Don’t share it with anyone — that token allows whoever has it to create code for the bot, which means whoever has it can control your bot. If you think the token has been compromised, the good news is that you can easily generate a new one with the link right under the token, which reads “Generate a new token.”
You’ll need that token in just a second.
Step 4: Send your bot to your server
Now scroll up to the box marked “App Details” and find your “Client ID,” a long number. Copy the number and add it to this URL, in the place of word CLIENTID.
https://discordapp.com/oauth2/authorize?&client_id=CLIENTID&scope=bot&permissions=8
The final URL should look like this, but with your client ID number in it instead of this fake one:
https://discordapp.com/oauth2/authorize?&client_id=000000000000000001&scope=bot&permissions=8
Copy the URL with your client ID number in it into your browser. That’ll take you to a website where you can tell Discord where to send your bot. You’ll know it worked if you open Discord in an app or in your browser and navigate to your server. The channel will say a bot has joined the room, and you’ll see it on the right side menu under the list of online members.
Step 5: Create a “Bot” folder on your computer
While you’re doing that, you can also take a moment to create a folder in an easy-to-reach place on your computer where you can store all your bot’s files. Call it something simple, like “DiscordBot” or “MyBot” so you know exactly what it is.
Step 6: Open your text editor and make your bot’s files
You’re going to create three files for your bot from your text editor. In the first, paste this code:
“token”: “Your Bot Token”
Replace “Your Bot Token” with the token you generated earlier on your bot’s application page. Make sure the token is inside the quotation marks. Then save the file into the Discord bot folder you made on your desktop, using the filename “auth.json.” Remember not to save it as a .txt file — it won’t work if it’s .txt instead of .json.
Make a new file, and put in this code:
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “My First Discord Bot”,
“main”: “bot.js”,
“author”: “Your Name”,
“dependencies”:
Replace the author name with your name if you want; you can also change the “description” to something other than “My First Discord Bot” if you want something more in line with what you’re making, which will be handy for remembering what your bot is supposed to do.
Save this file as “package.json” in your Discord bot folder.
Step 7: Define your bot’s code
There’s one more text file to make, and this is the important one that controls your bot’s behavior. You’ll want to be familiar with JavaScript to really have full control of your bot and know what you’re doing, but if you’re new to coding and just want to make something, you can copy and paste this code into the file to make a simple bot that will greet you in your server.
(Thanks to Medium user Renemari Padillo, whose bot tutorial helped us create this one. Check out his tutorial for code troubleshooting and other advice.)
var Discord = require(‘discord.io’);
var logger = require(‘winston’);
var auth = require(‘./auth.json’);
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console,
colorize: true
);
logger.level = ‘debug’;
// Initialize Discord Bot
var bot = new Discord.Client(
token: auth.token,
autorun: true
);
bot.on(‘ready’, function (evt)
logger.info(‘Connected’);
logger.info(‘Logged in as: ‘);
logger.info(bot.username + ‘ – (‘ + bot.id + ‘)’);
);
bot.on(‘message’, function (user, userID, channelID, message, evt)
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
if (message.substring(0, 1) == ‘!’)
var args = message.substring(1).split(‘ ‘);
var cmd = args[0];
args = args.splice(1);
switch(cmd)
// !ping
case ‘ping’:
bot.sendMessage(
to: channelID,
message: ‘Pong!’
);
break;
// Just add any case commands if you want to..
);
This code sets up a Discord bot that will respond to certain messages: Specifically, anything that starts with a “!” character. In particular, we’re programming the bot to respond to the command “!intro”, so if anyone types that in your server while the bot is in it, the bot will respond with a programmed message. In our code, we defined the message as “Greetings! Welcome to the server!” You can change both the prompt message and the response message by redefining them in the code above. Just make sure to maintain the single quotation marks around the messages.
Save this last text file as “bot.js” in your Discord bot folder.
Step 8: Open your computer’s “Command Prompt” and navigate to your Discord bot folder
On a Windows PC, you can easily get to the Command Prompt by clicking the Windows icon and typing “Command Prompt” in the field. Once it’s open, type “cd” followed by the file path to your folder. On my computer, the command looks like this: “cdUsersPhil’s DesktopDesktopDiscordBot”. That should change the command prompt line to include the file path to your folder.
Alternatively, you can navigate to your folder in Windows and hold Shift while right-clicking on a blank area of the folder, and choosing “Open Command Prompt.”
Step 9: Use the Command Prompt to install your bot’s dependencies
Now it’s time to make use of Node.js. In the Command Prompt, with your Discord bot folder in the file path line, type “npm install discord.io winston –save.” This will automatically install files you need to for your Discord bot into the folder directly.
Also use the following command line prompt to install additional dependencies: npm install https://github.com/woor/discord.io/tarball/gateway_v6
That should provide you with all the files you need.
Step 10: Run the bot
That should be everything. To try running your bot, type “node bot.js” in the Command Prompt (make sure you’re still navigated to your Discord bot folder).
Now head back to your Discord server and try testing your bot by typing “!intro,” or “!” followed by whatever you made your prompt message in your “bot.js” file. If everything went correctly, your bot should immediately return the message you coded for it.
Congrats! You just made a Discord bot!
Step 11: Figure out if your bot has been made by someone else
Discord has a big community of people making stuff for the greater good of the service all the time, and that includes bots. There are whole databases of bots other people have made that perform a variety of functions, and often their creators make those bots available for anyone to download and use. Save yourself some time and some coding by checking out some of the usual places where Discord bots are found, to see if someone has already done your work for you.
Some handy places to search for Discord bots are discordbots.org and bots.discord.pw, but you’re also likely to have luck googling for what you need, as well.
Editors’ Recommendations
- How to rip a Blu-ray or DVD
- How to add external games to your Steam library
- How to download Instagram photos from any device
- How to reset your Apple ID password
- How to make emoji
Hubble Telescope functioning again after activation of backup gyro
The Hubble Space Telescope has been responsible for some of the most stunning and informative pictures of deep space since it was launched in 1990, but the telescope suffered a failure on October 5 that placed it into safe mode. Now NASA has announced that the telescope has been fixed and will return to normal operations.
The failure occurred due to a problem with one of the six gyros which measure the speed at which the spacecraft turns. The Hubble instruments had to be deactivated when the third gyro malfunctioned, which caused the telescope to have problems with turning to new directions and locking on to new targets. Fortunately, there was a backup gyro onboard the spacecraft which the NASA team was able to activate remotely. Although the backup gyro was activated the day after the failure, there were issues with the data that it was sending, as it suggested that the craft was rotating far faster than it actually was.
It took three weeks to rectify the problem with the backup gyro, during which time the NASA scientists commanded the craft to perform various turns and maneuvers, and switched the gyro between different operational modes. The scientists believe that this fixed the problem by clearing a blockage between parts inside the gyro which was causing the inaccurate readings. With the gyro operating effectively, NASA then performed more tests to ensure that the gyro was stable and installed additional safeguards should the problem arise again in the future. The gyro was recalibrated by setting the telescope to rotate to point at various locations in the sky and by instructing it to lock on to targets, all of which were performed effectively.
The last stage of fixing the telescope was reactivating the instruments which had been powered down, and checking that it was sending back data correctly. All went well, and the telescope started transmitting data back to Earth for the first time since the problem arose on October 5.
Now the gyro is running correctly and the instruments have been reactivated, so Hubble can resume its data collection, capturing beautiful images of space objects.
Editors’ Recommendations
- Giant NASA space laser satellite to gauge impact of climate change on ice sheets
- 11 common Google Pixel problems and how to deal with them
- Did your Windows 10 audio stop working after the update? Microsoft has a fix
- Windows’ October 2018 update wants to be best buds with your phone
- Joby’s tiny tripods double as selfie sticks and hide four different modes
Downloading Google Chrome through Microsoft Edge is dangerous
New Windows 10 PC owners should be careful about downloading Google Chrome through Microsoft Edge, as Bing is apparently returning search results that contain malware and adware.
There is a running joke that the only purpose of Microsoft Edge is to download Google Chrome, but it appears that the tables could easily turn for users who are not careful. Fortunately, Twitter user Gabriel Landau did not fall prey to a fake Google Chrome download page returned by a Bing search.
Brand new Win10 laptop. Attempt to install Chrome. Almost get owned with my very first action. Why is this still happening in 2018, @bing? Please explain. pic.twitter.com/uYJhu7xa9H
— Gabriel Landau (@GabrielLandau) October 25, 2018
In a video that Landau posted on his Twitter account, he showed how he searched for “download chrome” on Bing through the Microsoft Edge browser. He clicked on the first link that appears, which is marked as from “google.com,” leading to what appears to be the legitimate Google Chrome download page.
However, upon closer inspection, the URL for the page is “googleonline2018.com.” The page is not an exact replica of the official Google Chrome landing page, but it looks real enough to trick users. In addition, clicking on the Download Chrome button starts the download for ChromeSetup.exe, but checking the file’s properties reveals that it is digitally signed by a company named Alpha Criteria, which is obviously not Google. It is very likely that the fake file contains malware.
An investigation by How To Geek revealed that the fake website is actually marked as a “deceptive site” by Google Chrome, but it is not flagged as such by Microsoft Edge and Bing. The Bing search query was reproduced on some systems, not all, but it was only appearing on Microsoft Edge.
The major issue here is that Bing is apparently not checking the URL of the search result, allowing what is likely malware to be downloaded by unsuspecting users. Making matters worse is that Bleeping Computer reported the same advertisement in April, so this is a recurring issue.
A Microsoft spokesperson reached out to How To Geek to say that the fake ad has been removed from Bing, and that the account associated with the malicious content has been banned. However, there was no explanation on why the ad was marked as from “google.com,” and no assurance that the ad will not reappear again after a few months.
The issue drives home the point that users should always be extra careful about downloading anything from the internet. Even if websites and links look legitimate, it is always best to check everything thoroughly to prevent headaches from malware infections.
Editors’ Recommendations
- How to change your Windows 10 login screen background and desktop wallpaper
- Canon and Nikon’s new mirrorless cameras impress. Should Sony start worrying?
- Cord-cutting 101: How to quit cable for online streaming video
- Colby Brown isn’t afraid to fail (or fall) in pursuit of the perfect travel shot
- Google plans crackdown on tech-support scams appearing in search ads
Let your case pull double-duty protecting your Pixel 3 and your money
Wallet cases are a great option if you want to cut down on your pocket carry. Because the Pixel 3 supports wireless charging, it’s doubtful you’ll find too many wallet case styles with the card slots on the back, but there are a growing number of folio-style wallet cases to choose from. We’d recommend the ProCase Genuine Leather Wallet Case ($26) but we’ve got more affordable and more premium options to choose from, too.
Always reliable
ProCase Genuine Leather Case

Available in three colors, ProCase delivers a classic wallet case design made with genuine leather. The inside flap features two card slots and a pocket for storing cash and receipts and the whole thing folds up into adjustable kickstand. Keeps your phone safe and stylish.
$26 at Amazon
Budget folio case
Abacus24-7 Flip Cover Wallet Case

Made of synthetic leather with a clear ID pocket and a hidden money pocket, this folio-style wallet case may just check all your boxes. It can store up to three cards along with some cash and the front cover doubles up as a kickstand.
$10 at Amazon
Stylish and affordable
Maxboost Magnetic Wallet Case

This case from Maxboost is made of synthetic leather to keep the price down but has a nice look to it with white stitching and a stylish magnetic flap. On the inside, you get three card slots and a pocket for cash. Backed by a lifetime warranty.
$10 at Amazon
Real fancy
ProCase Mirror Wallet Case

On top of the three card slots, money pocket, and folding kickstand functionality, this ProCase wallet also includes a small mirror that lets you check on your look without turning on your selfie camera. All in all, a very stylish and functional case.
$11 at Amazon
Premium, dude!
Bellroy Leather Phone Wallet

Bellroy’s premium leather case four card slots — two on the front cover, and two more hidden between the case and the back of your phone. Made from environmentally certified leather and available in five beautiful colors, this case is expensive but the best option for those who want a genuine leather case for the smaller Pixel 3.
$84 at Bellroy
We’ll be updating this list with other wallet-style case options as they emerge, but for now we’ll continue to swoon over that beautiful Bellroy Leather Wallet case. It’s definitely worth picking up if it fits in your budget, even if our needs are satisfied by with the ProCase Genuine Leather Wallet Case.



