#help
1 messages · Page 1 of 1 (latest)
ever seen something like this? js const x = { a: 1, b: 2 }?
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
you can make one, and then put to it all your invite uses
no
cuz u dont want it or
-
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.
-
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
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
that's genuinely not discord's fault...
that's how the language you are using works
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)
xD
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
what i tld you couple times already
make a separate obejct
throw into it what you need, so invite code and uses
when I don"t jave .uses < inv.uses in usedInvite it's working
but idk will it make errors
or bugs
what
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)