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 toolkit13mo 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/luna13mo ago
and what is your issue
qr
qrOP13mo ago
im sending 2 embeds im tryign to edit embed 2 with consoleembed2 @wolvinny 🌈
treble/luna
treble/luna13mo ago
you have to resolve the message you just sent into a variable and call edit on that
qr
qrOP13mo 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/luna13mo ago
can you not ping me in every reply
qr
qrOP13mo ago
mb
d.js docs
d.js docs13mo ago
Resources to understand Promise: - MDN: learn more - Guide: learn more - JavaScript info: learn more
treble/luna
treble/luna13mo ago
you should really understand how promises work
qr
qrOP13mo ago
can u not just tell me how in this context?>
treble/luna
treble/luna13mo ago
No. You need a solid understanding of js
qr
qrOP13mo ago
i do
treble/luna
treble/luna13mo ago
Just helping you without understanding isnt gonna work
qr
qrOP13mo ago
just not with editing messages
treble/luna
treble/luna13mo ago
then you should know how promises work .send returns a promise that resolves into a Message On which you can call .edit
qr
qrOP13mo 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/luna13mo ago
again <TextChannel>.send returns a promise that resolves into a Message On which you can call .edit
qr
qrOP13mo 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/luna13mo ago
It returns a Promise
qr
qrOP13mo ago
doesnt?
treble/luna
treble/luna13mo ago
It does
qr
qrOP13mo ago
DiscordAPIError[50005]: Cannot edit a message authored by another user
treble/luna
treble/luna13mo ago
Well yeah
qr
qrOP13mo ago
nvm i get this now
treble/luna
treble/luna13mo ago
Thats because you're trying to edit the message se't by the user
qr
qrOP13mo ago
how do i edit the specfic embed 2
treble/luna
treble/luna13mo ago
I would recommend to read this
qr
qrOP13mo 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/luna13mo ago
Yeah no Put some effort in and read the tag and read #rules 3
MrDiamond
MrDiamond13mo ago
Don’t expect people to spoon feed you code, if you dont understand something, look it up and gather some knowledge.
qr
qrOP13mo 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/luna13mo ago
you have to store the result from .send in a message which returns a promise so handle it
qr
qrOP13mo 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/luna13mo ago
maybe actually try to understand how promises work Nothing is gonna work if you dont know them Its basic js
MrDiamond
MrDiamond13mo ago
Nothing is working because you don’t have enough knowledge of javascript to understand what’s wrong
qr
qrOP13mo ago
exactly thats why im asking u guys for it
treble/luna
treble/luna13mo ago
#resources
qr
qrOP13mo ago
i swear i tried too confusing
treble/luna
treble/luna13mo 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 docs13mo ago
guide Additional Information: Understanding async/await - How do Promises work? read more
treble/luna
treble/luna13mo ago
thats the last resource i'll give
MrDiamond
MrDiamond13mo 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/luna13mo ago
more resources can be found in #resources
qr
qrOP13mo 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
MrDiamond13mo ago
Nope
qr
qrOP13mo ago
im not trying to learn js i alr know a bit
MrDiamond
MrDiamond13mo ago
Well you need to Your going to get know where if you don’t know what your doing
qr
qrOP13mo ago
i did that with python for close to 2 years and im good at it now
MrDiamond
MrDiamond13mo ago
Well python isn’t javascript They are two totally different languages
qr
qrOP13mo ago
yea but i learnt alot in java while making my fn lobby skin changer
MrDiamond
MrDiamond13mo ago
Java also isnt javascript
qr
qrOP13mo ago
i said js i meant js
MrDiamond
MrDiamond13mo ago
Ok then this shouldn’t be very hard What’s a promise
qr
qrOP13mo ago
idk i legit said i only know a ibt bit never used it while making my bot
MrDiamond
MrDiamond13mo ago
Once again, promises are necessary to learning js And discord js
qr
qrOP13mo ago
yea but id learn if i had a sample code
MrDiamond
MrDiamond13mo ago
Look it up then
treble/luna
treble/luna13mo 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
qrOP13mo ago
all solutions for editing is 1 message or 2 i have multiple alr thanks wolv
MrDiamond
MrDiamond13mo 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
qrOP13mo ago
never did g
MrDiamond
MrDiamond13mo ago
No description
MrDiamond
MrDiamond13mo ago
Just don’t ping me anymore
qr
qrOP13mo ago
didnt ping g
Want results from more Discord servers?
Add your server