MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / handleCountingGame

Function handleCountingGame

src/events/messageCreate.js:119–153  ·  view source on GitHub ↗
(message, client)

Source from the content-addressed store, hash-verified

117}
118
119async 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
155async function handleLeveling(message, client) {
156 try {

Callers 1

executeFunction · 0.85

Calls 5

getCountingGameConfigFunction · 0.90
isValidCountingMessageFunction · 0.90
saveCountingGameConfigFunction · 0.90
recordCorrectCountFunction · 0.90
deleteMethod · 0.45

Tested by

no test coverage detected