Пытался переписать права каналов, но вышла странная ошибка, суть которой я не понял.
Код:
let muterole = message.guild.roles.cache.find(r => r.name === "Muted")
if(!muterole) {
try{
muterole = await message.guild.roles.create({
name: "Muted",
color: "#514f48",
permissions: []
})
message.guild.channels.cache.forEach(async channel => {
await channel.overwritePermissions(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false,
SEND_TTS_MESSAGES: false,
ATTACH_FILES: false,
})
})
} catch(e) {
console.log(e.stack);
}
}
Ошибка:
(node:11440) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites.
at VoiceChannel.overwritePermissions (C:\Users\yande\Desktop\Руссиан сквад\node_modules\discord.js\src\structures\GuildChannel.js:208:9)
at C:\Users\yande\Desktop\Руссиан сквад\admcmd\mute.js:35:31
at Map.forEach (<anonymous>)
at Object.run (C:\Users\yande\Desktop\Руссиан сквад\admcmd\mute.js:34:44)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:11440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 43)
(node:11440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.