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
https://cdn.paxton.rip/kZWPCw1QF784 did this isntantly
No...! The link to the doc has a code snippet on how to provide options
no i do
look
i use button builder but im not sure how to run functions for the button
can you tell me how to do that
But this is the wrong way
this is my entire file without any functions
bru
oh!
thats mb
its sending me to catch because of error
what if i want to edit a role id instead of a user
What is the error ? Please show the full stack
no error in console
Provide role id instead of userid
okay
i will try
once again sending me to the catch statement
i will send you the entire js file
no console output tho
Because you do not log errors in your catch block, please log it and show the errors
console.log(e);
And please use one of these to share codes, as it's easier to read
Yeah
TypeError: Cannot read properties of undefined (reading 'edit')
at Object.execute (C:\Users\Paxton Warin\Repositories\Abyss-Bot\commands\moderation\lockdown.js:43:55)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\Paxton Warin\Repositories\Abyss-Bot\index.js:37:3)
cant read the edit property
i define channel properly:
const channel = interaction.client.channels.cache.get('1214631357209387089');
and i think i change the permissions correctly:
channel.permissionsOverwrites.edit('1171206894799552622', {
ViewChannels: False
})
Show full code, how you define channels how you get it, etc and please use one of these to share
ill js send you the entire js file
Not file
what do you want
oh
ill send you the try catch
and everything in there
that will show you
pastebin work?
I want you to show me the full code
like
the repo?
i dont understand
Just the file concerning the error not full repo
???
so you want me to send you the command file
right?
Pastebin
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandB...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I thought you were sending the file as an attachment, mb
oh
Can you log
channel
please and see what it returnsye
Wait...
Pastebin
TextChannel { type: 0, guild: Guild { id: '11711936 - Pasteb...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It's
permissionOverwrites
not permissionsOverwrites
bru
ok we got somewhere
but
now
its saying false is not defined
once again i am not familiar with this library so idk what it requires for its params
false
lowercase, and it's basic js, not related to djsoh
didnt notice that
it was taking it as a different form
ye
okay so it needs a bitfield instead of viewchannels
i would paste the error but its long
Also change to
ViewChannel
i mis-remembered, an oversight on my part
No (s) at the endyo thank you
it worked
Np...
have a great day