K
K
Konstantin Petrov2019-12-09 04:49:26
Node.js
Konstantin Petrov, 2019-12-09 04:49:26

How to redirect a bot from a response with a link to a response without a link?

I am writing a bot for Discord on discord.js.
There is a code. What would the bot respond to when users write a message to the chat.
So, when answering, he mentions this person. Well, this is understandable because there is a message.reply in the code
And how to make it so that it does not answer, but sends a message?
Here is the code:

client.on("message", (message) => { 
  if(message.content == "Привет всем"){ 
    message.reply("Привет! :wave:"); 
  } 
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2019-12-09
@ERED

If you ask a question, you write what you use. If I didn't know that you are trying to write a Discord bot using discord.js, I would never understand the question. And believe me, answering your question becomes many times more difficult.
In your case: The Message
object has a channel variable that is equal to the TextChannel object into which the message was sent. This object has a .send() method with which you can send a message to this text channel. Final code:

client.on("message", (message) => {
  if(message.content == "Привет всем"){
    message.channel.send("Привет! :wave:");
  }
});

Study the documentation , please. It is very convenient and understandable even for a junior developer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question