#help

1 messages · Page 1 of 1 (latest)

zealous coral
#

@split cedar

#

so

#

i still don"t get it

split cedar
#

ever seen something like this? js const x = { a: 1, b: 2 }?

zealous coral
#

ye

#

its object

#

what with that

#
        if (member.partial) member = await member.fetch()

        const cachedInvites = client.guildInvites.get(member.guild.id)

        const newInvites = await member.guild.invites.fetch()

        const usedInvite = newInvites.find(inv => cachedInvites.get(inv.code).uses < inv.uses)

        if (!usedInvite) return; 
#

so this is the code

#

and now

split cedar
#

you can make one, and then put to it all your invite uses

zealous coral
#

still dont get it how

#

can u do it for me lol

split cedar
#

no

zealous coral
#

cuz u dont want it or

split cedar
#
  1. We expect you to have a solid understanding of JavaScript. Do not ask general questions here. There is a countless number of exceptional online resources at your disposal, some of which we have provided for you in resources. We can usually point you in the right direction, but don't expect us to teach you the fundamentals from scratch.

  2. Don't expect us to hold your hand entirely. We can help you understand concepts and locate the correct resources, but not write your code for you.

and i'm not getting paid for this + kinda busy

zealous coral
#

oh

#

but dude

#

idk what i did wrong

#

i can't understand you

split cedar
#

i told you exactly that it's not entirely your fault

#

but if i tell you about things like "pass by reference" you will not understand it

zealous coral
#

okay so

#

its not my fault

#

how i can fix

#

discord's fault

#

or someone elses

split cedar
#

that's genuinely not discord's fault...

#

that's how the language you are using works

zealous coral
#

hmm

#

so

#

wait

#

STILL DONT GET IT

#

where is error

#

problem

#

or whatever

split cedar
#

the issue you're having is that the invite object is not a different object between what's in your cachedInvites and what you're fetching. this means that it's the same object but in a different place. this means that if the object gets updated, all other places will have the updated object as well, since those are just pointing to that one object and not having their own, completely different object. you can see that on what i sent above: x is an object, then i do let y = x essentially referencing that object, but not making new one. since both x and y are the exact same object in memory, changing the object through either x or y will change that one object (as that's the only object that exists)

zealous coral
#

xD

split cedar
#

told you you wouldn't get it

#

if you would create a new object to store whatever you want from the invite, that object would be a completely new object and would not be affected by the referencing you're experiencing

zealous coral
#

what now

split cedar
#

what i tld you couple times already

#

make a separate obejct

#

throw into it what you need, so invite code and uses

zealous coral
#

when I don"t jave .uses < inv.uses in usedInvite it's working

#

but idk will it make errors

#

or bugs

split cedar
#

what

zealous coral
#
const usedInvite = newInvites.find(inv => cachedInvites.get(inv.code))
#

this works

#

and it fetchs inviter

#

and invite

#

but do I need to increase uses

#

is it important

#
    {
      code: 'k7Yba4gh',
      type: 0,
      expires_at: '2022-08-05T11:51:35+00:00',
      guild: [Object],
      channel: [Object],
      inviter: [Object],
      uses: 1,
      max_uses: 0,
      max_age: 604800,
      temporary: false,
      created_at: '2022-07-29T11:51:35.261000+00:00'
    },
#

this happens

#

when i log

#

cachedInvites

#

TypeError: Cannot read properties of undefined (reading 'uses')

#
        const usedInvite = newInvites.find(inv => cachedInvites.get(inv).uses < inv.uses)