bot invites unwanted members into private threads

hi, discord.js I programmed a function that emit a drop embed message (with button) in the channel that reached 100 messages something weird happen when a drop occour in a private thread channel. when this happen, a lot of unwanted and casual users of our gild spawn in it, make a disaster I noticed this occour when the bot send his message in it this is the code that generate a drop message
js const dropPromotionPoints = async (dropChannel) => {
const action = new ActionRowBuilder();
const button = new ButtonBuilder();
const channel = dropChannel.guild.channels.cache.find((channel) => channel.name === customChannels.public)
|| dropChannel.guild.channels.cache.get(dropChannel.guild.publicUpdatesChannelId);
const message1 = new EmbedBuilder();
const message2 = new EmbedBuilder();

action.addComponents(
button
.setCustomId("take")
.setLabel("take")
.setStyle(ButtonStyle.Success)
);
message1
.setTitle("šŸ“¦ā­ new drop")
.setDescription("based on messages sent globally in this server. take it pressing the button below")
.addFields({ name: "type", value: "promotion points", inline: true })
.addFields({ name: "value", value: `${drops.promotionPoints} ā­`, inline: true })
.setThumbnail(dropChannel.client.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor("DarkGreen");
message2
.setTitle("šŸ“¦ā­ new drop")
.setDescription(`a *promotion points* drop spawned in ${dropChannel.name}`)
.addFields({ name: "type", value: "promotion points", inline: true })
.addFields({ name: "value", value: `${drops.promotionPoints} ā­`, inline: true })
.setThumbnail(dropChannel.client.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor("DarkGreen");

await dropChannel.send({ embeds: [message1], components: [action] });
await channel.send({ embeds: [message2] });
};
js const dropPromotionPoints = async (dropChannel) => {
const action = new ActionRowBuilder();
const button = new ButtonBuilder();
const channel = dropChannel.guild.channels.cache.find((channel) => channel.name === customChannels.public)
|| dropChannel.guild.channels.cache.get(dropChannel.guild.publicUpdatesChannelId);
const message1 = new EmbedBuilder();
const message2 = new EmbedBuilder();

action.addComponents(
button
.setCustomId("take")
.setLabel("take")
.setStyle(ButtonStyle.Success)
);
message1
.setTitle("šŸ“¦ā­ new drop")
.setDescription("based on messages sent globally in this server. take it pressing the button below")
.addFields({ name: "type", value: "promotion points", inline: true })
.addFields({ name: "value", value: `${drops.promotionPoints} ā­`, inline: true })
.setThumbnail(dropChannel.client.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor("DarkGreen");
message2
.setTitle("šŸ“¦ā­ new drop")
.setDescription(`a *promotion points* drop spawned in ${dropChannel.name}`)
.addFields({ name: "type", value: "promotion points", inline: true })
.addFields({ name: "value", value: `${drops.promotionPoints} ā­`, inline: true })
.setThumbnail(dropChannel.client.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor("DarkGreen");

await dropChannel.send({ embeds: [message1], components: [action] });
await channel.send({ embeds: [message2] });
};
2 Replies
d.js toolkit
d.js toolkitā€¢9mo 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!
jacopo2199o
jacopo2199oā€¢9mo ago
running on windows: discord.js: 14.13 node: 16.20 yes, programmer šŸŒž thx, that's all the code this function execute when fired by "new message" discord event to have a full picture I can post even the code fired when the button Is pressed
const takePromotionPoints = async (interaction) => {
const takerRole = getCustomRole(interaction.member);
let actionRow = new ActionRowBuilder();
let button = new ButtonBuilder();

interaction.client.emit("activity", interaction.member, drops.promotionPoints);

actionRow.setComponents(
button
.setCustomId("taken")
.setLabel("taken")
.setStyle(ButtonStyle.Danger)
.setDisabled(true)
);

interaction.update({
content: `${takerRole} *${interaction.member}* took the drop`,
components: [actionRow]
});
};
const takePromotionPoints = async (interaction) => {
const takerRole = getCustomRole(interaction.member);
let actionRow = new ActionRowBuilder();
let button = new ButtonBuilder();

interaction.client.emit("activity", interaction.member, drops.promotionPoints);

actionRow.setComponents(
button
.setCustomId("taken")
.setLabel("taken")
.setStyle(ButtonStyle.Danger)
.setDisabled(true)
);

interaction.update({
content: `${takerRole} *${interaction.member}* took the drop`,
components: [actionRow]
});
};
interaction.member does not refer to Who pressed the button? yes, my friend, I think you have found the problem, I mention the entire role so all members that have this role being mentioned inside the thread šŸ¤
Want results from more Discord servers?
Add your server