How can i edit a message by its id?

So I did it like this, but got an error "TypeError: Cannot read properties of undefined (reading 'messages')"
const Discord = require('discord.js');
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds], partials: [Partials.Channel] });
const { EmbedBuilder } = require('discord.js');

module.exports = async (bot, args, argsF) => {
    const exampleEmbed = new EmbedBuilder()
        .setColor(0x00c0ff)
        .setDescription('New description.')
    const channel = client.channels.cache.get(`1038743646670966854`);
    const message = await channel.messages.fetch(`1038743874950135818`);

channel.messages.edit("1038743874950135818", { embeds: [exampleEmbed]})
}

module.exports.names = ["edit"];
module.exports.interaction = {
    name: 'edit', 
    description: 'Command description.',
    defaultPermission: true 
};
Was this page helpful?