edit msg

const { Client, GatewayIntentBits, Events } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});


const wait = require('node:timers/promises').setTimeout;

prefix = "."
client.on("messageCreate", message => {
if (message.content.startsWith(prefix + "ping")) {
console.log("2349")
message.channel.send('Pong! :Pingsock:');
}
else if (message.content.startsWith(prefix + "start")) {
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':rocket: Initializing bot')
.setThumbnail('https://fortnite-api.com/images/cosmetics/br/cid_035_athena_commando_m_medieval/smallicon.png')
.addFields(
{ name: ':bust_in_silhouette: Account', value: '`Kanyes_chai`' },
)
const consoleembed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':floppy_disk: Console')
.setDescription('
const { Client, GatewayIntentBits, Events } = require('discord.js');
const { EmbedBuilder } = require('discord.js');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});


const wait = require('node:timers/promises').setTimeout;

prefix = "."
client.on("messageCreate", message => {
if (message.content.startsWith(prefix + "ping")) {
console.log("2349")
message.channel.send('Pong! :Pingsock:');
}
else if (message.content.startsWith(prefix + "start")) {
const exampleEmbed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':rocket: Initializing bot')
.setThumbnail('https://fortnite-api.com/images/cosmetics/br/cid_035_athena_commando_m_medieval/smallicon.png')
.addFields(
{ name: ':bust_in_silhouette: Account', value: '`Kanyes_chai`' },
)
const consoleembed = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':floppy_disk: Console')
.setDescription('
Started bot
')
const consoleembed2 = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':floppy_disk: Console')
.setDescription('
')
const consoleembed2 = new EmbedBuilder()
.setColor(0x0099FF)
.setTitle(':floppy_disk: Console')
.setDescription('
Started bot\n Logged in as "Kanyes_chai"\n
')
message.channel.send({ embeds: [exampleEmbed] });
message.channel.send({ embeds: [consoleembed] });
wait(2000);
message.edit({ embeds: [consoleembed2] });
}
}

);

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
console.log("works");


client.login("");
')
message.channel.send({ embeds: [exampleEmbed] });
message.channel.send({ embeds: [consoleembed] });
wait(2000);
message.edit({ embeds: [consoleembed2] });
}
}

);

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
console.log("works");


