discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.38k stars 3.97k forks source link

Collector.js Unexpected token #3488

Closed zhiyan114 closed 5 years ago

zhiyan114 commented 5 years ago

Please describe the problem you are having in as much detail as possible: when the script is ran, the following error produced:

/home/pi/node_modules/discord.js/src/structures/interfaces/Collector.js:203
  async *[Symbol.asyncIterator]() {
        ^

SyntaxError: Unexpected token *
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/pi/node_modules/discord.js/src/structures/MessageCollector.js:3:19)

Include a reproducible code sample here, if possible:

const Discord = require('discord.js');
const client = new Discord.Client();
var mysql = require('mysql');
var Raven = require('raven');

//Raven.config('SomeId').install();
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
//  Raven.context(function () {

  if(msg.channel.type != "dm" && msg.content.startsWith('!')) {
    msg.channel.send('The bot will only function if it called in DM');
  } else if(msg.channel.type == "dm" && msg.content != "!something") {
    msg.channel.send('The bot will only handle The Something, no other command can be used. To verify, type !verify');
  }
  if (msg.content === '!something') {
    // Do the stuff
//    var dbconn = mysql.createConnection({
//      host: "localhost",
//      user: "yourusername",
//      password: "yourpassword",
//      database: "mydb"
//   });
  }
//});
});

client.login('code');

Further details:

tipakA commented 5 years ago

Please update Node.

If you need help with discord.js installation or usage, please go to the discord.js Discord server instead: https://discord.gg/bRCvFy9 This issue tracker is only for bug reports and enhancement suggestions.

zhiyan114 commented 5 years ago

Alright, thank you (The website stated the minimum version was 6.0.0)

monbrey commented 5 years ago

Alright, thank you (The website stated the minimum version was 6.0.0)

That's for the stable version. You appear to be on the master branch, where the documented minimum version is 10.0.0