我将从使用 discord.js 的新Discord机器人开始。我仍在学习,但很好奇是否可以仅将回复发送给发起者,而不发送给频道。
Channel.send
和message.reply
对所有人都是公开的。
const discord = require('discord.js');
const client = new discord.Client;
const prefix = '!';
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.content === 'ping') {
message.channel.send('Pong!');
}
});
答案 0 :(得分:0)
您可以这样做:
message.author.send("text to send")
发送直接私人消息
答案 1 :(得分:0)
要让发短信的人dm
classpath 'com.google.gms:google-services:4.3.3'
要将其发送给其他人,
message.author.send("hullo");
答案 2 :(得分:0)
有3种方式来回应用户,我将解释所有这三种方式。要仅答复用户(作者),您可能想使用.reply()
方法。这就是您的用法:
message.reply("I replied to you :)!");
要仅私下发送消息给作者,您想使用author.send()
方法。这将在直接消息中发起私人对话,只有您的机器人和作者会参与其中。
message.author.send("This is a private conversation, nobody will ever know about.");
只需在频道中发送消息,请使用channel.send()
。
message.channel.send("This is a regular message, no user is pinged.");