client.login("");
64 Replies
d.js toolkit
d.js toolkit•12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna•12mo ago
and what is your issue
qr
qrOP•12mo ago
im sending 2 embeds im tryign to edit embed 2 with consoleembed2 @wolvinny 🌈
treble/luna
treble/luna•12mo ago
you have to resolve the message you just sent into a variable and call edit on that
qr
qrOP•12mo ago
how can i resolve the message into a variable or wait idk how @wolvinny 🌈 m = message.channel.send({ embeds: [consoleembed] }); m wait(2000); message.edit({ embeds: [consoleembed2] }); }
treble/luna
treble/luna•12mo ago
can you not ping me in every reply
qr
qrOP•12mo ago
mb
d.js docs
d.js docs•12mo ago
Resources to understand Promise: - MDN: learn more - Guide: learn more - JavaScript info: learn more
treble/luna
treble/luna•12mo ago
you should really understand how promises work
qr
qrOP•12mo ago
can u not just tell me how in this context?>
treble/luna
treble/luna•12mo ago
No. You need a solid understanding of js
qr
qrOP•12mo ago
i do
treble/luna
treble/luna•12mo ago
Just helping you without understanding isnt gonna work
qr
qrOP•12mo ago
just not with editing messages
treble/luna
treble/luna•12mo ago
then you should know how promises work .send returns a promise that resolves into a Message On which you can call .edit
qr
qrOP•12mo ago
i just dont know hjow to use the .edit to specific message message.edit({ message}); where would the message im aiming go at
treble/luna
treble/luna•12mo ago
again <TextChannel>.send returns a promise that resolves into a Message On which you can call .edit
qr
qrOP•12mo ago
i still cant tried everything u said m= message.channel.send({ embeds: [exampleEmbed] });
m wait(2000); m.edit({ embeds: [consoleembed2] }); message.channel.send({ embeds: [exampleEmbed] }); wait(2000); message.edit({ embeds: [consoleembed2] });
treble/luna
treble/luna•12mo ago
It returns a Promise
qr
qrOP•12mo ago
doesnt?
treble/luna
treble/luna•12mo ago
It does
qr
qrOP•12mo ago
DiscordAPIError[50005]: Cannot edit a message authored by another user
treble/luna
treble/luna•12mo ago
Well yeah
qr
qrOP•12mo ago
nvm i get this now
treble/luna
treble/luna•12mo ago
Thats because you're trying to edit the message se't by the user
qr
qrOP•12mo ago
how do i edit the specfic embed 2
treble/luna
treble/luna•12mo ago
I would recommend to read this
qr
qrOP•12mo ago
i did can you not just give me the code i tried everything idek can u not just give me a sample code example or edit mine
treble/luna
treble/luna•12mo ago
Yeah no Put some effort in and read the tag and read #rules 3
MrDiamond
MrDiamond•12mo ago
Don’t expect people to spoon feed you code, if you dont understand something, look it up and gather some knowledge.
qr
qrOP•12mo ago
ive been doing that for over an hour thats why i opened the ticket ik how to edit a message not send multiple embeds and edit 1 one of them only
treble/luna
treble/luna•12mo ago
you have to store the result from .send in a message which returns a promise so handle it
qr
qrOP•12mo ago
alr ill try again nthn is working ill just not use that feature spent too long on it and couldnt make it work
treble/luna
treble/luna•12mo ago
maybe actually try to understand how promises work Nothing is gonna work if you dont know them Its basic js
MrDiamond
MrDiamond•12mo ago
Nothing is working because you don’t have enough knowledge of javascript to understand what’s wrong
qr
qrOP•12mo ago
exactly thats why im asking u guys for it
treble/luna
treble/luna•12mo ago
#resources
qr
qrOP•12mo ago
i swear i tried too confusing
treble/luna
treble/luna•12mo ago
they're key to be able to work with djs and js in general So you'll somehow have to figure out a way
d.js docs
d.js docs•12mo ago
guide Additional Information: Understanding async/await - How do Promises work? read more
treble/luna
treble/luna•12mo ago
thats the last resource i'll give
MrDiamond
MrDiamond•12mo ago
We aren’t your teachers, we are random people who know how javascript works, look up “learn javascript” and try to get some knowledge
treble/luna
treble/luna•12mo ago
more resources can be found in #resources
qr
qrOP•12mo ago
idr need to learn it since my bot is just a handler for my fn bot i just needed the simple code on how to edit or a example but it took too long
MrDiamond
MrDiamond•12mo ago
Nope
qr
qrOP•12mo ago
im not trying to learn js i alr know a bit
MrDiamond
MrDiamond•12mo ago
Well you need to Your going to get know where if you don’t know what your doing
qr
qrOP•12mo ago
i did that with python for close to 2 years and im good at it now
MrDiamond
MrDiamond•12mo ago
Well python isn’t javascript They are two totally different languages
qr
qrOP•12mo ago
yea but i learnt alot in java while making my fn lobby skin changer
MrDiamond
MrDiamond•12mo ago
Java also isnt javascript
qr
qrOP•12mo ago
i said js i meant js
MrDiamond
MrDiamond•12mo ago
Ok then this shouldn’t be very hard What’s a promise
qr
qrOP•12mo ago
idk i legit said i only know a ibt bit never used it while making my bot
MrDiamond
MrDiamond•12mo ago
Once again, promises are necessary to learning js And discord js
qr
qrOP•12mo ago
yea but id learn if i had a sample code
MrDiamond
MrDiamond•12mo ago
Look it up then
treble/luna
treble/luna•12mo ago
this is going nowhere. Please take the time to learn promises, i gave you enough resources if you still have issues after that you can come back But learn promises first
qr
qrOP•12mo ago
all solutions for editing is 1 message or 2 i have multiple alr thanks wolv
MrDiamond
MrDiamond•12mo ago
No. Look up how promises work. I’m not arguing with you anymore, this is a complete waste of our times Don’t ping me
qr
qrOP•12mo ago
never did g
MrDiamond
MrDiamond•12mo ago
No description
MrDiamond
MrDiamond•12mo ago
Just don’t ping me anymore
qr
qrOP•12mo ago
didnt ping g
Want results from more Discord servers?
Add your server