- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- 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!
✅Marked as resolved by OP
#Collector not working
38 messages · Page 1 of 1 (latest)
add withResponse: true to the reply call
The fetchReply option when replying to an interaction will be removed in v15.
- {..., fetchReply: true}
+ {..., withResponse: true}
```This returns an [InteractionCallbackResponse](https://discord.js.org/docs/packages/discord.js/14.17.3/InteractionCallbackResponse:Class)
Use `<InteractionCallbackResponse>.resource.message` to get the message
also please show the non transpiled code next time
its?
also that code i was trying to test in eval command
!eval (async () => {
const {
ContainerBuilder,
TextDisplayBuilder,
ButtonBuilder,
ComponentType,
} = discord_js_1;
const msg = await message.channel.send({
flags: 32768,
components: [
new ContainerBuilder()
.addTextDisplayComponents(new TextDisplayBuilder().setContent("hello"))
.addActionRowComponents((row) =>
row.addComponents(
new ButtonBuilder()
.setCustomId("back")
.setEmoji("⬅")
.setStyle(2),
new ButtonBuilder()
.setCustomId("next")
.setEmoji("➡")
.setStyle(2)
)
),
],
});
const collector = msg.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 60_000,
});
collector.on("collect", async (interaction) => {
if (interaction.user.id !== message.author.id) {
return await interaction.reply({
content: "This isn't your navigation!",
ephemeral: true,
});
}
console.log("[Collector] Got:", interaction.customId);
await interaction.deferUpdate();
});
})();```
this is new code i evaled
the message got sent but nothing in the console when i clicked the button
Collector not working
Interaction user is the person pressing the button, message.author is the bot
well i removed the condition
still the same
!eval (async () => {
const {
ContainerBuilder,
TextDisplayBuilder,
ButtonBuilder,
ComponentType,
} = discord_js_1;
const msg = await message.channel.send({
flags: 32768,
components: [
new ContainerBuilder()
.addTextDisplayComponents(new TextDisplayBuilder().setContent("hello"))
.addActionRowComponents((row) =>
row.addComponents(
new ButtonBuilder()
.setCustomId("back")
.setEmoji("⬅")
.setStyle(2),
new ButtonBuilder()
.setCustomId("next")
.setEmoji("➡")
.setStyle(2)
)
),
],
});
const collector = msg.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 60_000,
});
collector.on("collect", async (interaction) => {
console.log("[Collector] Got:", interaction.customId);
await interaction.deferUpdate();
});
})();``` here is the new code
hmmm
i tried adding .on("end")
let containers = buildContainers(input, translation); // dw this is proper
let currentIndex = 0;
let msg = await message.reply({
allowedMentions: { users: [] },
flags: MessageFlags.IsComponentsV2,
components: containers[currentIndex],
});
let buttonsCollector = msg.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 30_000,
});
buttonsCollector.on("collect", async (interaction) => {
console.log("Interaction received:", interaction.customId);
});
buttonsCollector.on("end", (collected, reason) => {
console.log(
`Collector ended: ${reason}. Total collected: ${collected.size}`,
);
});
when i click, nothing happens, no logs anything just "This Interaction Failed"
but when the time is up (30s) it logs "Collector ended: time. Total collected: 0"
How is message defined here
Please Test your code in an actual environment, not through eval commands. Way too many factors causing this to fail in an eval
tested but still the same
message is just Message<true>
here is my actual code```ts
export async function quoteReading(message: Message<true>, input: string) {
try {
let translation = BibleTranslation.AKJV;
let containers = buildContainers(input, translation);
let currentIndex = 0;
console.log("Message:", message);
let msg = await message.reply({
allowedMentions: { users: [] },
flags: MessageFlags.IsComponentsV2,
components: containers[currentIndex],
});
console.log("Message sented:", msg);
let buttonsCollector = msg.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 30_000,
});
buttonsCollector.on("collect", async (interaction) => {
console.log("Interaction received:", interaction.customId);
});
buttonsCollector.on("end", (collected, reason) => {
console.log(
`Collector ended: ${reason}. Total collected: ${collected.size}`,
);
});
} catch (e: any) {
message.channel.send(Couldn’t find **${input}**\n- ${e.message});
}
}```
and console Message: <ref *1> Message { channelId: '1373246510170636319', guildId: '982123184830693476', id: '1375676439415754864', createdTimestamp: 1748057221989, type: 0, system: false, content: '!quote exo 32', author: User { id: '910837428862984213', bot: false, system: false, flags: UserFlagsBitField { bitfield: 4194304 }, username: 'butwhylezi', globalName: 'lezii', discriminator: '0', avatar: '438009cc3ac2e54bf932f8ae8254b5b1', banner: undefined, accentColor: undefined, avatarDecoration: null, avatarDecorationData: null }, pinned: false, tts: false, nonce: '1375676440095227904', embeds: [], components: [], attachments: Collection(0) [Map] {}, stickers: Collection(0) [Map] {}, position: null, roleSubscriptionData: null, resolved: null, editedTimestamp: null, reactions: ReactionManager { message: [Circular *1] }, mentions: MessageMentions { everyone: false, users: Collection(0) [Map] {}, roles: Collection(0) [Map] {}, _members: null, _channels: null, _parsedUsers: null, crosspostedChannels: Collection(0) [Map] {}, repliedUser: null }, webhookId: null, groupActivityApplication: null, applicationId: null, activity: null, flags: MessageFlagsBitField { bitfield: 0 }, reference: null, interactionMetadata: null, interaction: null, poll: null, messageSnapshots: Collection(0) [Map] {}, call: null } Message sented: <ref *1> Message { channelId: '1373246510170636319', guildId: '982123184830693476', id: '1375676445099298996', createdTimestamp: 1748057223344, type: 19, system: false, content: '', author: ClientUser { id: '1365370618979287090', bot: true, system: false, flags: UserFlagsBitField { bitfield: 524288 }, username: 'Pistis', globalName: null, discriminator: '0352', avatar: '2c0e6e9c1d1f208257f77deed5954fc7', banner: undefined, accentColor: undefined, avatarDecoration: null, avatarDecorationData: null, verified: true, mfaEnabled: true }, pinned: false, tts: false, nonce: null, embeds: [], components: [ ContainerComponent { data: [Object], components: [Array] }, ContainerComponent { data: [Object], components: [Array] } ], attachments: Collection(0) [Map] {}, stickers: Collection(0) [Map] {}, position: null, roleSubscriptionData: null, resolved: null, editedTimestamp: null, reactions: ReactionManager { message: [Circular *1] }, mentions: MessageMentions { everyone: false, users: Collection(0) [Map] {}, roles: Collection(0) [Map] {}, _members: null, _channels: null, _parsedUsers: null, crosspostedChannels: Collection(0) [Map] {}, repliedUser: User { id: '910837428862984213', bot: false, system: false, flags: [UserFlagsBitField], username: 'butwhylezi', globalName: 'lezii', discriminator: '0', avatar: '438009cc3ac2e54bf932f8ae8254b5b1', banner: undefined, accentColor: undefined, avatarDecoration: null, avatarDecorationData: null } }, webhookId: null, groupActivityApplication: null, applicationId: null, activity: null, flags: MessageFlagsBitField { bitfield: 32768 }, reference: { channelId: '1373246510170636319', guildId: '982123184830693476', messageId: '1375676439415754864', type: 0 }, interactionMetadata: null, interaction: null, poll: null, messageSnapshots: Collection(0) [Map] {}, call: null } Collector ended: time. Total collected: 0
what's your djs version?
npm ls discord.js
I cannot replicate with latest (14.19.3)
const client = new Client({ intents: ["Guilds"] });
const container = new ContainerBuilder()
.addTextDisplayComponents((text) => text.setContent("test"))
.addActionRowComponents((actionRowBuilder) =>
actionRowBuilder.addComponents(
new ButtonBuilder()
.setCustomId("test")
.setLabel("test")
.setStyle(ButtonStyle.Primary)
)
);
client.on("ready", async () => {
const channel = client.channels.cache.get(CHANNEL_ID) as TextChannel;
const msg = await channel.send({
components: [container],
flags: MessageFlags.IsComponentsV2,
});
const collector = msg.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 30_000,
});
collector.on("collect", async (interaction) => {
await interaction.reply("test");
});
collector.on("end", async (collected, reason) => {
console.log(
`Collector ended: ${reason}. Total collected: ${collected.size}`
);
});
});
client.login();
correctly replies and logs with Collector ended: time. Total collected: 1 upon end
"discord.js": "^14.19.3",
is there prob with container?
of my
?
i tried ts client.on(Events.InteractionCreate, () => console.log("Interaction create boom"), );
and when i click the button, nothing is logged
let me check
https://discord.com/developers/applications > open your app > scroll to "Interactions Endpoint URL", make sure there's nothing there
yeah
bruh
its working now
how dummy i am