Discord.js bot code error


#1

Hello

I was coding my bot when this appeard:

ReferenceError: command is not defined
at Object.<anonymous> (/app/index.js:171:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

Here is the link to my code: https://glitch.com/edit/#!/join/bb123f40-1975-44f6-91d8-5455fa85a0c2

Can you please help me?


#2

Hey @TheBigerGamer I think you want top move that code up into your message handler which starts at https://glitch.com/edit/#!/minigam1ng-network-discord-bot?path=index.js:53:0. In fact you’ll have to have it after the line at https://glitch.com/edit/#!/minigam1ng-network-discord-bot?path=index.js:69:0 where you define the command variable from the message contents.

Just to make sure you understand, when you post a join token as you have here that will allow anyone reading this post to join your project as a full member, which means they can delete files or the whole project if they wanted to. Nothing we can’t help you recover from, but if you made your project public people could read it and give pointers without being able to do destructive things. You can also ask for help as described in the help docs, which gives you a little more control.