简体   繁体   English

如何使Discord bot DM用户获得特定答复?

[英]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.

相关问题 如何让我的 discord 机器人通过回复池回复特定消息? - How do I make my discord bot reply to a specific message with reply from a pool of replies? 如何让我的 discord 机器人回复包含特定字母/字符的消息? - How can I make my discord bot reply to a message when it contains a specific letter/character? 如何让我的 Discord Bot 回复并提及? - How to make my Discord Bot reply with a mention? 如何让我的 Discord Bot 回复类似消息的相同答案? JavaScript - How do I make my Discord Bot reply a same answer for similar messages? JavaScript 如何使 discord.js bot dm 向特定人员发送消息? - How to make a discord.js bot dm a message to a specific person? 如何制作 DM 提到的用户的 discord js 机器人? - How do I make a discord js bot that DM's a mentioned user? 如何使用 java 脚本让 discord 机器人向命令中提到的人发送 DM? - How do I make a discord bot send a DM to someone mentioned in the command, using java script? 当特定用户玩特定游戏时,如何让我的不和谐机器人发送消息? - How do I make my discord bot send a message when a specific user plays a specific game? 如何让 discord 机器人编辑 dm 消息? - how to make a discord bot edit a dm message? 当被问到某个问题时,如何让我的 Discord Bot (Javascript) 在标签中回复用户? - How can i make my Discord Bot (Javascript) reply to the user in tag, when a certain question is asked?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM