discord-akairo / discord-akairo

A bot framework for Discord.js.
https://discord-akairo.github.io/
MIT License
557 stars 128 forks source link

akairo does not support ES6 syntax #122

Open castdrian opened 4 years ago

castdrian commented 4 years ago

Using latest master & djs master Node 13.11.0:

import { AkairoClient } from 'discord-akairo';

results in

SyntaxError: The requested module 'discord-akairo' does not provide an export named 'AkairoClient'

as workaround you have to do

import Akairo from 'discord-akairo';

class GideonClient extends Akairo.AkairoClient {...

also the commandhandler uses require() on the files instead of import, resulting in

Error: [ERR_REQUIRE_ESM] [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Adrian\code\Gideon\akairo\cmds  \admin\abm.js
  require() of ES modules is not supported.
castdrian commented 4 years ago

here's my branch on which I handled this to work somewhat properly https://github.com/gideonbot/discord-akairo/tree/akairo-es6

castdrian commented 4 years ago

*doesn't fix the broken destructuring

MrZillaGold commented 4 years ago

It is also necessary to make support for files with the extension .mjs and .cjs. At the moment, the library does not process files with these extensions.

GamesProSeif commented 4 years ago

It is also necessary to make support for files with the extension .mjs and .cjs. At the moment, the library does not process files with these extensions.

You can easily allow that with the extensions option in the command handler

papaia commented 4 years ago

We could maybe allow cjs and mjs extensions, combined with a check: if it's an mjs, we await import, otherwise we require. As for the importing of Akairo, we could maybe do something like discordjs/discord.js#3998.

jonahsnider commented 4 years ago

Why not just use the import function for everything?

1Computer1 commented 4 years ago

import does not support reloading as of the moment. Its not a deal breaker, but I'd rather not touch it for now.