I need help applying functions to my discord bot.

Here is the code block for the function of confirm:
if (confirmation.customId === 'confirm') {

await confirmation.update({
embeds: [{
title: 'Lockdown confirmed!',
description: `The lockdown will commence in 5 seconds.`,
color: '15548997',
}],
ephemeral: true,
components: [],
},);

}
if (confirmation.customId === 'confirm') {

await confirmation.update({
embeds: [{
title: 'Lockdown confirmed!',
description: `The lockdown will commence in 5 seconds.`,
color: '15548997',
}],
ephemeral: true,
components: [],
},);

}
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
d.js toolkit
d.js toolkit7mo ago
- 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
NyR
NyR7mo ago
#rules 3 we won't write codes for but we can guide you
paxton!!
paxton!!7mo ago
okay if someone could guide me thatd be great im profficient in js but not this library
d.js docs
d.js docs7mo ago
:method: PermissionOverwriteManager#edit() Edits permission overwrites for a user or role in this channel, or creates an entry if not already present.
paxton!!
paxton!!7mo ago
how do i define the channal channel* or is this the channel the message was sent it in*
NyR
NyR7mo ago
Do you want to edit the channel where interaction took place or some other channel?
paxton!!
paxton!!7mo ago
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
NyR
NyR7mo ago
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
paxton!!
paxton!!7mo ago
what do i put for <client>
NyR
NyR7mo ago
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
paxton!!
paxton!!7mo ago
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
NyR
NyR7mo ago
The first parameter in overwrite must be userid or role id then overwrites options
paxton!!
paxton!!7mo ago
so roleId: 123445667, then put the change
NyR
NyR7mo ago
It's explained here if you go to the link
paxton!!
paxton!!7mo ago
i see i scrolled a little bit more and saw
const channel = interaction.client.channels.cache.get('1214631357209387089');
channel.permissionsOverwrites.edit({
id: 1171206894799552622,
deny: [PermissionsFlagsBit.ViewChannel],
}
)
const channel = interaction.client.channels.cache.get('1214631357209387089');
channel.permissionsOverwrites.edit({
id: 1171206894799552622,
deny: [PermissionsFlagsBit.ViewChannel],
}
)
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
Want results from more Discord servers?
Add your server