[RS] JesseUCAVedYou [EN]
[RS] JesseUCAVedYou [EN]
Explore posts from servers
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
Works wonderfully thanks to you. Will post my code here for future reference of others.
// The channel ID you want to monitor
const pollChannelId = '1292516925494267954';

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 the message is a poll result (type 46), do nothing (allow it)
if (message.type === 46) {
return; // End the execution, don't delete the poll result message
}

// If the message is a poll
if (message.poll) {
// Check if the poll has more than 5 options
if (message.poll.answers && message.poll.answers.size > 5) {
try {
// Delete the message (poll)
await message.delete();
// Notify the user via DM
await message.author.send(`Your poll was deleted because it exceeded the limit of 5 answers.`);
} catch (error) {
console.error(`Error deleting poll or sending DM: ${error}`);
}
}
return; // End execution here if it's a valid poll
}

// If it's not a poll, delete the message and send a DM
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}`);
}
}
});
// The channel ID you want to monitor
const pollChannelId = '1292516925494267954';

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 the message is a poll result (type 46), do nothing (allow it)
if (message.type === 46) {
return; // End the execution, don't delete the poll result message
}

// If the message is a poll
if (message.poll) {
// Check if the poll has more than 5 options
if (message.poll.answers && message.poll.answers.size > 5) {
try {
// Delete the message (poll)
await message.delete();
// Notify the user via DM
await message.author.send(`Your poll was deleted because it exceeded the limit of 5 answers.`);
} catch (error) {
console.error(`Error deleting poll or sending DM: ${error}`);
}
}
return; // End execution here if it's a valid poll
}

// If it's not a poll, delete the message and send a DM
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}`);
}
}
});
14 replies
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
Will try. Thanks!
14 replies
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
:PES_Happy:
14 replies
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
So here I am looking like a fool lol
14 replies
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
No description
14 replies
DIAdiscord.js - Imagine a boo! 👻
Created by [RS] JesseUCAVedYou [EN] on 10/8/2024 in #djs-questions
Keeping A Channel Polls Only
-_- and my question/code gets removed. le sigh
14 replies