首页 > 解决方案 > 静音每个频道 discord.js 中的角色

问题描述

我尝试在每个频道中静音一个名为“mutedRole”的角色,所以我输入了一些代码,这是代码:

    if(message.content === `${prefix}mute`) {
 message.guild.channels.cache.forEach((channel) => {

 channel.updateOverwrite(channel.guild.roles.mutedRole, {
  SEND_MESSAGES: false
})
  .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
  .catch(console.error);

});
}

但是现在,当我输入 !mute 时,它​​给了我以下错误:

TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.

如何在每个频道中静音角色“mutedRole”?

问候:)

标签: discorddiscord.jsbots

解决方案


推荐阅读