-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tutorial ES6 update #1554
Comments
Thanks for the feedback - we do have plans to rewrite the examples to ES6. In fact, many already have been but the updated guide has not yet gone live. For information on how to use ES6 import correctly, check out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import For example, importing SlashCommandBuilder is The equivalent to the in-line require() you mentioned is the dynamic import: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import |
Thank you for the response. I am looking forward to that update, as every other tutorial I could find also used the require() syntax, despite saying it's updated for ES6... In regards to your helpful advice and links: 1: I did import the SlashCommandBuilder in that way, but running the code gives me an error that SlashCommandBuilder is not a constructor. Worked fine if I c/p the lines directly into my index.js though. 2: I did try the import() function, but trying to use the object that should have been imported, was not working for me. Probably something I am doing wrong, but so far unable to work it out. |
Along with ES6, it will be great if you add TypeScript examples :) |
If you are trying to migrate const command = require(filePath); to ES6, here's how you should do it: const command = (await import(`file://${filePath}`)); |
Is your feature request related to a problem? Please describe.
Your current tutorial is filled with require() and module.exports. Converting to the ES6 import/export does not work.
Describe the solution you'd like
I would like to see an updated tutorial with proper ES6 import/export so I can properly learn current coding methods.
Describe alternatives you've considered
No response
Additional notes
I do not wish to learn outdated coding methods, so converting my project to CommonJS is a last resort that I would prefer not to do.
The text was updated successfully, but these errors were encountered: