#MainGuild is not defined

1 messages ยท Page 1 of 1 (latest)

cedar hemlock
#

t

#

fucking hate slowmode

#

and its chaos

west valve
#

lmao

cedar hemlock
#

are you in the same function?

west valve
#

๐Ÿ’€ shit

#

i put it in the end because i got told to console.log a variable outside the function before in this channel ๐Ÿ’€

cedar hemlock
#

nono

#

wait

#

send me the code here

#

cant find it

west valve
#

ong i hate this shit

#

"undefined"


    client.on('ready', async () => {
        const MainGuild = await client.guilds.cache.get("984989513757626368");

        console.log(MainGuild)

        MainGuild.commands.set(CommandsArray).then(async (command) => {
            const Roles = (commandName) => {
                const cmdPerms = CommandsArray.find((c) => c.name === commandName) + cmdPerms;
                if(!cmdPerms) return null;

                return MainGuild.roles.cache    .filter((r) => r.permissions.has(cmdPerms));
            }

            const fullPermissions = command.reduce((accumulator, r) => {
                const roles = Roles(r.names);
                if(!roles) return accumulator;

                const permissions = roles.reduce((a, r) => {
                    return [...a, {id: r.id, type: "ROLE", permission: true}]
                }, []);

                return [...accumulator, {id: r.id, permissions }]
            }, []);
            
            await MainGuild.commands.permissions.set({ fullPermissions });
        }); 
    });
}


cedar hemlock
#

ye thats perf

#

are you sure that is the guild id

west valve
#

ill redo it

#

if its not forgive me

cedar hemlock
#

just check if it is, ive done that too many times xd

west valve
#

nope its correct ๐Ÿ’”

cedar hemlock
#

the fuck

west valve
#

i bet you its a spelling mistake somwhere else or a missing semicolon

cedar hemlock
#

did this work before?

#

colons dont matter in sj

#

js

#

i never use em

#

unless in a for loop

#

xd

west valve
#

yep, but i have have seen a lot of "undefined reading of property" errors

cedar hemlock
#

try it with another guild the bot is in

#

sure it has all intents?

west valve
#

its the only one, is it worth going through the hastle

cedar hemlock
#

you have the intents?

west valve
#

let me show you

#

here, also i have never seen those "partials" or "makeCache"

cedar hemlock
#

always done it like this

#

make sure your intent thing includes flags.guilds

west valve
#

it hasnt worked for me before, when i followed the guide it didnt have enough since i jumped straight to audit logs and things

#

ill try that one. im not using much anyway

cedar hemlock
#

try it with the guide, that i can do more with than the bitfields (i can look into it if you want

#

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.GUILD_MEMBERS],

}),

})

#

if you try with this

west valve
#

yeah im not using messageEmbed in my index.js file ill just copy and paste that

cedar hemlock
#

add Intents to the const {client, collection thing

west valve
#

i had it before since as i said i followed the guide

cedar hemlock
#

then it should do it all for you

west valve
#

still same error and MainGuild giving undefined when i console.log()

cedar hemlock
#

wtf

#

which version of djs?

#

dont say 12

#

xd

west valve
#

latest version, but this was a new project and im pretty sure they made smaller version(s)

cedar hemlock
#

ight

#

super weird

west valve
#

do you think theres any resources i could use for this?

cedar hemlock
#

console.log(client.guilds.cache)

west valve
#

sure ill try that

cedar hemlock
#

to see if theres any guilds there

#

idk if thats a valid call

#

it should be

west valve
#

Collection(0) [Map] {}?? i have a Developer Folder in my commands and thats where my ping.js is but im pretty sure i have developer imported on there.

still same error btw

cedar hemlock
#

its not getting any guilds

#

are you logging your bot with the right token?

#

idk if you have multiple

west valve
#

Y e p

cedar hemlock
#

but it seems this bot isnt in any discord

#

or

#

what the fuck ahha

west valve
#

the bot console.log 'ed the ready event

cedar hemlock
#

it works for my testing bot :/

west valve
#

man i fr hate this shit ๐Ÿ’€

cedar hemlock
#

i have more than a dozen bots

west valve
#

hmm

#

maybe

cedar hemlock
#

try regenerating

west valve
#

well i have to go now, ok sure

cedar hemlock
#

and replacing the old token

#

or

#

console.log(client.user.tag)

#

to check if its the right one

#

do that first

west valve
#

hhmm. ill try that

cedar hemlock
#
   console.log(`Connected as ${client.user.tag}`)
west valve
#

holy god danm shit

cedar hemlock
#

i have this default in my client.on ready, cus i always forget

#

xd

west valve
#

i want to kill myself immediatly

cedar hemlock
#

not worth it

west valve
#

well this conversation was absolutely useless

cedar hemlock
#

Xd

west valve
#

no its because i made a new bot and i didnt invite it to any server ๐Ÿ’€

cedar hemlock
#

xd

west valve
#

sorry for wasting your time ๐Ÿ—ฟ

cedar hemlock
#

thats 10 minutes of our lives we arent getting back

#

oh i couldnt care less for my time, happy we got to the bottom of it

west valve
#

lmao

#

well wasting time is known in js

cedar hemlock
#

Have a wonderful day/night

cedar hemlock
west valve
cedar hemlock
#

same for me, good night