Made a command for user information, gives an error

Made a command for user information, gives an error
Error [GuildMembersTimeout]: Members didn't arrive in time.
at Timeout._onTimeout (C:\Users\User\Desktop\Discord BOT JS\node_modules\discord.js\src\managers\GuildMemberManager.js:267:16)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'GuildMembersTimeout'
}
node:events:492
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Discord BOT JS\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Discord BOT JS\src\events\interactionCreate.js:18:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:395:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

Node.js v18.17.0
Error [GuildMembersTimeout]: Members didn't arrive in time.
at Timeout._onTimeout (C:\Users\User\Desktop\Discord BOT JS\node_modules\discord.js\src\managers\GuildMemberManager.js:267:16)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
code: 'GuildMembersTimeout'
}
node:events:492
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Discord BOT JS\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Discord BOT JS\src\events\interactionCreate.js:18:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:395:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

Node.js v18.17.0
13 Replies
d.js toolkit
d.js toolkit17mo 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!
Black_Wither
Black_Wither17mo ago
Can you show me \events\InteractionCreate.js line 18?
monbrey
monbrey17mo ago
You're probably missing the GuildMembers intent
Обкуренный
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
Maybe, but I didn't quite understand, is it possible somehow in the code?
Cae
Cae17mo ago
Its inside main js file
Обкуренный
What do you mean? I found this only in index.js
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
Squid
Squid17mo ago
You need to add the GuildMembers intent to fetch all members
Обкуренный
C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\commands\Moderation\MemberInfo.js:69:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\events\interactionCreate.js:15:13) {
code: 'InteractionAlreadyReplied'
}
C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:102:46)
at Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\commands\Moderation\MemberInfo.js:69:25)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (C:\Users\User\Desktop\Fury Bot DSICORD JS V14\src\events\interactionCreate.js:15:13) {
code: 'InteractionAlreadyReplied'
}
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
const { Interaction } = require("discord.js");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return

try{


await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}

},



};
interactionCreate.js
Обкуренный
The bot thinks
Squid
Squid17mo ago
In your interactionCreate.js, you should only .reply() if both interaction.replied and interaction.deferred are false Otherwise, you should .followUp() or .editReply() since you have already acknowledged the interaction
Обкуренный
To be honest, I don't fully understand what I need to do now.
Squid
Squid17mo ago
What's happening right now is: 1) It works as normal, reaches your command files, and calls deferReply() 2) Some error occurs 3) It gets kicked out and into your error handler in interactionCreate.js, but because you already acknowledged the interaction, the interaction.reply() is throwing an error
Want results from more Discord servers?
Add your server