Post a Would You Rather question every day at noon UTC in a channel I choose, with two vote buttons, edit the message with the percentages as votes come in, and let each member vote once Use an editable list of option A/option B pairs with the existing questions as defaults.
Posts a "Would You Rather" question every day at noon UTC with two voting buttons. Members can vote once per question, and the message updates in real-time to show vote counts and percentages as votes come in.
How to use:
/wyr post to test posting immediatelyMade by MEE6. Remix it to get a copy of your own and change anything you like.
A: Have the ability to fly 2 votes (67%)
B: Have the ability to be invisible 1 votes (33%)
✅ Posted!
// Daily "Would You Rather" with vote buttons and live percentage updates
// A rotating set of questions
const QUESTIONS = [
{ optionA: 'Have the ability to fly', optionB: 'Have the ability to be invisible' },
{ optionA: 'Live in the past', optionB: 'Live in the future' },
{ optionA: 'Always be 10 minutes late', optionB: 'Always be 20 minutes early' },
{ optionA: 'Never eat pizza again', optionB: 'Never eat burgers again' },
{ optionA: 'Read minds', optionB: 'See the future' },
{ optionA: 'Have unlimited time', optionB: 'Have unlimited money' },
{ optionA: 'Fight 100 duck-sized horses', optionB: 'Fight 1 horse-sized duck' },
{ optionA: 'Speak all languages', optionB: 'Talk to animals' },
{ optionA: 'Restart your life at 10 years old', optionB: 'Skip ahead 10 years' },
{ optionA: 'Never use social media again', optionB: 'Never watch TV or movies again' },
];
mee6.settings({
channel: { type: 'channel', label: 'Where to post questions', required: true, sample: 'general' },
questions: {
type: 'list',
label: 'Questions',
maxItems: 100,
fields: {
option_a: { type: 'string', label: 'Option A', required: true },
option_b: { type: 'string', label: 'Option B', required: true },
},
default: QUESTIONS.map((row) => ({ option_a: row.optionA, option_b: row.optionB })),
},
});
// Command to test posting immediately
mee6.command('wyr post', { description: "Post today's question now (for testing)" }, async (ctx) => {
const channelId = ctx.settings.channel;
if (!channelId) {
await ctx.reply('No channel is set — an admin can choose one in the dashboard.');
return;
}
if (!(await postQuestion(channelId, ctx))) {
await ctx.reply('No questions configured. Add questions in settings.');
return;
}
await ctx.reply({ content: '✅ Posted!', ephemeral: true });
});
// Daily schedule at noon UTC
mee6.schedule.cron('daily_wyr', '0 12 * * *', { scope: 'daily_question' });
mee6.on('scheduled', async (ctx) => {
if (ctx.scheduleKey === 'daily_wyr') {
const channelId = ctx.settings.channel;
if (!channelId) return;
await postQuestion(channelId, ctx);
}
});
async function postQuestion(channelId: string, ctx: any) {
const QUESTIONS = (ctx.settings.questions as { option_a: string; option_b: string }[]).map((row) => ({
optionA: row.option_a,
optionB: row.option_b,
}));
if (!QUESTIONS.length) {
mee6.log('No questions configured');
return false;
}
// Pick a question based on the day of the year
const dayOfYear = Math.floor(Date.now() / 86400000);
const question = QUESTIONS[dayOfYear % QUESTIONS.length];
const sent = await ctx.send(channelId, {
embed: {
title: '🤔 Would You Rather?',
description: `**A:** ${question.optionA}\n\n**B:** ${question.optionB}`,
color: '#5865F2',
footer: { text: 'Vote with the buttons below!' },
},
buttons: [
{ label: 'A', customId: 'vote_a', style: 'primary' },
{ label: 'B', customId: 'vote_b', style: 'success' },
],
});
// Store the question and initialize vote counts
await mee6.store.set(
`wyr_${sent.messageId}`,
{
channelId: sent.channelId,
messageId: sent.messageId,
optionA: question.optionA,
optionB: question.optionB,
votesA: 0,
votesB: 0,
},
{ ttl: 86400 * 2 }
); // Keep for 2 days
return true;
}
mee6.on('button', async (ctx) => {
if (!ctx.customId.startsWith('vote_')) return;
const data = await mee6.store.get<{
channelId: string;
messageId: string;
optionA: string;
optionB: string;
votesA: number;
votesB: number;
}>(`wyr_${ctx.message.id}`);
if (!data) {
await ctx.reply({ content: 'This poll has expired.', ephemeral: true });
return;
}
const m = mee6.store.member(ctx.author.id);
const voteKey = `wyr_vote_${ctx.message.id}`;
const existingVote = await m.get<string>(voteKey);
if (existingVote) {
await ctx.reply({ content: 'You already voted on this question!', ephemeral: true });
return;
}
// Record the vote
const choice = ctx.customId === 'vote_a' ? 'A' : 'B';
await m.set(voteKey, choice, { ttl: 86400 * 2 });
// Update the counts
if (choice === 'A') {
data.votesA++;
} else {
data.votesB++;
}
await mee6.store.set(`wyr_${ctx.message.id}`, data, { ttl: 86400 * 2 });
// Calculate percentages
const total = data.votesA + data.votesB;
const percentA = total > 0 ? Math.round((data.votesA / total) * 100) : 0;
const percentB = total > 0 ? Math.round((data.votesB / total) * 100) : 0;
// Update the message with new percentages
await mee6.editMessage(data.channelId, data.messageId, {
embed: {
title: '🤔 Would You Rather?',
description: `**A:** ${data.optionA}\n**${data.votesA} votes (${percentA}%)**\n\n**B:** ${data.optionB}\n**${data.votesB} votes (${percentB}%)**`,
color: '#5865F2',
footer: { text: `${total} total vote${total !== 1 ? 's' : ''}` },
},
buttons: [
{ label: 'A', customId: 'vote_a', style: 'primary' },
{ label: 'B', customId: 'vote_b', style: 'success' },
],
});
await ctx.reply({ content: `✅ You voted for **${choice}**!`, ephemeral: true });
});