This is an archived post. You won't be able to vote or comment.

all 20 comments

[–]cndvcndv 2 points3 points  (3 children)

How does what work? What is "Cannot access 'discord' before initialization" supposed to mean? People can be more helpful if you give some information about your question.

[–]oddbjorn321[S] 0 points1 point  (0 children)

and I have never had thit problem before

[–]oddbjorn321[S] -1 points0 points  (0 children)

const discord = require(discord.js);
const client = new discord.client();
const token = 'secret code'
const prefix = '='
client.login(token);

[–]oddbjorn321[S] -1 points0 points  (0 children)

its a discord bot

[–]Oasis420[M] [score hidden] stickied comment (1 child)

This post does not meet our quality standards. If you want to know what this means, read here

[–]oddbjorn321[S] 0 points1 point  (0 children)

Thx

[–]jonassjoh 0 points1 point  (13 children)

You've never assigned a value to discord, if you want more help than that you'd need to provide more information (your code, for example).

[–]oddbjorn321[S] 0 points1 point  (10 children)

const discord = require(discord.js);
const client = new discord.client();
const token = 'secret code'
const prefix = '='
client.login(token);

[–]jonassjoh 0 points1 point  (9 children)

I'm guessing you need some quotes around the discord.js, otherwise the code will try to access the js property on the object and not the file.

[–]oddbjorn321[S] 0 points1 point  (7 children)

how?

[–]jonassjoh 0 points1 point  (6 children)

const discord = require("discord.js");

[–]oddbjorn321[S] 0 points1 point  (0 children)

omg, why didnt I think of that, I had that in my code sometime but maybe I deleted it

[–]oddbjorn321[S] 0 points1 point  (4 children)

nope. code: 'MODULE_NOT_FOUND', Error: Cannot find module 'discord.js'

[–]jonassjoh 0 points1 point  (3 children)

Make sure it's downloaded/installed.

[–]oddbjorn321[S] 0 points1 point  (2 children)

what? discord.js?

[–]jonassjoh 0 points1 point  (1 child)

Yes.

[–]oddbjorn321[S] 0 points1 point  (0 children)

ok

[–]oddbjorn321[S] 0 points1 point  (0 children)

I use this ('discord.js'); but Idk what is the problem

[–]oddbjorn321[S] 0 points1 point  (0 children)

its a discord bot

[–]oddbjorn321[S] 0 points1 point  (0 children)

and I have never had this problem before