Discord.js: Discord.js Async Await Problem

Created on 15 Nov 2017  ·  5Comments  ·  Source: discordjs/discord.js

I am having an issue where the async and await are constantly throwing an error:

capture

While there's nothing wrong with my code:

Here's the async part:

client.on("message", async message => {
           // commands
});

And here's the command with the await part:

    if(command === "mutual") {
        if(args.length < 1)
            return message.reply('Please provide a name of a Discord server you are in!');

        const query = args.join(' ').toLowerCase();
        const guild = client.guilds.find(guild => guild.name.toLowerCase() === query);

        if(!guild)
            return message.channel.send('That server could not be found!');

        const mutual = client.users.filter(user => inGuild(message.guild, user) && inGuild(guild, user));

        const {url} = await client.utils.gistUpload(mutual.map(user => `-${user.username}`).join('\n'), 'txt');

        message.channel.send({
            embed: client.utils.embed(`Mutual members of ${guild.name}`, limitTo(mutual.array().map(user => user.username), 25, ', '), [
                {
                    name: 'Full List',
                    value: url
                }
            ])
        }).delete(30000);
    }

If anyone is able to help me with this, that would be amazing! Thanks in advance

question (please use Discord instead)

Most helpful comment

@DakshMiglani I see that you've since edited your comments, but I see all 👁 . Please check your own knowledge before suggesting untrue notions, such as your claim that async cannot be used on arrow functions. Thanks.

All 5 comments

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

@Dev-Yukine Oh, oops, sorry, I didn't know that. I never really used Github before, to be honest

@DakshMiglani's answer won't work.
Update node...

If he did have the right node version, he wouldn’t get this error.

@DakshMiglani I see that you've since edited your comments, but I see all 👁 . Please check your own knowledge before suggesting untrue notions, such as your claim that async cannot be used on arrow functions. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LLamaFTL picture LLamaFTL  ·  3Comments

iCrawl picture iCrawl  ·  3Comments

tiritto picture tiritto  ·  3Comments

tom-barnes picture tom-barnes  ·  3Comments

Blumlaut picture Blumlaut  ·  3Comments