我想在此消息上添加角色,但它给我错误消息“成员不是 确定”
if (message.content === "diocane"){
message.reply('Now you get a warn');
member.roles.add('731217864446705714');
}
})
member is not defined
at Client.<anonymous> (C:\Users\lucad\Desktop\Discord Bot\index.js:156:5)
at Client.emit (events.js:327:22)
at MessageCreateAction.handle (C:\Users\lucad\Desktop\Discord Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at WebSocketManager.handlePacket (C:\Users\lucad\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\lucad\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\lucad\Desktop\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\lucad\Desktop\Discord Bot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\lucad\Desktop\Discord Bot\node_modules\ws\lib\websocket.js:800:20)
(node:7892) 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:7892) [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.
答案 0 :(得分:0)
您尚未将成员定义为任何人,因此您可以这样做:
let member = message.author
或简单地:
message.author.roles.add(`731217864446705714`)