I just started coding my Discord bot and I made a command that replies to every message that isn’t sent by a bot. When I tried it in DMs it works fine, but when I tried it in my server it would mention the user before the command. In the DM it would say just “test”, but in the server it would say something like “@ExampleUser, test”.
Is there a way I can fix this? Here’s my code:
const Discord = require('discord.js'); const client = new Discord.Client(); client.on("message", (message) => { if (message.author.bot) return; return message.reply("test") });
Advertisement
Answer
Instead of message.reply('test')
use message.channel.send('test')
that sends a message to the channel the original message was sent to.