message collector from array

I'm using an attachments and message content, to get the question and answer like this:
No description
52 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
EREBUS
EREBUS13mo ago
söyle kanka hata ne yardım ededyim edeyim*
Forhand.
Forhand.13mo ago
with this code:
client.on('messageCreate', async message => {
let args = message.content.split(" ");
if (args[0] === `event`) {
if (message.author.id !== "222534954196664320") return;
await message.delete().catch(err => { console.log(err) });
let channel = client.channels.cache.get(Ch);
let MainCh = client.channels.cache.get(Main);
let uploaded = false;
await channel.messages.fetch().then(msgs => {
for (const msg of msgs) {
if (msg[1].attachments.size > 0) {
const collector = MainCh.createMessageCollector({ time: 60000 });
collector.on('collect', async m => {
if (m.content === msg[1].content) {
await m.reply(`Correct!`).catch(err => { console.log(err) });
uploaded = true;
collector.stop();
}
})
collector.on('end', async () => {
if (!uploaded) {
MainCh.send(`The time is done, and no one choose the correct answer.`).catch(err => { console.log(err) });
}
})
}
}
}).catch(err => { console.log(err) });
}
})
client.on('messageCreate', async message => {
let args = message.content.split(" ");
if (args[0] === `event`) {
if (message.author.id !== "222534954196664320") return;
await message.delete().catch(err => { console.log(err) });
let channel = client.channels.cache.get(Ch);
let MainCh = client.channels.cache.get(Main);
let uploaded = false;
await channel.messages.fetch().then(msgs => {
for (const msg of msgs) {
if (msg[1].attachments.size > 0) {
const collector = MainCh.createMessageCollector({ time: 60000 });
collector.on('collect', async m => {
if (m.content === msg[1].content) {
await m.reply(`Correct!`).catch(err => { console.log(err) });
uploaded = true;
collector.stop();
}
})
collector.on('end', async () => {
if (!uploaded) {
MainCh.send(`The time is done, and no one choose the correct answer.`).catch(err => { console.log(err) });
}
})
}
}
}).catch(err => { console.log(err) });
}
})
EREBUS
EREBUS13mo ago
kanka yanlış yapıyon
Forhand.
Forhand.13mo ago
so I want to wait until someone answers then it'll send the second attachment that in the chat channel
EREBUS
EREBUS13mo ago
he kanka
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
EREBUS
EREBUS13mo ago
he is Turkish i am too can i help with using Turkish
Forhand.
Forhand.13mo ago
I'm not Turkish
EREBUS
EREBUS13mo ago
oh the "test" okey my bad if i was you i'd do like this i could create a db and set the text then i'd use messageCreate again and if(message.content ==== db.text) return i think that way is way too good what is ur db?
Forhand.
Forhand.13mo ago
I'm using json files if I'll use a db
EREBUS
EREBUS13mo ago
okey i'll send a code wait What is Ch and Main ?
Forhand.
Forhand.13mo ago
Ch is the channel to collect the attachment and content, Main is the channel to send the attachment and collect the correct answer from
EREBUS
EREBUS13mo ago
should correct answer have a attachment ?
Forhand.
Forhand.13mo ago
no just content
EREBUS
EREBUS13mo ago
oh okey wait
client.on("messageCreate", async(message) => {
let args = message.content.split(" ");
if(args[0] !== "event") return
if(message.author.id !== "222534954196664320") return
await message.delete()
/* set db to true answer*/
})

