Build a counting game in #counting: members count up one number at a time, nobody can count twice in a row, and the count resets to 1 if someone gets it wrong
A counting game where members count up one number at a time in a designated channel.
Rules:
Setup: Set the counting channel in the creation settings. The game tracks progress automatically and reacts with ✅ for correct counts or ❌ when someone makes a mistake.
Made by MEE6. Remix it to get a copy of your own and change anything you like.
❌ @Alex, you can't count twice in a row! Resetting to 1.
❌ Wrong number! Expected 3 but got 5. Resetting to 1.
// Counting game: members count up one number at a time
// Nobody can count twice in a row, and wrong numbers reset to 1
mee6.settings({
counting_channel: {
type: 'channel',
label: 'Counting channel',
required: true,
sample: 'counting',
},
});
// Only messages in the counting channel wake the module (none while it is not set)
mee6.on('message', { channels: [mee6.setting('counting_channel')] }, async (ctx) => {
// Get the current count and last user
const currentCount = await mee6.store.get<number>('count', 0);
const lastUserId = await mee6.store.get<string>('last_user');
const content = ctx.message.content.trim();
const num = parseInt(content, 10);
// Check if it's a valid number
if (isNaN(num) || content !== num.toString()) return;
const expectedCount = currentCount + 1;
// Check if the same user is counting twice in a row
if (lastUserId === ctx.author.id) {
await ctx.reply(`❌ ${ctx.author.mention}, you can't count twice in a row! Resetting to 1.`);
await mee6.store.set('count', 0);
await mee6.store.delete('last_user');
await ctx.react('❌');
return;
}
// Check if the number is correct
if (num !== expectedCount) {
await ctx.reply(`❌ Wrong number! Expected **${expectedCount}** but got **${num}**. Resetting to 1.`);
await mee6.store.set('count', 0);
await mee6.store.delete('last_user');
await ctx.react('❌');
return;
}
// Correct! Update the count and last user
await mee6.store.set('count', num);
await mee6.store.set('last_user', ctx.author.id);
await ctx.react('✅');
// Celebrate milestones
if (num % 100 === 0) {
await ctx.reply(`🎉 Milestone reached: **${num}**!`);
}
});