(message, client)
| 117 | } |
| 118 | |
| 119 | async function handleCountingGame(message, client) { |
| 120 | try { |
| 121 | const config = await getCountingGameConfig(client, message.guild.id); |
| 122 | if (!config.enabled || !config.channelId || message.channel.id !== config.channelId) { |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | const content = message.content.trim(); |
| 127 | const validCount = isValidCountingMessage(content, config); |
| 128 | const invalidAttempt = !validCount || message.author.id === config.lastUserId; |
| 129 | |
| 130 | if (invalidAttempt) { |
| 131 | await message.delete().catch(() => {}); |
| 132 | await saveCountingGameConfig(client, message.guild.id, { |
| 133 | ...config, |
| 134 | nextNumber: 1, |
| 135 | lastUserId: null, |
| 136 | currentStreak: 0, |
| 137 | }); |
| 138 | |
| 139 | const failureMessage = await message.channel.send(`❌ Count broken by <@${message.author.id}>. The sequence has been reset to **1**.`); |
| 140 | setTimeout(() => { |
| 141 | failureMessage.delete().catch(() => {}); |
| 142 | }, 10000); |
| 143 | |
| 144 | return true; |
| 145 | } |
| 146 | |
| 147 | await recordCorrectCount(client, message.guild.id, message.author.id); |
| 148 | return true; |
| 149 | } catch (error) { |
| 150 | logger.error('Error handling counting game:', error); |
| 151 | return false; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | async function handleLeveling(message, client) { |
| 156 | try { |
no test coverage detected