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
};
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
};
7 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
</> Idris
</> Idris3y ago
you don't have to create a new client instance in each file
! Bemep
! BemepOP3y ago
Ok, i did const client = new Client(); and got an error "TypeError [ClientMissingIntents]: Valid intents must be provided for the Client"
</> Idris
</> Idris3y ago
I just told you that you don't have to create a new client in each file I assume bot is already a Client instance use it
! Bemep
! BemepOP3y ago
Oh, you mean (bot, args, argsF) This doesn't solve my problem
</> Idris
</> Idris3y ago
replace all your client by bot assuming bot is already a Client instance
! Bemep
! BemepOP3y ago
It works thanks
Want results from more Discord servers?
Add your server