1

I have looked and I have tried different things, but I cant seem to find an answer that either makes sense or works. I am new to all this in general, but so far stackoverflow has been amazing!

My question is I understand how to create a hyperlink in an embed, but is there way to the embed to work as button that sends a message rather than open up to the web page.

const Google = new Discord.MessageEmbed()
    .setColor('#0099ff')
    .setTitle('Google')
        .setURL('https://google.com')

At the moment the following embed will link to google.com but is there a way to set it so it sends a "!help" message into the server (which is a separate command within the bot), like something like message.channel.send("!help") I have looked at adding fields and such, but it seems this is the only way to make an embed function as a button/hyperlink.

1
  • 2
    That wouldn't work, however, you could set up a system using reaction collectors to listen to certain emojis being reacted to the message and do something through that Commented Jul 3, 2020 at 18:45

1 Answer 1

1

There is no current way to do this as links are just links. You can achieve something similar by using awaitReactions() to check if the member has reacted to the embed and sending the message that way:

// Send embed here
message.react('👍').then(() => message.react('👎'));

const filter = (reaction, user) => {
    return ['👍', '👎'].includes(reaction.emoji.name) && user.id === message.author.id;
};

message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then(collected => {
        const reaction = collected.first();

        if (reaction.emoji.name === '👍') {
            // Send the message here
        }

        else {
            // Optional: Send a message if they don't react with a thumbs up
        }
    })
    .catch(collected => {
        // Also optional: Check if the reacted before timeout
    });

You can find more information regarding reactions here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.