I need help applying functions to my discord bot.
Here is the code block for the function of confirm:
i need a way to remove the sendmessage permissions of the role
1171206894799552622
of certain channels, if someone could write the code it'd be great, the id's are below.
1174066163941126215, 1174066275618664560, 1174066357797658764, 1174066422637408396
59 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OP#rules 3 we won't write codes for but we can guide you
okay
if someone could guide me thatd be great
im profficient in js but not this library
:method: PermissionOverwriteManager#edit()
Edits permission overwrites for a user or role in this channel, or creates an entry if not already present.
how do i define the channal
channel*
or is this the channel the message was sent it
in*
Do you want to edit the channel where interaction took place or some other channel?
i want to edit the channels: 1174066163941126215, 1174066275618664560, 1174066357797658764, 1174066422637408396 denying sendmessages for the role 1171206894799552622
if you could guide me thatd be great
also, ive tried attaching the code to the top of the if statement, but for some reason, the catch statement instantly initializes instead of waiting for timeout
thats why i was wondering if you could tell me how to properly insert the code
You can put the channels id in an array and use for...of loop to iterate over it, and inside the loop get the channel with
const channel = <Client>.channels.cache.get('id')
then call channel.permissionsOverwrites.edit() inside the loop
what do i put for <client>
It's your bot's instance, almost all structures from discordjs has that property, so if you have interaction , you can access it via
interaction.client
alright
i will do that
to be clear
const channel = interaction.client.channels.cache.get('1214631357209387089');
channel.permissionsOverwrites.edit({
SendMessages: false
}
)
but where do i define the id for the role being editted
The first parameter in overwrite must be userid or role id then overwrites options
so roleId: 123445667,
then put the change
It's explained here if you go to the link
i see
i scrolled a little bit more
and saw
so like this
it does that weird instant catch thing again
idk how to explain
instead of running that code, it runs the catch statement at the bottom
i can send the entire file if youd like