client.on("messageCreate", async(message) => {
if(message.channel.id !== "main.channel.id") return
if(message.content === data.true.answer) return message.reply({content: "Congz! You answered correctly!"})
}
client.on("messageCreate", async(message) => {
let args = message.content.split(" ");
if(args[0] !== "event") return
if(message.author.id !== "222534954196664320") return
await message.delete()
/* set db to true answer*/
})

client.on("messageCreate", async(message) => {
if(message.channel.id !== "main.channel.id") return
if(message.content === data.true.answer) return message.reply({content: "Congz! You answered correctly!"})
}
oh i guess do u wanna like if nobody answered in 5 minutes the event should cancel ?
Forhand.
Forhand.13mo ago
yes but in 10 seconds better
EREBUS
EREBUS13mo ago
client.on("messageCreate", async(message) => {
let args = message.content.split(" ");
if(args[0] !== "event") return
if(message.channel.id !== "") return
if(message.author.id !== "222534954196664320") return
await message.delete()
await message.guild.channels.cache.get().send({YOU'LL SEND ATTACHMENT HERE})
/* set db to true answer and the Date.now()*/
})

client.on("messageCreate", async(message) => {
if(message.channel.id !== "main.channel.id") return
if(message.content === data.true.answer) return message.reply({content: "Congz! You answered correctly!"})
/* edit db to answered and who did it first*/

client.on("ready", () => {
setTimeout(() => {
if(!db.true.answer || !db.date.now) return
if(db.date.now > yourtime ) {
client.guilds.cache.get().channels.cache.get().send({content: "Nobody answered true thing, event canceled."})
db delete
}
if(db.answered) {
client.guilds.cache.get().channels.cache.get().send({content: "Congz! " + db.who.answered + " Answered truely! "})
return db delete
}
}, 3000)
})
}
client.on("messageCreate", async(message) => {
let args = message.content.split(" ");
if(args[0] !== "event") return
if(message.channel.id !== "") return
if(message.author.id !== "222534954196664320") return
await message.delete()
await message.guild.channels.cache.get().send({YOU'LL SEND ATTACHMENT HERE})
/* set db to true answer and the Date.now()*/
})

client.on("messageCreate", async(message) => {
if(message.channel.id !== "main.channel.id") return
if(message.content === data.true.answer) return message.reply({content: "Congz! You answered correctly!"})
/* edit db to answered and who did it first*/

client.on("ready", () => {
setTimeout(() => {
if(!db.true.answer || !db.date.now) return
if(db.date.now > yourtime ) {
client.guilds.cache.get().channels.cache.get().send({content: "Nobody answered true thing, event canceled."})
db delete
}
if(db.answered) {
client.guilds.cache.get().channels.cache.get().send({content: "Congz! " + db.who.answered + " Answered truely! "})
return db delete
}
}, 3000)
})
}
is this what u wanna ?
Forhand.
Forhand.13mo ago
it's isn't possible to collect from chat because it's gonna be allowed for everyone to add he's own image + content (which is the answer) that's why I had to do it like this
EREBUS
EREBUS13mo ago
it is possible
EREBUS
EREBUS13mo ago
i checked here the message content if it is true answer
No description
Forhand.
Forhand.13mo ago
and after someone answered it'll continue to send the second and third attachments and so on untill the bot sends all the attachments in the chat
EREBUS
EREBUS13mo ago
so please tell me clearly what you wanna ? You tell me it is just message content and u re saying there are attachments too
Forhand.
Forhand.13mo ago
I'll show you an example
Forhand.
Forhand.13mo ago
So the bot's gonna take the attachments from here to send it in the MainCh and will wait for 10s to answer and the answer gonna be The Attachment's message content
No description
Forhand.
Forhand.13mo ago
if someone got it right or the time ends it'll wait 10 seconds then send the second attachment and so on untill the bot send all attachments
EREBUS
EREBUS13mo ago
in MainCh, will you write manuelly
Forhand.
Forhand.13mo ago
yes the people there will try to guess the correct answer, which is the message content for the attachment's message
EREBUS
EREBUS13mo ago
okey that code'll work . but i'll edit wait
Forhand.
Forhand.13mo ago
okay mate
EREBUS
EREBUS13mo ago
Okey that'll work But that it'll work like Channel 1 Channel 2 You write "Try" in Channel 1 and it'll delete that then bot will send a attachment Channel 2 and time'll start if they write, time'll delete and game done if they don't bot'll send a message to they don't write correct answer
Forhand.
Forhand.13mo ago
it shouldn't done before the bot sends all the messages that contains an attachment the Ch chat
EREBUS
EREBUS13mo ago
Oh i guess you wanna if it able there are many question for answer and if all question is sent bot should start time
Forhand.
Forhand.13mo ago
no no for each question there's time, if they didn't answer the correct answer in time or they did. it'll wait 10 seconds and it'll send the next attachment and start another 10s untill the attachments are done
EREBUS
EREBUS13mo ago
The questions did sending but bot should start their time in order am i right
Forhand.
Forhand.13mo ago
this the best way until now but I couldn't made it like send one attachment and send another after answering the correct answer or after the time is up
EREBUS
EREBUS13mo ago
okey if you know "the best way" you can finish it bye And i know %100 you are turkish anyway
Forhand.
Forhand.13mo ago
I'm not and why ur mad?
EREBUS
EREBUS13mo ago
i am trying to help but u still say the best way is mine and then how can i help you
Forhand.
Forhand.13mo ago
okay I'm sorry, help me are we good now?
EREBUS
EREBUS13mo ago
? is it true
Forhand.
Forhand.13mo ago
no it should send one question and send another after the time is up or after someone answers the correct answer
EREBUS
EREBUS13mo ago
okey then the code'll work but You write question 1 and the time done you write question 2 it is manual way you wanna automatic way but idk how it can be possible
Forhand.
Forhand.13mo ago
oh, okay
EREBUS
EREBUS13mo ago
it is manual way i hope i write true thing
Forhand.
Forhand.13mo ago
I prefer to do it in automatic way
EREBUS
EREBUS13mo ago
i don't know english %100 yeah i understood but idk mate sorry
Forhand.
Forhand.13mo ago
you did help me so much so thanks you for the help
EREBUS
EREBUS13mo ago
love you
Forhand.
Forhand.13mo ago
no worries love you too
EREBUS
EREBUS13mo ago
i hope you'll get automatic way have a nice evenin'
Forhand.
Forhand.13mo ago
you too ❤️
Want results from more Discord servers?
Add your server