Error Dashboard

Hello, I have an error in my dashboard. Could you help me because I don't understand what's going on Thanks
TypeError: C:\Users\james\OneDrive\Bureau\boots\src\views\index.ejs:2
1| <head>
>> 2| <%- include('parts/head', {bot, user, path}) %>
3|
4|
5| </head>

C:\Users\james\OneDrive\Bureau\boots\src\views\parts\head.ejs:173
171|
172| <% if(user) { %>
>> 173| <%
174| let guild = bot.guilds.cache.get(config.server.id).members.cache.get(user.id);
175| if(guild) {
176| if(guild.roles.cache.get(roles.administrator) || guild.roles.cache.get(roles.moderator)) {

Cannot read properties of undefined (reading 'guilds')
at eval ("C:\\Users\\james\\OneDrive\\Bureau\\boots\\src\\views\\parts\\head.ejs":75:33)
at head (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:703:17)
at include (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:701:39)
at eval ("C:\\Users\\james\\OneDrive\\Bureau\\boots\\src\\views\\index.ejs":12:17)
at index (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:703:17)
at tryHandleCache (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:274:36)
at exports.renderFile [as engine] (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:491:10)
at View.render (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\application.js:657:10)
at Function.render (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\application.js:609:3)
TypeError: C:\Users\james\OneDrive\Bureau\boots\src\views\index.ejs:2
1| <head>
>> 2| <%- include('parts/head', {bot, user, path}) %>
3|
4|
5| </head>

C:\Users\james\OneDrive\Bureau\boots\src\views\parts\head.ejs:173
171|
172| <% if(user) { %>
>> 173| <%
174| let guild = bot.guilds.cache.get(config.server.id).members.cache.get(user.id);
175| if(guild) {
176| if(guild.roles.cache.get(roles.administrator) || guild.roles.cache.get(roles.moderator)) {

Cannot read properties of undefined (reading 'guilds')
at eval ("C:\\Users\\james\\OneDrive\\Bureau\\boots\\src\\views\\parts\\head.ejs":75:33)
at head (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:703:17)
at include (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:701:39)
at eval ("C:\\Users\\james\\OneDrive\\Bureau\\boots\\src\\views\\index.ejs":12:17)
at index (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:703:17)
at tryHandleCache (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:274:36)
at exports.renderFile [as engine] (C:\Users\james\OneDrive\Bureau\boots\node_modules\ejs\lib\ejs.js:491:10)
at View.render (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\application.js:657:10)
at Function.render (C:\Users\james\OneDrive\Bureau\boots\node_modules\express\lib\application.js:609:3)
51 Replies
Lioness100
Lioness1002y ago
It looks like bot is undefined. Can you show where you are using this view in the javascript?
!" 𝑱𝒂𝒎𝒆𝒔__
I looked in the code & bot is not declared
Lioness100
Lioness1002y ago
I meant where you were using ejs.renderFile Well, that's your problem Did you copy and paste the code from somewhere else? If so, always try to understand what it's doing first so errors like these don't arise
!" 𝑱𝒂𝒎𝒆𝒔__
That's what I'm trying to understand but personally I find my code correct & I don't understand why I have this error
Lioness100
Lioness1002y ago
Because you're not passing in a bot variable
Can you show where you are using this view in the javascript?
Lioness100
Lioness1002y ago
I meant where you were using ejs.renderFile
In src\views\index.ejs you are rendering the head.ejs, and injecting the bot, user, and path variable for use in that file. However, bot is undefined That's the only info I can really give you with this context
!" 𝑱𝒂𝒎𝒆𝒔__
How can I define it if it is already defined?
Lioness100
Lioness1002y ago
I need to see your code lol src\views\index.ejs and the javascript where that's rendered
Lioness100
Lioness1002y ago
You already sent me that, that's not the code I need
Lioness100
Lioness1002y ago
and the javascript where that's rendered
!" 𝑱𝒂𝒎𝒆𝒔__
On the code Javascript & notified with this
<%
//code
%>
<%
//code
%>
Here
Want results from more Discord servers?
Add your server