Counting Game Question

Hey there, so I am making a counting game for my server, and everything is right. Although, I would like to add a system where one user can't keep counting. Another user has to count with them. So user 1 starts at "1", but can't say "2" or the game will end. Here is my code so far:
if(message.channel.id === "988686879547330580"){
if (Number(message.content) === count + 1){
count++

if (timeout) clearTimeout(timeout)

timeout = setTimeout(
() => chanel.send(++count).catch(console.error),
30000
)

} else if (message.member.id !== bot.user.id) {
message.channel.send(`${message.author} messed up!`).catch(console.error)

count = 0

if (timeout) clearTimeout(timeout)
}

if(count == "100"){
message.channel.send(":tada: - **Successfully reached #100!**")
}
}
if(message.channel.id === "988686879547330580"){
if (Number(message.content) === count + 1){
count++

if (timeout) clearTimeout(timeout)

timeout = setTimeout(
() => chanel.send(++count).catch(console.error),
30000
)

} else if (message.member.id !== bot.user.id) {
message.channel.send(`${message.author} messed up!`).catch(console.error)

count = 0

if (timeout) clearTimeout(timeout)
}

if(count == "100"){
message.channel.send(":tada: - **Successfully reached #100!**")
}
}
7 Replies
Jaworek
Jaworek3y ago
channel send takes object or string not number everything else looks okey
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Jaworek
Jaworek3y ago
learn js bro
d.js docs
d.js docs3y ago
mdn clearTimeout() The global clearTimeout() method cancels a timeout previously established by calling setTimeout().
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
probablyraging
For what it's worth, my bot has a counting game that does what you're asking, it's pretty messy, could be better, but it works https://github.com/ProbablyRaging/CreatorBot/blob/master/modules/games/counting_game.js You're welcome to take any code you please How I do what you're asking
let failed = false;
let previousCounter = [];

await message?.channel.messages.fetch({ limit: 20 }).then(async fetched => {
const filtered = fetched.filter(m => !m.author.bot);

filtered.forEach(m => {
// only keep the results that are a number
if (!isNaN(m.content)) {
previousCounter.push({ id: m.author.id });
}
});

// if the same person counted two number is a row
if (previousCounter[1].id === author.id) {
failReason = `${author} **FAILED** \n> You can't count two numbers in a row`;
failed = true;
await checkForGuildSaves();
return;
}
});
let failed = false;
let previousCounter = [];

await message?.channel.messages.fetch({ limit: 20 }).then(async fetched => {
const filtered = fetched.filter(m => !m.author.bot);

filtered.forEach(m => {
// only keep the results that are a number
if (!isNaN(m.content)) {
previousCounter.push({ id: m.author.id });
}
});

// if the same person counted two number is a row
if (previousCounter[1].id === author.id) {
failReason = `${author} **FAILED** \n> You can't count two numbers in a row`;
failed = true;
await checkForGuildSaves();
return;
}
});
GitHub
CreatorBot/counting_game.js at master · ProbablyRaging/CreatorBot
CreatorBot is a multipurpose discord.js v13 bot created for the CreatorHub Discord server - CreatorBot/counting_game.js at master · ProbablyRaging/CreatorBot
istay
istayOP3y ago
thank you, this helps slot alot*
Want results from more Discord servers?
Add your server