Lntrn
Lntrn

Reputation: 5

Getting bot to react to it's own message

How would I make the bot react to it's own message? I know it's probably a simple enough thing but I can't find an answer. Thanks in advance.

module.exports = {
    name: "ping",
    description: "Basic ping command",
    execute(message) {
        message.channel.send("Pong.");
        message.react("🏓");
    },
};

Edit: I forgot to say in here that this is Discord.JS, not python

Upvotes: 0

Views: 114

Answers (2)

T. Dirks
T. Dirks

Reputation: 3676

You have the right idea but you add the reaction to the wrong message. To react to the message the bot has send, you can use the Promise returned by TextChannel.send(). Take a look at the example code below and give it a try:

module.exports = {
    name: "ping",
    description: "Basic ping command",
    execute(message) {
        message.channel.send("Pong.").then((botMessage) => {
            botMessage.react("🏓");
        });
    },
};

Upvotes: 1

TheSavageTeddy
TheSavageTeddy

Reputation: 204

see this article

the code should be

bot.add_reaction(msg, "🏓")

Upvotes: 0

Related Questions