Skip to content Skip to sidebar Skip to footer

TypeError: Message.guild.channels.forEach Is Not A Function

I'm creating a mute command but when I want to disable speaking permission for the Mute role for each channel, I get this error: TypeError: message.guild.channels.forEach is not a

Solution 1:

As of Discord.js v12, it is message.guild.channels.cache. Also, get rid of the id parameter, I don't know what you need that for. Should look like this:

 message.guild.channels.cache.forEach(async channel => {
        await channel.overwritePermissions(muteRole, {
            SEND_MESSAGES: false,
            SEND_TTS_MESSAGES: false,
            ATTACH_FILES: false,
            ADD_REACTIONS: false
        });
    });

Solution 2:

I don't how to explain it, but it doesn't pass on an ID.

 message.guild.channels.forEach(async (channel, id) => {
        await channel.overwritePermissions(muteRole, {
            SEND_MESSAGES: false,
            SEND_TTS_MESSAGES: false,
            ATTACH_FILES: false,
            ADD_REACTIONS: false
        })
    })

Should work if you just do

.forEach(async (channel, id) => { 
});

Hope this works!


Post a Comment for "TypeError: Message.guild.channels.forEach Is Not A Function"