Skip to content
Advertisement

How would I get my js Discord bot to post an embed to a public channel on the event on a private channel receiving a message?

I’m new to this and I feel like I’ve hit a wall!

I have a webhook setup so any new sales for a product get posted to a private channel for an admin to action, I have just created a ‘sales train’ bot that will simply post a nice embed when i run the !sale command in general chat but would prefer if it posted this automatically everytime a new sales order came through the private channel via the webhook.

Here’s my code atm

client.on('message', message => {
if (message.content === '!sale') {  

  message.delete()

  const embed = new MessageEmbed()
        .setColor(16763136)
        .setThumbnail('https://thumbnnailURL')
        .setDescription("*Another customer has just signed up for 1 month!*n      n **FOMO? Head to <#pricingchannelID> to find out more!**")
        .setTitle(`🚂  SALE TRAIN COMING THROUGH!`)

    message.channel.send(embed);
});

Is it possible to add something where it can watch the private channel ID for a message then post this embed to the public channel ID when it’s triggered? Any help is appreciated 🙂

Thanks!

Advertisement

Answer

Sussed it!

    client.on('message', message => {
    if (message.channel.id === 'CHANNEL ID THE WEBHOOK/MESSAGE IS BEING SENT TO') {  

const channel = client.channels.cache.get("CHANNEL ID THE EMBED GETS SENT TO")

      const embed = new MessageEmbed()
            .setColor(x)
            .setThumbnail('x')
            .setDescription("x")
            .setTitle(`x`)
    
        channel.send(embed);
    }
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement