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