Kuezy
Kuezy

Reputation: 101

DiscordJS edit existing embed

I want to edit a existing embed in discord.js. But Im getting the error that message.edit is not a function.

Code:

        await mongo().then(async mongoose => {

        const results = await applicationSchema.findOneAndDelete({
            guildId: guildId,
            applicationId: applicationId
        })

        for (const application of results.applications) {
            const { applicationId, userId, appliedfor } = application
            user22 = bot.users.cache.get(userId);
            let acceptembed = new Discord.MessageEmbed()
                .setColor(colours.maincolour)
                .setDescription(`Lieber <@${userId}>! Deine Bewerbung wurde angenommen!`)
            user22.send(acceptembed)
                // m = reaction.messages.cache.fetch(applicationId);
                // m.edit(null, { embed: output });
            let message = bot.channels.cache.get('823554343827013652').messages.fetch(applicationId)
            await message.edit()
        }

    })

Upvotes: 0

Views: 85

Answers (1)

Beam
Beam

Reputation: 66

The message you are sending should be put in .edit() as it would for .send(). Please note that this does not add to the message, but instead replaces it.

bot.channels.cache.get('823554343827013652').messages.fetch(applicationId)
    .then(message => message.edit(acceptembed));

Upvotes: 1

Related Questions