I am making a discord bot, and I want to do this: someone type -ping and the bot responds with @theuserwhotyped-ping.
I have no errors, I just don't know how to code it, and I don't find any solution on the Internet.
Here is the code I made:
const Discord = require("discord.js");
const client = new Discord.Client();
const prefix = "-";
client.on("message", message=>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(" ");
const command = args.shift().toLowerCase();
if (command === "ping"){
message.channel.send("@{user}); //this is the line which dont work
}
});
You can either use message.reply:
message.reply('typed ping');
It sends a reply, like @peter, typed ping.
Or use the message.author:
message.channel.send(`${message.author} typed ping`);
It sends a message like @peter typed ping.