Permission check in other guild
How am I supposed to make it so for example I have Invite to MTF context menu that has to invite someone to MTF guild, like, it does its job, but my point is so no person can be invited unless they have Lieutenant+ in MTF guild, how am I supposed to make this permission check? (i'd appreciate if i were to be pinged upon reply)
Solution:Jump to solution
@Boomeravna @UndiedGFX I got it fixed. Instead of passing just userid, I passed entire member object & did member.fetch(true) and of course made sure I am fetched in the 'mtf' guild. Hopefully it is understood
26 Replies
make a precondition and in that precondition use
this.container.client.guilds.get('the id of the other guild').roles.get('the id of the role')
and then do the checks you want to do.i'll see it soon
So apparently it does work but my command seems to do check only for the first time
It doesn't care if someones role was removed, it will still execute it
And yes, I do fetch it
show code pls
this.container.client.guilds.get is not a function is also what I get in the console, and I've just noticed it
because guilds.get is not a method?
it is pre djs v12
it is guilds.cache.get
yeah I didnt realize, just followed the example above
the same should be done for RoleManager and ChannelManager instances
Alright I've fixed it but still, the issue persists within role remove
as i said
So like let me explain
these two lines, are obselete
it should be guilds.cache.get and roles.cache.get
and about the "role remove", your code doesnt do anything like that, so i do not understand
Yeah because I tried to elaborate and I didn't
For example someones role gets removed, he still is able to execute the command as if nothing had happened
can you like try fetching roles before running the
if
, maybe discord.js didnt update the cache
even though it should remove the role from cacheSo you expect me to just update them to add cache.get to it?
sorry Im just a little overwhelmed
I'm swapping it
no, what i meant was djs should update the member roles cache when the role is removed
maybe try this again, the issue should not happen
The application did not respond
Also do I revert that or
Oh lord this discord formatting
Let me read
according to the docs, <guilds>.get does not exist
it should be .cache.get
Oh wait
I had old lines copied
Yeah, I have it set to .cache.get
That's the issue I am facing now
and what exactly is causing that
Oh, well, didn't have the role
but yeah, the issue is as I have mentioned
If I update my role when my bot is online, it would still execute it
Or if I ran the bot without roles and then give myself the role, it won't execute thinking I don't have it
"my" are you sure you dont have an OwnerOnly precondition as well wrapped up in the command?
preconditions: ['IsMTFHR'],
And the precondition code you've got
The context menu does not have anything that would restrict it
It does not have anything regarding permissions, just IsMTFHR precondition
So yeah, I haven't found a fix to it
Solution
@Boomeravna @UndiedGFX I got it fixed. Instead of passing just userid, I passed entire member object & did member.fetch(true) and of course made sure I am fetched in the 'mtf' guild. Hopefully it is understood
Thank you for your help though