How to properly use "fetchReply" in Discord.js Interaction API?
While working on my Discord.js bot, I encountered the following warning:
npm list discord.js and node node -v version? fetchReply: true to fetch the interaction response message, as shown in the example below and its work
node --trace-deprecation index.js

InteractionCallbackResponse message withResponse i get an error with method createMessageComponentCollector InteractionCallbackResponse, do <response>.resources!.message!.createMessageComponentCollectorconst response = await interaction.reply({
fetchReply: true,
flags: [MessageFlags.Ephemeral],
components: [row],
});
const collector = response.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
time: 60_000,
filter: (i: AnySelectMenuInteraction) => i.user.id === interaction.user.id && i.customId === selectMenu.data.custom_id,
});
collector.on('collect', async (i: AnySelectMenuInteraction) => {
const memberIds = i.values;
for (const memberId of memberIds) {
console.log(memberId);
}
});import { ActionRowBuilder, AnySelectMenuInteraction, ButtonInteraction, ComponentType, MessageFlags, PermissionFlagsBits, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } from "discord.js";
import CustomClient from "../../../base/classes/Client";
import { ButtonIds } from "../../../base/enums/buttonsIds.enum";
import IComponent from "../../../base/interfaces/component.interface";
import { Emojis } from "../../../base/enums/emojis.enum";
export default class Kick implements IComponent {
client: CustomClient;
constructor(client: CustomClient) {
this.client = client;
}
id = ButtonIds.Kick;
async execute(interaction: ButtonInteraction, client: CustomClient) {
const validation = await client.voiceMasterHelper.validation(interaction, this.id);
if (!validation.success) {
if (validation.message) {
interaction.reply({
content: validation.message,
flags: MessageFlags.Ephemeral
});
};
return;
};
const data = validation.data;
const channel = validation.channel!;
const membersSize = channel?.members.size;
const options: StringSelectMenuOptionBuilder[] = channel.members
.filter((m) => m.id !== data?.owner_id)
.filter((m) => !m.permissions.has(PermissionFlagsBits.Administrator || PermissionFlagsBits.ModerateMembers))
.map((m) => {
return new StringSelectMenuOptionBuilder()
.setLabel(`${m.user.username}`)
.setValue(`${m.user.id}`)
});
if (options.length === 0) {
await interaction.reply({
content: `<:warn:${Emojis.Warn}> _Вам некого исключать из канала._`,
flags: MessageFlags.Ephemeral
});
return
};
const selectMenu = new StringSelectMenuBuilder()
.setCustomId(`kick_members`)
.setMinValues(1)
.setMaxValues(membersSize - 1)
.setOptions(options)
const row = new ActionRowBuilder<StringSelectMenuBuilder>()
.setComponents(selectMenu)
const response = await interaction.reply({
components: [row],
flags: MessageFlags.Ephemeral,
// withResponse: true,
})
const collector = response.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
time: 60_000,
filter: (i: AnySelectMenuInteraction) => i.user.id === interaction.user.id && i.customId === selectMenu.data.custom_id,
})
collector.on(`collect`, async (i: AnySelectMenuInteraction) => {
const memberIds = i.values;
for (const memberId of memberIds) {
console.log(memberId);
};
});
};
}; const response = await interaction.reply({
components: [row],
flags: MessageFlags.Ephemeral,
withResponse: true,
})
const collector = response.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
time: 60_000,
filter: (i: AnySelectMenuInteraction) => i.user.id === interaction.user.id && i.customId === selectMenu.data.custom_id,
})
collector.on(`collect`, async (i: AnySelectMenuInteraction) => {
const memberIds = i.values;
for (const memberId of memberIds) {
console.log(memberId);
};
});