【发布时间】:2021-01-16 12:23:17
【问题描述】:
我正在尝试使用我的不和谐机器人删除我的服务器的所有角色。但它出现了这个错误:
(node:10096) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Role
at RequestHandler.execute (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\amy nuker\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10096) 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: 1)
(node:10096) [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.
我的代码:
if(message.content.startsWith(prefix + 'roled')){
message.guild.roles.cache.forEach(roles => roles.delete());
}
这不起作用,所以我尝试使用 .map() 函数
if(message.content.startsWith(prefix + 'roled')){
// message.guild.roles.cache.map(roles => roles.delete());
}
但无济于事。我仍然遇到与以前相同的错误。我该怎么做才能解决这个问题?
【问题讨论】:
标签: javascript node.js discord discord.js