Closed InvertedStone closed 4 years ago
Can you post your code in a code block? Use: ``` code here ```
@Consoli0 Here is my code
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.content === '!ping') {
message.channel.send('Pong.');
}
});
client.login('NzMwNTIzMjA3ODYxNDAzNzU5.Xwc1Cw.hdU76z49PmqksorH8zAoFY7O7JI');
Please do not ignore the issue template. If you have any questions about the discord.js library usage, please ask them in the Discord Server instead. https://discord.gg/bRCvFy9 **
Your syntax errors are not issues with the library and don't belong here. We suggest you install a linter. Additionally, you'll want to regenerate your token immediately.
Smarter people than me also suggested it could be out-of-date Node. The library requires node v12.0.0 or higher.
Firstly: Please re-read our section about tokens and why you should never give them to anyone (including a github thread). Luckily Discord token invalidation is integrated into GitHub and you will need to get a new one regardless.
Secondly: Your heading and error paste show different issues, quite odd.
I can not reproduce this behavior and can run the linked code (and "resulting code sample" listing) without any issues. Please provide the actual versions of both discord.js and node and make sure you run both commands in your bots project folder.
npm list discord.js
node --version
I am running on node.js v13.6.0
and discord.js 12.2.0
and 11.6.4
respectively.
How are you running your code? That error does not appear to coincide with the code you provided, and the stack trace isn't helpful either
Firstly: Please re-read our section about tokens and why you should never give them to anyone (including a github thread). Luckily Discord token invalidation is integrated into GitHub and you will need to get a new one regardless.
Secondly: Your heading and error paste show different issues, quite odd.
I can not reproduce this behavior and can run the linked code (and "resulting code sample" listing) without any issues. Please provide the actual versions of both discord.js and node and make sure you run both commands in your bots project folder.
npm list discord.js node --version
I am running on node.js
v13.6.0
and discord.js12.2.0
and11.6.4
respectively.
I have regenerated the token :D so no need I use the recommended node and latest discord.js.
Please do not ignore the issue template. If you have any questions about the discord.js library usage, please ask them in the Discord Server instead. https://discord.gg/bRCvFy9 **
Your syntax errors are not issues with the library and don't belong here. We suggest you install a linter. Additionally, you'll want to regenerate your token immediately.
Smarter people than me also suggested it could be out-of-date Node. The library requires node v12.0.0 or higher.
As i said i have regenerated the token, my node is the one recommended in the website
How are you running your code? That error does not appear to coincide with the code you provided, and the stack trace isn't helpful either
I followed this toturial.
Please understand that "recommended" is not a version and actually execute the provided commands and show the output:
npm list discord.js
node --version
Without further information there is nothing anyone can do. The tutorial you keep linking is completely valid and runs on node.js v13.6.0
(anything newer than 12.0.0) and discord.js 12.2.0
and 11.6.4
without any issues.
Thanks, the problem was i was using an older version of node thx :D
I have followed every step, but fore some reason it gives me an error message which is the following:
SyntaxError: Unexpected token ) at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (C:\Users\Home\Desktop\hexbot\node_modules\discord.js\src\index.js:3:14) at Module._compile (module.js:570:32)
My code is the same thing as the list. I use the recommended node.js and Visual Studio Code. Any help is appreciated :D