The reply to this interaction has not been sent

Hey there! I'm using discord.js v13.8.0 and I'm trying to make an AFK command, I ran the command but I am met with an error shown below
Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.followUp (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:169:64)
at /home/container/commands/slash/afk.js:42:23
at /home/container/node_modules/mongoose/lib/model.js:5095:18
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
} Promise {
<rejected> Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.followUp (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:169:64)
at /home/container/commands/slash/afk.js:42:23
at /home/container/node_modules/mongoose/lib/model.js:5095:18
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
}
Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.followUp (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:169:64)
at /home/container/commands/slash/afk.js:42:23
at /home/container/node_modules/mongoose/lib/model.js:5095:18
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
} Promise {
<rejected> Error [INTERACTION_NOT_REPLIED]: The reply to this interaction has not been sent or deferred.
at CommandInteraction.followUp (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:169:64)
at /home/container/commands/slash/afk.js:42:23
at /home/container/node_modules/mongoose/lib/model.js:5095:18
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
}
}
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
vance_
vance_OP3y ago
My code:
const colors = require("colors");
const { MessageEmbed } = require("discord.js");
const SlashCommand = require("../../lib/SlashCommand");
const afkSchema = require('../../database/afkSchema');

const command = new SlashCommand()
.setName("afk")
.setDescription("Set your AFK on/off")
.addStringOption((option) =>
option
.setName('reason')
.setDescription('The reason to be AFK')
.setRequired(false)
)
.setRun(async (client, interaction) => {

const reason = interaction.options.getString('reason') || 'No Reason Provided'

const params = {
guild: interaction.guild.id,
user: interaction.user.id
}

afkSchema.findOne({params}, async(err, data) => {
if(data) {
data.delete()
interaction.reply({
embeds: [
new MessageEmbed()
.setDescription(`${client.emojiconfig.correct} You are no longer AFK!`)
.setColor("GREEN")
]
})
} else {
new afkSchema({
guild: interaction.guild.id,
user: interaction.user.id,
reason: reason,
date: Date.now()
}).save()

interaction.followUp({
embeds: [
new MessageEmbed()
.setDescription(`${client.emojiconfig.correct} You are now AFK for: __**${reason}**__`)
.setColor("GREEN")
]
})
}
})
});

module.exports = command;
const colors = require("colors");
const { MessageEmbed } = require("discord.js");
const SlashCommand = require("../../lib/SlashCommand");
const afkSchema = require('../../database/afkSchema');

const command = new SlashCommand()
.setName("afk")
.setDescription("Set your AFK on/off")
.addStringOption((option) =>
option
.setName('reason')
.setDescription('The reason to be AFK')
.setRequired(false)
)
.setRun(async (client, interaction) => {

const reason = interaction.options.getString('reason') || 'No Reason Provided'

const params = {
guild: interaction.guild.id,
user: interaction.user.id
}

afkSchema.findOne({params}, async(err, data) => {
if(data) {
data.delete()
interaction.reply({
embeds: [
new MessageEmbed()
.setDescription(`${client.emojiconfig.correct} You are no longer AFK!`)
.setColor("GREEN")
]
})
} else {
new afkSchema({
guild: interaction.guild.id,
user: interaction.user.id,
reason: reason,
date: Date.now()
}).save()

interaction.followUp({
embeds: [
new MessageEmbed()
.setDescription(`${client.emojiconfig.correct} You are now AFK for: __**${reason}**__`)
.setColor("GREEN")
]
})
}
})
});

module.exports = command;
The tags are of no help either
d.js docs
d.js docs3y ago
Resources to understand Promise: • MDN: learn more • Guide: learn more • JavaScript info: learn more
vance_
vance_OP3y ago
I didn't follow.. Is this a pun or something? In your else you don't reply, you mean I should not reply in my else { }? and there is no reply before followUp? Is that what you were trying to say I don't understand is what I Meant Ah and the reply before the else? alright Thanks! it works
Want results from more Discord servers?
Add your server