showing results for - "awaitmessages discord js v12"
Anton
17 Mar 2020
1// The provided set allows for responder error with an array of 
2// answers permitted. Ideally, it would be best to place this in
3// a JSON file, which you can call quiz.json for simplicity.
4
5const quiz = require('./quiz.json');
6const item = quiz[Math.floor(Math.random() * quiz.length)];
7const filter = response => {
8	return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
9};
10
11message.channel.send(item.question).then(() => {
12	message.channel.awaitMessages(filter, { max: 1, time: 30000, errors: ['time'] })
13		.then(collected => {
14			message.channel.send(`${collected.first().author} got the correct answer!`);
15		})
16		.catch(collected => {
17			message.channel.send('Looks like nobody got the answer this time.');
18		});
19});