Javascript Discord.js:Bot应该提到执行命令的用户
我正在为Discord制作一个机器人,作为第一个JS项目,在用户写了一篇文章之后,它将打印GIF或图像!GIF或!JPG命令。此外,它还将添加一条消息如何在GIF/图像上方的消息中提及发出命令的用户?我试着做了搜索,但找不到解决方案Javascript Discord.js:Bot应该提到执行命令的用户,javascript,discord.js,Javascript,Discord.js,我正在为Discord制作一个机器人,作为第一个JS项目,在用户写了一篇文章之后,它将打印GIF或图像!GIF或!JPG命令。此外,它还将添加一条消息如何在GIF/图像上方的消息中提及发出命令的用户?我试着做了搜索,但找不到解决方案 client.on("message", msg => { const sentences = ["Here is your sh*", "Take that image and shove it!"
client.on("message", msg => {
const sentences = ["Here is your sh*", "Take that image and shove it!", "Lol ok..."]
const texts = sentences[Math.floor(Math.random() * sentences.length)];
if (msg.content === "!Commands") {
msg.reply("Use '!GIF' for random GIFs and '!JPG'for random JPGs");
}
if (msg.content === "!GIF") {
gifNumber = 6
var randomGif = Math.floor (Math.random() * (gifNumber - 1 + 1)) + 1;
msg.reply(texts, {files: ["./gif/" + randomGif + ".gif"]});
}
if (msg.content ==="!JPG") {
jpgNumber = 2
var randomJpg = Math.floor (Math.random() * (jpgNumber - 1 + 1)) + 1;
msg.reply(texts, {files: ["./jpg/" + randomJpg + ".jpg"]});
}
});
字符串化的用户对象将解析为一个提词。 发送2条消息,1条用于提及,第2条用于内容
msg.channel.send(msg.author);
msg.channel.send(texts, {files: ["./jpg/" + randomJpg + ".jpg"]});
您可以使用
msg.author.id
msg.channel.send(`anytext`);
将允许您在同一消息中以提及方式向用户提及
提到一个用户
提到一个频道
提到了一个角色