![]() ![]() Press the "Run" button and you should see Replit installing the Discord library in the output pane on the right, as in the image below. In the default index.js file that is included with your new repl, add the following line of code: Our repl will automatically pull in all dependencies. Normally we would install this third-party library through npm, but because we're using Replit, we can skip the installation. We don't need to reinvent the wheel as there is already a great Node wrapper for the Discord bot API called discord.js. Over at Replit, create a new repl, choosing "Node.js" as your language. The first thing we need to do is create a Node.js repl to write the code for our Discord bot. Now we can get to the fun part of building a brain for our bot! Creating a repl and installing our Discord dependencies After completing the captcha, you should get an in-app Discord notification telling you that your bot has joined your server. Select the server we created in the step before this and hit the "Authorize" button. Visit the URL that you created in your web browser and you'll see a page similar to the following where you can choose which server to add your bot to. ![]() the application ID, not the secret bot token).Ĭreate a URL that looks as follows, but using your application ID instead of mine at the end (the link calls the application ID "client_id"): To add a bot to your server, you'll need the Application ID from the "General Information" page that we looked at before when we created our ReplBotApplication (ie. Our Discord bot is still just a shell at this stage as we haven't written any code to allow it to do anything, but let's go ahead and add the bot to our Discord server anyway. Adding your Discord bot to your Discord server Soon we'll invite our bot to chat with us as well. Once the server is up and running, you can chat with yourself, or invite some friends to chat with you. Press "Create a server" in the screen that follows, and then give your server a name. Press the "+" icon, as shown below, to create a server. If you don't have a Discord server to add your bot to, you can create one by either opening the desktop Discord application that you downloaded earlier or returning to the Discord home page in your browser. ![]() Take note of your token or copy it to your clipboard, as we'll need to add it to our code soon. You can get the token by pressing "Reset Token", and then copy it to your clipboard by pressing "Copy". Anyone who has the bot's token can prove that they own the bot, so you'll need to be careful not to share this with anyone. The last thing we'll need from our bot is a token. Click "Yes, do it" when Discord asks if you're sure about bringing a new bot to life. The next step is to add a bot to this application, so head over to the "Bot" tab using the menu on the left and press the "Add Bot" button, as shown below. You have now created a Discord application. ![]() You can also rename the application and provide a description for your bot, then press "Save Changes". You can come back later and get it from this page, or copy it somewhere so you can find it when you need it. The first thing to do on the next page is to note your Application ID, which you'll need to add the bot to the server. Visit the Discord developer's page and press the "New application" button, as in the image below.įill out a name for your bot and select "Create". Once you have an account, you'll want to create a Discord application. You can sign up for a free account over at Discord, and you can download one of their desktop or mobile applications from the Discord homepage. Creating a bot in Discord and getting a token Let's get through these admin steps first and then we can get to the fun part of coding our bot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |