UMI
UMI
DIAdiscord.js - Imagine an app
Created by UMI on 5/20/2024 in #djs-questions
How do I send timed messages using cron please?
HI im not to sure how to work with cron and commands to end a timed message every midnight
7 replies
DIAdiscord.js - Imagine an app
Created by UMI on 5/11/2024 in #djs-questions
why this collector isnt working?its not responding to the answers
module.exports = {
data: new SlashCommandBuilder()
.setName("quotes-quiz")
.setDescription("Answer some league quotes"),

async execute(interaction) {
const item = quiz[Math.floor(Math.random() * quiz.length)];
const collectorFilter = response => {
return item.answer.some(answer => answer.toLowerCase() === response.content.toLowerCase());
};

interaction.reply({content: item.question, fetchReply: true})
.then(() => {
interaction.channel.awaitMessages({filter: collectorFilter, max: 1, time: 10_000, errors: ['time']})
.then(collected => {
interaction.followUp(`${collected.first().author} got the correct answer!`);
})
.catch(collected => {
interaction.followUp('Looks like nobody got the answer this time.');

});
});

}
}
module.exports = {
data: new SlashCommandBuilder()
.setName("quotes-quiz")
.setDescription("Answer some league quotes"),

async execute(interaction) {
const item = quiz[Math.floor(Math.random() * quiz.length)];
const collectorFilter = response => {
return item.answer.some(answer => answer.toLowerCase() === response.content.toLowerCase());
};

interaction.reply({content: item.question, fetchReply: true})
.then(() => {
interaction.channel.awaitMessages({filter: collectorFilter, max: 1, time: 10_000, errors: ['time']})
.then(collected => {
interaction.followUp(`${collected.first().author} got the correct answer!`);
})
.catch(collected => {
interaction.followUp('Looks like nobody got the answer this time.');

});
});

}
}
here is what the json looks like
[
{
"question": "Who says: \"The warrior's spirit is never broken.\"",
"answer": ["Xin Zhao", "xinzhao", "Xin"]
},
{
"question": "Who says: \"Break men to break their shackles.\"",
"answer": ["urgot", "Urgot"]
},
{
"question": "Who says: \"Everyone stay put, I'll be right back.\"",
"answer": ["galio", "Galio"]
}
]
[
{
"question": "Who says: \"The warrior's spirit is never broken.\"",
"answer": ["Xin Zhao", "xinzhao", "Xin"]
},
{
"question": "Who says: \"Break men to break their shackles.\"",
"answer": ["urgot", "Urgot"]
},
{
"question": "Who says: \"Everyone stay put, I'll be right back.\"",
"answer": ["galio", "Galio"]
}
]
8 replies