0
votes

and thank you for trying to help me! I am making a discord bot using discord.js. I made a mute command which works perfect and i am very happy that it works perfect, but now discord give's me another problem. If i want to mute somebody i gave him a mute role. Now that's my problem i managed to overwrite the permissions for the channel where i type the mute command, but i need to manually overwrite the other channels in the server!

I want to overwrite all channels on the server!

So my code is:

     message.channel.updateOverwrite(muterole, {
            VIEW_CHANNEL: true, 
            SEND_MESSAGES: false,
            READ_MESSAGE_HISTORY: true,
            TALK: false})

Thank you in advance!

1

1 Answers

0
votes

You could use the each() function to iterate (loop) through each channel in the current guild and perform the action(s), as utilised below:

// iterate a function through every channel in a server
message.guild.channels.cache.each((channel) => { 
   channel.updateOverwrite(muterole, {
            VIEW_CHANNEL: true, 
            SEND_MESSAGES: false,
            READ_MESSAGE_HISTORY: true,
            TALK: false});
});