#Editing an message

1 messages ยท Page 1 of 1 (latest)

fluid temple
verbal monolith
#

hi

deft spoke
fluid temple
#

^ @verbal monolith

verbal monolith
#

ty guys

fluid temple
#

No problem

verbal monolith
#

But how does it know which message? Probably a silly question

#

@fluid temple

fluid temple
#

Could you send a snippet of the code you are using for editing the message

verbal monolith
#
message.edit('This is my new content!')
  .then(msg => console.log(`Updated the content of a message to ${msg.content}`))
  .catch(console.error);   ```
fluid temple
#

Messages are indexed by ids, im not sure if that helps.

#

Could you elaborate your question?

verbal monolith
#

That helped

fluid temple
#

Thank you for asking

verbal monolith
#

Ehmmmm.. Why does this not work? @fluid temple ๐Ÿ˜„

  let id = message.id
  console.log(id)
  

})
await.sleep(5000)
id.edit('This is my new content!')
  .then(msg => console.log(`Updated the content of a message to ${msg.content}`))
  .catch(console.error);   ```
fluid temple
#

Alright, so firstly your bot has to send an message and then do .then(msg => {msg.edit()}) , right now there is no message to edit

#

Secondly, it's kind of with that but an message ID isn't an message object (which can be returned by handling the promise using .then)

verbal monolith
fluid temple
#

Yep!

#

So i'll show the whole require trace so you dont get confused

verbal monolith
#

ty

fluid temple
#
client.on('messageCreate', message => {
  if(message.author.bot) return
  message.reply('Example message').then(msg => {
    msg.edit(options)
  })
})```
#

@verbal monolith

verbal monolith
fluid temple
#

No problem

verbal monolith
# fluid temple No problem

But how can i make this work???

  if(message.author.bot) return
  message.reply('Example message').then(msg => {
    setTimeout(10)
    msg.edit('e')
  })
})   ```
fluid temple
verbal monolith
#

ty