Reputation: 165
when I ran a command, it just flew through the messages, and instead goes at the link, it wasn't supposed to be like that, it was suppose to be an answer, then go, answer, then go etc. I trued many ways, but it still flew right pass through some questions, proof below.
Code:
const {Client,Message,MessageEmbed} = require('discord.js')
/**
*
* @param {Client} bot
* @param {Message} message
*/
module.exports.run = async(bot, message) => {
let guild = bot.guilds.cache.get(`851186051598123008`)
let channels = guild.channels.cache.get(`866029925424824350`)
const filter = m => m.author.id === message.author.id
const intro = new MessageEmbed()
.setTitle("Bug Report | Introduction")
.setColor("GREEN")
.setDescription("Hello, I think you have seen a bug lately! Want to report it? Say `next` in order to continue with this prompt!")
.setFooter("Automatically cancelled in 2 minutes. | Say `cancel` to cancel the prompt.")
const cancelEmbed = new MessageEmbed()
.setTitle("Bug Report | Cancelled")
.setColor('RED')
.setDescription("Thank you for trying to report a bug! If you think this is a mistake, please run `<prefix>reportbug` or contact the CS team.")
const collector1 = message.channel.createMessageCollector(filter, {
max: "1",
maxMatches: '1',
time: 120000,
errors:['time']
})
const collector2 = message.channel.createMessageCollector(filter, {
max: "1",
maxMatches: '1',
time: 120000,
errors:['time']
})
const collector3 = message.channel.createMessageCollector(filter, {
max: '1',
maxMatches: '1',
time: 120000,
errors:['time']
})
const collector4 = message.channel.createMessageCollector(filter, {
max: '1',
maxMatches: '1',
time: 1000*60*5,
errors:['time']
})
const collector5 = message.channel.createMessageCollector(filter, {
max: '1',
maxMatches: '1',
time: 1000*60*2,
errors:['time']
})
message.channel.send(intro)
collector1.on('collect', msg => {
if(msg.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(msg.content.toLowerCase() === "next"){
const commandEmbed = new MessageEmbed()
.setTitle("Bug Report | Command Title")
.setDescription("What is the command name? This will give us the specific command.")
.setColor("YELLOW")
.setFooter("Automatically cancelled in 2 minutes. | Say `cancel` to cancel the prompt.")
message.channel.send(commandEmbed)
collector2.on('collect', m => {
if(m.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(m.content){
const descriptionEmbed = new MessageEmbed()
.setFooter("Automatically cancelled in 2 minutes. | Say `cancel` to cancel the prompt.")
.setDescription("What is the bug, as in what happened to reproduce?")
.setTitle("Bug Report | Bug Reproduction")
.setColor('YELLOW')
message.channel.send(descriptionEmbed)
collector3.on('collect', ms => {
if(ms.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(ms.content){
const evidence = new MessageEmbed()
.setFooter("Automatically cancelled in 5 minutes. | Say `cancel` to cancel the prompt.")
.setDescription("Is there any evidence? We only support gyzayo & discord atm! If you don't have any, put 'n/a'!")
.setTitle("Bug Report | Evidence")
.setColor('YELLOW')
message.channel.send(evidence)
collector4.on('collect', mm => {
if(mm.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(mm.content.startsWith('https://cdn.discordapp.com/attachments/' || 'https://gyazo.com/')){
const confirmEmbed = new MessageEmbed()
.setFooter("Automatically cancelled in 2 minutes. | Say `cancel` to cancel the prompt.")
.setDescription("Are you sure that you are going to post this? Option are `yes` or `no`")
.setTitle("Bug Report | Confirmation")
.setColor("YELLOW")
message.channel.send(confirmEmbed)
collector5.on('collect', me => {
if(me.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(me.content.toLowerCase() === "no"){
cancelEmbed.setDescription("Thank you for trying to report a bug! | You have denied to post it!")
return message.channel.send(cancelEmbed)
}
if(me.content.toLowerCase() === "yes"){
const infoEmbed = new MessageEmbed()
.setTitle("Bug Information")
.setColor('BLUE')
.addFields(
{
name: 'Guild Name:',
value: `${message.guild.name} (${message.guild.id})`,
inline: false
},
{
name: 'User: ',
value: `${message.author.tag} (${message.guild.id})`,
inline: false
},
{
name: 'Command Name: ',
value: m.content,
inline: false
},
{
name: 'Bug Description: ',
value: ms.content,
inline: false
},
{
name: 'Bug Proof/Evidence: ',
value: mm.content,
inline: false
}
)
channels.send(infoEmbed)
message.channel.send(`Thank you for submitting a bug report! A developer of ours will review and fix this current bug! You may join the support server by using the following command: \`<prefix>support\`!`)
}
if(!['yes','no','cancel'].includes(me.content)){
cancelEmbed.setDescription(`Thank you for trying to report a bug! | Please include a choice: ['yes','no','cancel'], and please run the prompt again.`)
return message.channel.send(cancelEmbed)
}
// Thank you for trying to report a bug!
})
}
if(mm.content.toLowerCase() === "n/a"){
const confirmEmbed = new MessageEmbed()
.setFooter("Automatically cancelled in 2 minutes. | Say `cancel` to cancel the prompt.")
.setDescription("Are you sure that you are going to post this? Option are `yes` or `no`")
.setTitle("Bug Report | Confirmation")
.setColor("YELLOW")
message.channel.send(confirmEmbed)
collector5.on('collect', me => {
if(me.content.toLowerCase() === "cancel"){
return message.channel.send(cancelEmbed)
}
if(me.content.toLowerCase() === "no"){
cancelEmbed.setDescription("Thank you for trying to report a bug! | You have denied to post it!")
return message.channel.send(cancelEmbed)
}
if(me.content.toLowerCase() === "yes"){
const infoEmbed = new MessageEmbed()
.setTitle("Bug Information")
.setColor('BLUE')
.addFields(
{
name: 'Guild Name:',
value: `${message.guild.name} (${message.guild.id})`,
inline: false
},
{
name: 'User: ',
value: `${message.author.tag} (${message.guild.id})`,
inline: false
},
{
name: 'Command Name: ',
value: m.content,
inline: false
},
{
name: 'Bug Description: ',
value: ms.content,
inline: false
},
{
name: 'Bug Proof/Evidence: ',
value: "N/A",
inline: false
}
)
channels.send(infoEmbed)
message.channel.send(`Thank you for submitting a bug report! A developer of ours will review and fix this current bug! You may join the support server by using the following command: \`<prefix>support\`!`)
}
if(!['yes','no','cancel'].includes(me.content)){
cancelEmbed.setDescription(`Thank you for trying to report a bug! | Please include a choice: ['yes','no','cancel'], and please run the prompt again.`)
return message.channel.send(cancelEmbed)
}
// Thank you for trying to report a bug!
})
}
if(!(mm.content.startsWith('https://cdn.discordapp.com/attachments/' && 'https://gyazo.com/') && ['n/a','cancel'].includes(mm.content))){
cancelEmbed.setDescription("Thank you for trying to report a bug! | Please include a choice: ['n/a','cancel'] or you used a unwhitelisted links of ours!")
}
})
}
})
}
})
}
if(!['next','cancel'].includes(msg.content)){
cancelEmbed.setDescription("Thank you for trying to report a bug! | Invalid option, choose: ['next','cancel'] and run the prompt again!")
message.channel.send(cancelEmbed)
}
})
collector1.on('end', collect => {
if(!collect.size) {
return message.reply(`You didn't reply on time!`)
}
})
collector2.on('end', collect2 => {
if(collect2.size === 0) {
return message.reply(`You didn't reply on time!`)
}
})
collector3.on('end', collect3 => {
if(collect3.size === 0){
return message.reply(`You didn't reply on time!`)
}
})
collector4.on('end', collect4 => {
if(collect4.size === 0){
return message.reply('You didn\'t reply on time!')
}
})
collector5.on('end', collect5 => {
if(collect5.size === 0) {
return message.reply(`You didn't reply on time.`)
}
})
}
module.exports.config = {
name: "bugreport",
aliases: ['reportbug']
}
If anybody can help, that would be wonderful! <3
Upvotes: 0
Views: 396
Reputation: 683
Your code is creating all the collectors at the same time, which makes them trigger all at the same time as well since they have the same filter
function. You should make it so it only creates the next collector after it has gathered the message from the previous, like so:
await message.channel.send(intro);
const collector1 = message.channel.createMessageCollector(filter, {
max: "1",
maxMatches: '1',
time: 120000,
errors:['time']
});
collector1.on('collect', msg => {
(...)
const collector2 = message.channel.createMessageCollector(filter, {
max: "1",
maxMatches: '1',
time: 120000,
errors:['time']
});
collector2.on('collect', msg => {
const collector3 = (...);
}
collector2.on('end', collect => {
if(!collect.size) {
return message.reply(`You didn't reply on time!`)
}
});
}
collector1.on('end', collect => {
if(!collect.size) {
return message.reply(`You didn't reply on time!`)
}
});
By the way, this could be way more simple if you used awaitMessages() instead.
Upvotes: 2