0

I've already searched around and i'm unable to find the answer to my dilemma. I'm running on node.js and javascript, but unfortunately i'm awful at coding because i'm just now starting out! please give me some tips if i've done anything wrong. anyway! Anytime someone tries to preform a command, this comes up, but my bot comes online. see here! so, I have tried to change the code and my code seemingly looks like this;

var Discord = require("discord.js")

const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const Enmap = require("enmap");

var client = new Discord.Client();

Is there something i'm missing here? thank you in advance!

8
  • Welcome to SO! Looks like you're having trouble at the import stage. Did you already run npm install discord.js? (See installation section of docs here.) Commented Mar 1, 2019 at 14:30
  • yes! ty for the welcome. I have installed the discord.js now and even have tried uninstalling it. anything else that could be causing this problem! cheers! Commented Mar 1, 2019 at 14:59
  • Okay, so your import is working then. Could you share more code? Commented Mar 1, 2019 at 15:56
  • yup! heres a bit more. var Discord = require("discord.js") const { promisify } = require("util"); const readdir = promisify(require("fs").readdir); const Enmap = require("enmap"); var client = new Discord.Client(); client.on('ready', () => { client.user.setActivity('https://git.io/d.js-heroku', {type: 'WATCHING'}); }); client.config = require("./config.js"); client.logger = require("./modules/Logger"); require("./modules/functions.js")(client); Commented Mar 1, 2019 at 17:02
  • Are you referencing Discord in any of your separate requires (like config.js)? You'll also have to import it in there. Not really sure what's going on otherwise. Commented Mar 1, 2019 at 17:45

1 Answer 1

1

You are using var Discord = require("discord.js") so you should try to use const instead of var if you haven't tried this const Discord = require("discord.js")

Sign up to request clarification or add additional context in comments.

1 Comment

Can you edit the answer to explain how and why this should solve the problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.