“Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred” I keep getting this error on discord.js v14

I am trying to make a bank command with subcommands “balance, withdraw, deposit and transfer coins”, but every time I try to run the command I get the error “The reply to this interaction has already been sent or deferred”. I have tried to change the interaction.reply to interaction.deferReply and sometimes to interaction.followUp but no matter what I kept on getting the same error over and over again.

bank.js

const { ApplicationCommandOptionType } = require("discord.js");
const balance = require("./sub/balance");
const deposit = require("./sub/deposit");
const transfer = require("./sub/transfer");
const withdraw = require("./sub/withdraw");
const emoji = require("../../utils/emojis.json");

/**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */

module.exports = {
  name: "bank",
  description: "access to bank operations",
  subcommands: [
    {
      trigger: "balance",
      description: "check your balance",
    },
    {
      trigger: "deposit <coins>",
      description: "deposit coins to your bank account",
    },
    {
      trigger: "withdraw <coins>",
      description: "withdraw coins from your bank account",
    },
    {
      trigger: "transfer <user> <coins>",
      description: "transfer coins to another user",
    },
  ],
  options: [
    {
      name: "balance",
      description: "check your coin balance",
      type: ApplicationCommandOptionType.Subcommand,
      options: [
        {
          name: "user",
          description: "name of the user",
          type: ApplicationCommandOptionType.User,
          required: false,
        },
      ],
    },
    {
      name: "deposit",
      description: "deposit coins to your bank account",
      type: ApplicationCommandOptionType.Subcommand,
      options: [
        {
          name: "coins",
          description: "number of coins to deposit",
          type: ApplicationCommandOptionType.Integer,
          required: true,
        },
      ],
    },
    {
      name: "withdraw",
      description: "withdraw coins from your bank account",
      type: ApplicationCommandOptionType.Subcommand,
      options: [
        {
          name: "coins",
          description: "number of coins to withdraw",
          type: ApplicationCommandOptionType.Integer,
          required: true,
        },
      ],
    },
    {
      name: "transfer",
      description: "transfer coins to other user",
      type: ApplicationCommandOptionType.Subcommand,
      options: [
        {
          name: "user",
          description: "the user to whom coins must be transferred",
          type: ApplicationCommandOptionType.User,
          required: true,
        },
        {
          name: "coins",
          description: "the amount of coins to transfer",
          type: ApplicationCommandOptionType.Integer,
          required: true,
        },
      ],
    },
  ],
  callback: async (args, interaction, client) => {
    const sub = args[0];
    let response;

    if (sub === "balance") {
      const resolved =
        (await interaction.guild.resolveMember(args[1])) || interaction.member;
      response = await balance(resolved.user);
    }

    //
    else if (sub === "deposit") {
      const coins = args.length && parseInt(args[1]);
      if (isNaN(coins))
         interaction.reply(
          "Provide a valid number of coins you wish to deposit"
        );
      response = await deposit(interaction.author, coins);
    }

    //
    else if (sub === "withdraw") {
      const coins = args.length && parseInt(args[1]);
      if (isNaN(coins))
         interaction.reply(
          "Provide a valid number of coins you wish to withdraw"
        );
      response = await withdraw(interaction.author, coins);
    }

    //
    else if (sub === "transfer") {
      if (args.length < 3)
         interaction.reply("Provide a valid user and coins to transfer");
      const target = await interaction.guild.resolveMember(args[1], true);
      if (!target)
         interaction.reply("Provide a valid user to transfer coins to");
      const coins = parseInt(args[2]);
      if (isNaN(coins))
         interaction.reply(
          "Provide a valid number of coins you wish to transfer"
        );
      response = await transfer(interaction.author, target.user, coins);
    }

    //
    else {
        await interaction.reply("Invalid command usage");
    }

    await interaction.reply(response);
  },

  async interactionRun(interaction) {
    const sub = interaction.options.getSubcommand();
    let response;

    // balance
    if (sub === "balance") {
      const user = interaction.options.getUser("user") || interaction.user;
      response = await balance(user);
    }

    // deposit
    else if (sub === "deposit") {
      const coins = interaction.options.getInteger("coins");
      response = await deposit(interaction.user, coins);
    }

    // withdraw
    else if (sub === "withdraw") {
      const coins = interaction.options.getInteger("coins");
      response = await withdraw(interaction.user, coins);
    }

    // transfer
    else if (sub === "transfer") {
      const user = interaction.options.getUser("user");
      const coins = interaction.options.getInteger("coins");
      response = await transfer(interaction.user, user, coins);
    }

    await interaction.editReply(response);
  },
};

