Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Kickme命令,无法读取标记_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript Kickme命令,无法读取标记

Javascript Kickme命令,无法读取标记,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,我正在尝试将一个命令添加到我的bot中,我不太明白为什么“tag”的属性没有定义${user.tag}在我的real kick命令中工作得很好,它只是不想注册发送“!下面的kickme命令标记是我的代码和错误 代码 const Discord = require('discord.js') module.exports.run = async (bot, message, args) => { const user = message.mentions.users.fir

我正在尝试将一个命令添加到我的bot中,我不太明白为什么“tag”的属性没有定义${user.tag}在我的real kick命令中工作得很好,它只是不想注册发送“!下面的kickme命令标记是我的代码和错误

代码


const Discord = require('discord.js')


module.exports.run = async (bot, message, args) => {


    const user = message.mentions.users.first();
    const member = message.guild.member(user);

    message.author.send(`Here is an invite so you can join back! https://discord.gg/FBXSduget2 `)

    message.channel.send(`!kick ${user.tag} `)

    message.channel.send(`${user.tag} Kicked themself`)
}

  module.exports.help = {
    name: "kickme"
  }


错误


(node:13204) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tag' of undefined
    at Object.module.exports.run (C:\Users\8fwbu\Desktop\CodeTProj\-Tux V2\commands\kickme.js:12:40)
    at Client.<anonymous> (C:\Users\8fwbu\Desktop\CodeTProj\-Tux V2\main.js:42:31)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\8fwbu\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\8fwbu\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13204) 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:13204) [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


(节点:13204)未处理的PromisejectionWarning:TypeError:无法读取未定义的属性“tag”
在Object.module.exports.run(C:\Users\8fwbu\Desktop\CodeTProj \-Tux V2\commands\kickme.js:12:40)
在客户端。(C:\Users\8fwbu\Desktop\CodeTProj \-Tux V2\main.js:42:31)
在Client.emit(events.js:315:20)
在MessageCreateAction.handle(C:\Users\8fwbu\node\u modules\discord.js\src\client\actions\MessageCreate.js:31:14)
在Object.module.exports[作为消息\u CREATE](C:\Users\8fwbu\node\u modules\discord.js\src\client\websocket\handlers\MESSAGE\u CREATE.js:4:32)
在WebSocketManager.handlePacket(C:\Users\8fwbu\node\u modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
在WebSocketShard.onPacket(C:\Users\8fwbu\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
在WebSocketShard.onMessage(C:\Users\8fwbu\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
在WebSocket.onMessage(C:\Users\8fwbu\node\u modules\ws\lib\event target.js:132:16)
在WebSocket.emit(events.js:315:20)
(使用`node--trace warnings…`显示警告的创建位置)
(节点:13204)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于抛出不带catch块的异步函数内部,或者拒绝未处理的承诺
with.catch()。要在未处理的承诺拒绝时终止节点进程,请使用CLI标志“---unhandled rejections=strict”(请参阅https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (拒绝id:1)
(节点:13204)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将使用非零退出代码终止Node.js进程

消息中似乎没有提到任何人-
用户
未定义。因为你想踢发送消息的用户,你可以通过

const user=message.author

谢谢,我完全忘了