I need help with bot making on Discord.

Where exactly did you pick up the idea to use  node . ? Because I don’t think that is the command you actually want to use. You are more likely to want to start your application. Thus, you need to provide the name of the file your application consists of. In your case that should be  app.jsbot.js , or similar. At least something ending in  .js.

What  node .  does, is just give the current directory you’re in ( . means “current directory” in the shell) to the node interpeter. It’s not something Node can handle.

So just try to run your  bot.js or  app.js file directly using  node bot.js  (or  node app.js ).

Sorry for the late response, was dealing with school and still am. In the video I watched (https://www.youtube.com/watch?v=X_qg0Ut9nU8)

Said to use the ‘node .’ 

Hi @demonwolffang ,

I suspect that the person in the video uses  node .  because his main code file is called  index.js. So you could either:

  • Also name your code file  index.js  instead of bot.js / app.js ;
  • or run it using  node bot.js node app.js

The file was automatically named index.js and still is. I tried running ‘node .’ in CMD and the node.js app, but continue getting the same response 

node .

Hi @demonwolffang ,

Would it be possible to push your project to a GitHub repository. I’d love to investigate using my own environment and understand the bigger picture.

What do you mean? 

If you’re comfortable with it, I’d like to receive a copy of your code so I can test out some things on my own computer.

That works way faster than asking you to test something and letting you post it back here.

Sure. I’ll get it set up for you. 

I need to re-make it because for some odd reason my index.js was deleted? 

Is there a way to message you the bots coding?

Sure @demonwolffang, if you don’t want to share it publicly you can add me as a collaborator on your repository. Alternatively my mail address is publicly availible on my GitHub profile.

Thank you! I’ll get it sent. 

Sadly I dont see the email. I’m still new here. 

Ok I added you to it!!

Mail addresses of people who chose to make them public are availible below their profile picture on their profile page (e.g. https://github.com/mpboom).

I’ve checked your code and made a pull request where the bot is fixed up until the point it works. I’ll highlight the problems below:

  • The token you checked into source control * was invalid. I tested it with a token from a bot on my account and it did work.
  • You had a file called  index.js that runs the entire app. You can then start the app by running  node index.js. If you’d also like to be able to start your app by running npm start , you need to modify the  package.json  a bit. I did that for you in the pull request so you can see what I actually changed.
  • You need to install external packages like  discord.js manually trough NPM. You can define them in your  package.json first, which you already did, and then install them using  npm install. It’ll create a big directory called  node_modules  that you should put in a file called  .gitignore. That way, it won’t be checked into source control (= it won’t be  uploaded to GitHub). I already did the last part (ignoring the  node_modules folder), but since I can’t access your computer you’ll have to run  npm install manually yourself.

As I explained in the PR, you should now be able to run your bot using  node index.js  or  npm start  after reviewing my changes.

If you have any more questions about learning Node - or a different language! - we are here to help!

* Please never check tokens into source control! Instead, store them in a seperate - not checked in - file and retrieve them from there in your application. That way you POINT to the token instead of actually uploading it to GitHub.

I did forget to add the folder for the bot_modules which I did have installed using ‘npm init’ I believe. But thank you so much!! Hopefully I can learn more coding. So thank you so much!

Also, where should I put the .gitignore and should there be anything written in it?

As you can see in my pull request on your repository, the  .gitignore file should be created as a file in the root directory of your repository.

Each line in the file represents a pattern of either a directory or file(s) that it can match. These directories and files will be ignored by Git and thus not checked in and uploaded.

The  node_modules folder should be ignored, so you’ll need to put that in the file. You can see an example here: https://github.com/DemonWolfFang/DiscordBot/pull/1/files#diff-a084b794bc0759e7a6b77810e01874f2 .

1 Like

Can you walk me trough it please? Sadly I dont know where to put the stuff being a noob that I am… 

@demonwolffang you mean helping you with the .gitignore file? I already did, see here: https://github.com/DemonWolfFang/DiscordBot/pull/1/files .