channel.threads.create at collector creates two threads in one time

async function setup_message() {
const { guild } = require("./discord_bot.js")
var channel = await guild.channels.fetch("1146767939958231060");
var message = await channel.messages.fetch("1146768903830241311");
var message_data = { embeds: [CreateMenu], components: [row] };
await message.edit(message_data);
const collector = message.createMessageComponentCollector();
collector.on('collect', async interaction => {

if (interaction.isButton()) {
if (interaction.customId === 'create') {
console.log("Test")
channel.threads.create({
name: 'food-talk',
autoArchiveDuration: 60,
reason: 'Needed a separate thread for food',
});
}
}
});
}
async function setup_message() {
const { guild } = require("./discord_bot.js")
var channel = await guild.channels.fetch("1146767939958231060");
var message = await channel.messages.fetch("1146768903830241311");
var message_data = { embeds: [CreateMenu], components: [row] };
await message.edit(message_data);
const collector = message.createMessageComponentCollector();
collector.on('collect', async interaction => {

if (interaction.isButton()) {
if (interaction.customId === 'create') {
console.log("Test")
channel.threads.create({
name: 'food-talk',
autoArchiveDuration: 60,
reason: 'Needed a separate thread for food',
});
}
}
});
}
3 Replies
d.js toolkit
d.js toolkit16mo 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!
Parogo_72
Parogo_7216mo ago
probably you are calling that function twice, thus creating two collectors so the collector function will run twice
Andrew📎
Andrew📎OP16mo ago
the console log returns only one "test"
Want results from more Discord servers?
Add your server