Keeping A Channel Polls Only

I'm trying to make a specific channel polls only. Since Discord doesn't have a permission set for this I've setup my bot to detect the difference in a poll message and a regular message.

Regular messages get deleted from the channel and the user a DM stating why.
Polls get ignored.
This has been successful.
What isn't successful though is when the poll ends and Discord sends out the notification message stating the poll has ended it gets deleted as well.
Is there a way to detect poll end messages too? I tried having the bot see if the messages contained specific text, but no luck.

// The channel ID you want to monitor
const pollChannelId = '1292516925494267954';

// Check if the message is a poll ending message (adjust based on your poll ending format)
function isPollEndMessage(message) {
    return message.content.includes("has closed"); // Customize this if necessary
}

client.on('messageCreate', async (message) => {
    // Ignore messages from bots
    if (message.author.bot) return;

    // Only check messages from the specified channel
    if (message.channel.id === pollChannelId) {
        // If it's a poll, process as normal
        if (message.poll) {
            // Check if the poll has more than 5 options
            if (message.poll.answers && message.poll.answers.size > 4) {
                try {
                    // Delete the poll
                    await message.delete();
                    // Notify the user via DM
                    await message.author.send(`Your poll was deleted because it exceeded the limit of 4 answers.`);
                } catch (error) {
                    console.error(`Error deleting poll or sending DM: ${error}`);
                }
            }
            return; // End execution if the message is a valid poll
        }

        // If the message is the poll ending message, don't delete it
        if (isPollEndMessage(message)) {
            return; // Do nothing if it's the poll end message
        }

        // If it's not a poll or an ending message, delete the message
        try {
            await message.delete();
            await message.author.send(`Your message was deleted because ${message.channel} is for polls only.`);
        } catch (error) {
            console.error(`Error deleting message or sending DM: ${error}`);
        }
    }
});
Was this page helpful?