Collectors not working

This collector worked for me on discord.js v13, but after rewriting the whole bot on v14 it suddenly stopped working (bot sees interactions because the initial console.logs work, but the bot doesn't want to edit messages and add the tagged channel to the database)
6 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Korrumz2
Korrumz2OP3y ago
const { EmbedBuilder } = require("discord.js");
module.exports = {
customId: `settings-menu`,
type: "select",

run: async (client, interaction) => {
const embed = new EmbedBuilder()
.setDescription(`Please mention your announcement channel, or enter its ID`)
.setColor("Blurple")
await interaction.reply({ embeds: [embed] })

let filter = m => m.author.id === interaction.user.id;
const collector = interaction.channel.createMessageCollector({ filter, time: 15000 });

collector.on('collect', async m => {
const channel = m?.mentions?.channels?.first() || m?.guild?.channels?.cache?.get(m?.content)
if (!channel?.id) {
return interaction.channel.send(`${interaction.user.tag}, It's not channel!`)
}

const get = await client.prisma.guild.findFirst({ where: { id: interaction.guild.id } })

await client.prisma.guild.upsert({
where: {
id: interaction.guild.id
},
create: {
id: interaction.guild.id,
broadcastChannel: channel.id
},
update: {
broadcastChannel: channel.id
}
})

const embedSuccessfully = new EmbedBuilder()
.setDescription(`Successfully added broadcast channel to database!\nNew value: ${channel.name} (<#${channel.id}>)\nYou have a few seconds to change your channel. `)
.setColor("Green")
await interaction.editReply({ embeds: [embedSuccessfully] });
});

collector.on('end', async collected => {
await interaction.editReply( { content: "Your time to complete the options is over.", embeds: [] })
collector.stop()
});
}
}
const { EmbedBuilder } = require("discord.js");
module.exports = {
customId: `settings-menu`,
type: "select",

run: async (client, interaction) => {
const embed = new EmbedBuilder()
.setDescription(`Please mention your announcement channel, or enter its ID`)
.setColor("Blurple")
await interaction.reply({ embeds: [embed] })

let filter = m => m.author.id === interaction.user.id;
const collector = interaction.channel.createMessageCollector({ filter, time: 15000 });

collector.on('collect', async m => {
const channel = m?.mentions?.channels?.first() || m?.guild?.channels?.cache?.get(m?.content)
if (!channel?.id) {
return interaction.channel.send(`${interaction.user.tag}, It's not channel!`)
}

const get = await client.prisma.guild.findFirst({ where: { id: interaction.guild.id } })

await client.prisma.guild.upsert({
where: {
id: interaction.guild.id
},
create: {
id: interaction.guild.id,
broadcastChannel: channel.id
},
update: {
broadcastChannel: channel.id
}
})

const embedSuccessfully = new EmbedBuilder()
.setDescription(`Successfully added broadcast channel to database!\nNew value: ${channel.name} (<#${channel.id}>)\nYou have a few seconds to change your channel. `)
.setColor("Green")
await interaction.editReply({ embeds: [embedSuccessfully] });
});

collector.on('end', async collected => {
await interaction.editReply( { content: "Your time to complete the options is over.", embeds: [] })
collector.stop()
});
}
}
Korrumz2
Korrumz2OP3y ago
(No error in console)
Idris
Idris3y ago
show your intents
Korrumz2
Korrumz2OP3y ago
wait ok im stupid, i forgot about it sorry thanks for reminder
Idris
Idris3y ago
no prob
Want results from more Discord servers?
Add your server