I need help with bot making on Discord.

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 .

Yes, but due to me being new (and I’m stupid with coding and learning how to do it) I don’t know where to put it or if the file needs a specific path or where to put it. 

See the link I posted in my last post. The filenames and paths are on top of the file in a grey bar. In the case of the  .gitignore file that filename is just  .gitignore and it’s path is the root. So putting a  .gitignore file in the root of your repository should work fine.

The root of the repository? 

Yes, that is right.

Which I have absolute no idea what it means. 

It’s just the base directory. If you are unsure as to what to do, you can always merge my PR here https://github.com/DemonWolfFang/DiscordBot/pull/1 by clicking Merge pull request. You’ll then be able to pull the changes into your project locally either by using a GUI Git client (like GitHub Desktop for example), or by using the command line  git pull. You’ll then see the changes pop up automatically and will know what I mean with the  .gitignore  file.

Using that preset code, I also encountered some problems. I don’t have my version of that preset code, but when I ran your code into Esprima, the result showed that at the line where it goes ‘“name”: “demonsbot”,’ the colon became an ‘unexpected token’. I have run into similar problems and I would like to enquire if anyone knows how to solve this problem. Yes, I did read the following stuff that was already posted but frankly, I have no idea what you two just discussed.

Old post, issue was fixed long ago. Running the code returning unexpected token means you’re either missing a piece of code or didn’t finish it.

But what exactly am I missing? Would you please kindly share to me your code for the package? And yes, I know this is an old post. I just decided to pick up coding recently and noted this down while trying to troubleshoot my stuff.