@nobodyphilia
Начинающий программист

Почему выходит ошибка ReferenceError: embed is not defined?

// interactionCreate.js
const { MessageEmbed } = require("discord.js");
const client = require("..");
var config = require("../settings/config.json");
var ee = require("../settings/embed.json");

client.on('interactionCreate', async interaction => {
    // Slash Command Handling
    if (interaction.isCommand()) {
        await interaction.deferReply({ ephemeral: false }).catch(() => { });

        const cmd = client.slashCommands.get(interaction.commandName);
        if (!cmd)
            return interaction.followUp({ content: "An error has occured " });

        const args = [];

        for (let option of interaction.options.data) {
            if (option.type === "SUB_COMMAND") {
                if (option.name) args.push(option.name);
                option.options?.forEach((x) => {
                    if (x.value) args.push(x.value);
                });
            } else if (option.value) args.push(option.value);
        }
        interaction.member = interaction.guild.members.cache.get(interaction.user.id);

        if (cmd) {
            // checking user perms
            if (!interaction.member.permissions.has(cmd.permissions || [])) {
                return interaction.followUp({
                    embeds: [
                        new MessageEmbed()
                            .setColor(ee.embed_color)
                            .setDescription(`You don't Have ${cmd.permissions} To Run Command..`)
                            .setFooter(ee.embed_footertext, ee.embed_footericon)
                    ]
                })
            }
            cmd.run(client, interaction, args);

        }
    }

    // Context Menu Handling
    if (interaction.isContextMenu()) {
        await interaction.deferReply({ ephemeral: false });
        const command = client.slashCommands.get(interaction.commandName);
        if (command) command.run(client, interaction);
    }
});


// av.js
const { CommandInteraction, Client, MessageEmbed } = require("discord.js");

module.exports = {
    name: "avatar",
    description: "Get avatar of user",
    permissions : [""],
    /**
     *
     * @param {Client} client
     * @param {CommandInteraction} interaction
     * @param {String[]} args
     */
    run: async (client, interaction, args) => {
        let ember = new MessageEmbed()
        .setImage(interaction.user.displayAvatarURL({dynamic: true}))

        interaction.followUp({embeds: [embed]})
    },
};


ReferenceError: embed is not defined
    at Object.run (E:\staff\BotDiscord\slscommands\other\av.js:17:40)
    at Client.<anonymous> (E:\staff\BotDiscord\events\interactionCreate.js:39:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)        
PS E:\staff\BotDiscord>
  • Вопрос задан
  • 164 просмотра
Решения вопроса 1
Alexandre888
@Alexandre888 Куратор тега Боты
Javascript-разработчик
let ember = new MessageEmbed()
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы