I am new to discord.js and wanted to make the bot to reply to the person who sent the command. For example:
Person1: !hello
Bot: Hello, @Person1
Usually, I would create my commands like this:
main/index.js
if(command === 'cmd'){
client.commands.get('cmd').execute(message, args);
cmd.js
module.exports = {
name: 'cmd',
description: 'example command',
execute(message, args){
message.channel.send('this is a command');
}
}
If it's possible to do it in this format, it would be really helpful. Again, apologies for my lack of understanding this is still very new to me. Thanks.
You can simply use the message.author
to mention the author of the message like this:
execute(message, args) {
message.channel.send(`Hello, ${message.author}!`);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.