#help with guild fetching

1 messages · Page 1 of 1 (latest)

brisk temple
#

Lets use a thread

outer holly
#

thanks

quick crest
#

<Client>.guild.fetch()

brisk temple
#

Can you share the entire file?

outer holly
#

sure

brisk temple
#

Can you use codeshare?

outer holly
#

sure

brisk temple
#

I noticed in the snippets you sent that it you used application commands and used guild-related code as well.

outer holly
#

i know

#

but to set the commands for the bot it needs to fetch guild ids

brisk temple
#

The problem is you are using guilds.commands and at the top application.commands

#

application commands are 'global', so not for any specific guild.

outer holly
#

what im doing is im setting perms for slash commands so i need to fetch the guild id im gonna be using and then fetch the perms users have

brisk temple
#

You can do a loop for all guilds I believe let me look at the docs

#

client.guilds.cache.forEach()

#

In case you have multiple guilds I guess

outer holly
#

hhm

#

i cant find the right one tho

#

got it but

#

return client.guilds.cache.forEach(permissions)&& !x.managed
^

TypeError: object is not a function

#
if(!permissions) return null;
                     return client.guilds.cache.forEach(permissions)&& !x.managed
                 };```
#

ohhhhhhhhhhhhhhhhhhhhhhhh i fucked the code up lmaoooooooooooo missing an array

brisk temple
#

Could be

#

Also you don't just use foreach on permissions

#

You need to make an arrow function which will be executed forEACH command

outer holly
#
if(!permissions) return null;
                     return guilds.roles.cache.filter(
                         (x) => x.permissions.has(permissions) && !x.managed)


                 }```
#

now i just have to const guilds and im done i think

#

return guilds.roles.cache.filter(
^

ReferenceError: guilds is not define

brisk temple
#

Because you need to fetch them as I said

outer holly
#

yup

#

how do i get a guild id tho

#

@brisk temple

#

what

#

return guilds.roles.cache.filter(
^

TypeError: Cannot read property 'cache' of undefined