Don’t ever post your token on the internet.Ĭopy this code, paste in your token at the bottom, and save it as index.js in a dedicated folder. Obviously, the token in the screenshot here is fake. The last line logs in with the token from the bot portal.If the message just says “ping,” then it will reply with “Pong!” The client.on('message') block will fire everytime a new message is posted to any channel. Of course, you’ll need to check the message content, and that’s what the if block does.Here, it’s just configured to log its name to the terminal. The client.on('ready') block will fire when the bot starts up.Line one imports the module into an object called “Discord,” and line two initializes the client object. The first two lines are to configure the client.This code is taken from the discord.js example. You could just use notepad, but we recommend either Atom or VSC.Ĭonsole.log(`Logged in as $!`) You can install it by running the following command: npm i -g nodemon It’s a command line app that monitors your bot’s code and restarts automatically on changes. We also recommend installing the nodemon tool.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |