[英]How do I make my Discord bot DM users with a specific reply?
I'm trying to make my bot having a DM commands that can send a specific user with a specific DM message. 我正在尝试使我的机器人具有DM命令,该命令可以向特定用户发送特定的DM消息。
For example: 例如:
Me: !dm @user#6969 hi who ru 我:!dm @ user#6969嗨,谁茹
Bot: Messages user#6969 "hello who ru" Bot:提示用户#6969“ hello who ru”
Currently using Visual Studio Code to code the stuff, and I don't really know how do I make this command due to I couldn't really find a working tutorial about it. 当前使用Visual Studio Code编写代码,由于无法真正找到有效的教程,我不知道该如何执行此命令。
if(message.content.startsWith(`${prefix}dm`)) {
var mention = message.mentions.members.first()
mention.send("hi")
}
Here's the error: 这是错误:
mention.send("hi")
^
TypeError: Cannot read property 'send' of undefined
at Client.client.on.message (/Users/Private/Desktop/Discord/bot/index.js:69:17)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (/Users/Private/Desktop/Discord/bot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/Users/Private/Desktop/Discord/bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/Users/Private/Desktop/Discord/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/Users/Private/Desktop/Discord/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/Users/Private/Desktop/Discord/bot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/Users/Private/Desktop/Discord/bot/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:198:13)```
if(message.content.startsWith(`${prefix}dm`)) {
const mentionedUser = message.mentions.users.first();
if(!mentionedUser) return message.reply('Mention Somebody');
mentionedUser.send('Hi');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.