#Check Permissions

1 messages · Page 1 of 1 (latest)

wraith sequoia
#

How do I check what permissions a user has in a guild? I have literally no idea and I didnt see a helper function for it or anything

toxic socket
#

This part is added by me though so you may want to change that depending on if you want to keep the same behaviour or not

zinc hornet
toxic socket
zinc hornet
zinc hornet
toxic socket
#

Likely v19 and above

#

It’s meant to be used with dd cache proxy. If you dont use that then you might have to slightly change the types and/or code

zinc hornet
#

i noticed

#

well

#

ig it is time

#

to mess w cache

zinc hornet
toxic socket
#

You use TS so it’ll error if you’re missing a prop in desired prop

zinc hornet
#

well, there is no error but the bot's commands that requires perms dont work think_rotate

toxic socket
#

Define “don’t work”

#

What function are you using and what is the return value

zinc hornet
#

turns out i was being stupid

#

guild not found

    const guild = await bot.cache.guilds.get(interaction.guildId);
    if (!guild) return console.log('guild not found');```
#

@toxic socket how do i manually populate the cache? (i thought it would be automatic for some reason lolz)

toxic socket
#

To populate you send it to transformer / customizer

zinc hornet
#

so y is it not populating by itself

toxic socket
#

check if you’re receiving guild create payloads

zinc hornet
toxic socket
#

yes

zinc hornet
#

but its not finding the client

#

😭

#

client not found every re-start has a diff error, thats crazy

toxic socket
#

what

zinc hornet
#

basically, now the guilds r getting cached properly, but now its not finding the client in the cache

#

for some reason

#
    const client = await bot.cache.members.get(interaction.guildId, bot.id);
    if (!client) return console.log('client not found');```
#
const getProxyCacheBot = (bot: Bot<BotDesiredProperties, DesiredPropertiesBehavior.RemoveKey>) =>
  createProxyCache(bot, {
    desiredProps: {
      guild: ['channels', 'id', 'roles', 'ownerId', "members"],
      member: ['roles', 'id', 'guildId'],
      role: ['permissions', 'id', 'position', 'guildId'],
      channel: ['id', 'type', 'guildId', 'parentId', 'permissions', 'internalOverwrites'],
    },
  });``` thats how my proxy cache is
toxic socket
#

that looks fine

#

log guild object from cache

zinc hornet
#

k

zinc hornet
#

the members are there

toxic socket
#

is the bot in there

#

also check if interaction guild id is there

zinc hornet
#

yes

toxic socket
#

now check interaction guild id

#

maybe someones running it in dm

zinc hornet
#

its a test bot

toxic socket
zinc hornet
#

oh the horror

#

bro im so stupid

#

😭

#

@toxic socket can you kill me

#

lowkey

#

get: (id: bigint, guildId: bigint)
const client = await bot.cache.members.get(interaction.guildId, bot.id);

#

spot the error