I’m working on a Discord bot that needs to respond to webhook messages. I have a webhook set up that sends messages to a channel when someone submits a Google form. What I want to do is make my bot automatically add buttons (like approve/reject) whenever it detects a message from this webhook.
I tried using the messagecreate event to catch bot messages and add buttons, but it’s not working. Here’s what I attempted:
client.on('messageCreate', (msg) => {
if(msg.author.bot) {
const approveBtn = new ButtonBuilder()
.setLabel('Approve')
.setStyle(ButtonStyle.Success)
.setCustomId('approve_action');
const rejectBtn = new ButtonBuilder()
.setLabel('Reject')
.setStyle(ButtonStyle.Secondary)
.setCustomId('reject_action');
const row = new ActionRowBuilder().addComponents(approveBtn, rejectBtn);
msg.reply({content: 'Choose an action:', components: [row] });
}
});
The buttons aren’t showing up at all. Am I missing something with how Discord handles webhook messages?