'DiscordAPIError: Invalid Form Body: Invalid Emoji

I am making a tickets bot.

When I try click of any of the embeds, it will run the code and create a new channel, then continue to ping me in it like I wanted, but then shows this error.

DiscordAPIError: Invalid Form Body
components[0].components[1].emoji.name: Invalid emoji
at RequestHandler.execute (C:\Users\wrigh\Documents\Discord Bots\Practice Bot - Copy\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\wrigh\Documents\Discord Bots\Practice Bot - Copy\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async TextChannel.send (C:\Users\wrigh\Documents\Discord Bots\Practice Bot - Copy\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15)

The full error is here (sorry for link wouldn't let me post full error) :

https://sourceb.in/dOCoUtAQVx

The code is here:

    const { ButtonInteraction, MessageEmbed, MessageActionRow, MessageButton } = require("discord.js");
    const DB = require("../../Structures/Handlers/Schemas/Ticket");
    const { PARENTID, EVERYONEID } = require("../../Structures/config.json");
    const Ticket = require("../../Structures/Handlers/Schemas/Ticket");

    module.exports = {
    name: "interactionCreate",
    /**
     * 
     * @param {ButtonInteraction} interaction
     */
    async execute(interaction) {
        if(!interaction.isButton()) return;
        const { guild, member, customId } = interaction;
        if (!["player", "bug", "other"].includes(customId)) return;

        const ID = Math.floor(Math.random() * 90000) + 10000;

        await guild.channels
        .create(`${customId + "-" + ID}`, {
        type: "GUILD_TEXT",
        parent: PARENTID,
        permissionOverwrites: [
            {
                id: member.id,
                allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
            },
            {
                id: EVERYONEID,
                deny: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
            },
        ],
        })
        .then(async (channel) => {
            await DB.create({
                GuildID: guild.id,
                MemberID: member.id,
                TicketID: ID,
                ChannelID: channel.id,
                Closed: false,
                Locked: false,
                type: customId,
            });

            const Embed = new MessageEmbed()
            .setAuthor(
                `${guild.name} | Ticket: ${ID}`,
                guild.iconURL({ dynamic: true })
            )
            .setDescription(
                "Please wait patiently for a response from the Staff team, in the mean while, describe your issue in as much detail."
            )
            .setFooter("The buttons below are staff only buttons.");
    
            const Buttons = new MessageActionRow();
            Buttons.addComponents(
                new MessageButton()
                .setCustomId("close")
                .setLabel("Save and close")
                .setStyle("PRIMARY")
                .setEmoji("📂"),
                new MessageButton()
                .setCustomId("lock")
                .setLabel("lock")
                .setStyle("SECONDARY")
                .setEmoji("'🔒"),
                new MessageButton()
                .setCustomId("unlock")
                .setLabel("unlock")
                .setStyle("SUCCESS")
                .setEmoji("❤"),
            );
    
        channel.send({
            embeds: [Embed],
            components: [Buttons],
        });
        await channel
        .send({ content: `${member} here is your ticket` })
        .then((m) => {
            setTimeout(() => {});
            }, 1 * 5000);
        })
    
          interaction.reply({
            content: `${member} your ticket has been created: ${channel}`,
        });
    
    


    },
    };
```js

I'm still learning JavaScript so please bear with me if I don't get it straight away, I will try my best.


Solution 1:[1]

You have an extra character in your lock button. It should be .setEmoji("?"), not .setEmoji("'?"). That's what the error is telling you: "Invalid Emoji" (because '{lock} isn't an emoji)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 0xLogN