balance

const { EmbedBuilder } = require("discord.js");
const User = require("../../../models/user");
const emoji = require("../../../utils/emojis.json");

/**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */

module.exports = {
  callback: async (user, interaction, client) => {
    const embed = new EmbedBuilder()
      .setAuthor({ name: user.username })
      .setThumbnail(user.displayAvatarURL())
      .addFields(
        {
          name: "Wallet",
          value: `${user.coinsInWallet || 0}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Bank",
          value: `${user.coinsInBank || 0}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Net Worth",
          value: `${(user.coinsInWallet || 0) + (user.coinsInBank || 0)}${
            emoji.coin
          }`,
          inline: true,
        }
      );

     interaction.deferReply({ embeds:  });
  },
};

deposit

const { EmbedBuilder } = require("discord.js");
const User = require("../../../models/user");
const emoji = require("../../../utils/emojis.json");

/**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */

module.exports = {
  callback: async (user, coins, interaction, client) => {
    if (isNaN(coins) || coins <= 0)
      return "Please enter a valid amount of coins to deposit";
    const userDb = await getUser(user);

    if (coins > user.coins)
      return `You only have ${userDb.coins}${emoji.coin} coins in your wallet`;

    userDb.coins -= coins;
    userDb.bank += coins;
    await userDb.save();

    const embed = new EmbedBuilder()
      .setAuthor({ name: "New Balance" })
      .setThumbnail(user.displayAvatarURL())
      .addFields(
        {
          name: "Wallet",
          value: `${userDb.coins}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Bank",
          value: `${userDb.bank}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Net Worth",
          value: `${userDb.coins + userDb.bank}${emoji.coin}`,
          inline: true,
        }
      );

       interaction.deferReply({ embeds:  });
  },
};

transfer

const { EmbedBuilder } = require("discord.js");
const User = require("../../../models/user");
const emoji = require("../../../utils/emojis.json");

/**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */

module.exports = {
  callback: async (self, target, coins, interaction, client) => {
    if (isNaN(coins) || coins <= 0)
      return "Please enter a valid amount of coins to transfer";
    if (target.bot) return "You cannot transfer coins to bots!";
    if (target.id === self.id) return "You cannot transfer coins to self!";

    const userDb = await getUser(self);

    if (userDb.bank < coins) {
      return `Insufficient bank balance! You only have ${userDb.bank}${
        emoji.coin
      } in your bank account.${
        userDb.coins > 0 &&
        "nYou must deposit your coins in bank before you can transfer"
      } `;
    }

    const targetDb = await getUser(target);

    userDb.bank -= coins;
    targetDb.bank += coins;

    await userDb.save();
    await targetDb.save();

    const embed = new EmbedBuilder()
      .setAuthor({ name: "Updated Balance" })
      .setDescription(
        `You have successfully transferred ${coins}${emoji.coin} to ${target.username}`
      )
      .setTimestamp(Date.now());

       interaction.deferReply({ embeds:  });
  },
};

withdraw

const { EmbedBuilder } = require("discord.js");
const User = require("../../../models/user");
const emoji = require("../../../utils/emojis.json");

/**
 *
 * @param {Client} client
 * @param {Interaction} interaction
 */

module.exports = {
  callback: async (user, coins, interaction, client) => {
    if (isNaN(coins) || coins <= 0)
      return "Please enter a valid amount of coins to deposit";
    const userDb = await getUser(user);

    if (coins > userDb.bank)
      return `You only have ${userDb.bank}${emoji.coin} coins in your bank`;

    userDb.bank -= coins;
    userDb.coins += coins;
    await userDb.save();

    const embed = new EmbedBuilder()
      .setAuthor({ name: "New Balance" })
      .setThumbnail(user.displayAvatarURL())
      .addFields(
        {
          name: "Wallet",
          value: `${userDb.coins}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Bank",
          value: `${userDb.bank}${emoji.coin}`,
          inline: true,
        },
        {
          name: "Net Worth",
          value: `${userDb.coins + userDb.bank}${emoji.coin}`,
          inline: true,
        }
      );

       interaction.deferReply({ embeds:  });
  },
};

New contributor

akaxyi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật