#How to get message by id

23 messages · Page 1 of 1 (latest)

obtuse ridge
#

for(let channel of interaction.guild.channels.cache) await console.log(channel[1].messages.fetch(messageId))
does not works

north tinselBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

unreal pike
#
  • First, console.log(await ...) not await console.log(...)
  • Second, channel isn't a array,
  • Third, not all channels have messages
obtuse ridge
#

ok

#

thx

#

the channel has messages

#

and channel is an array

#

and its not working 😦

#

@unreal pike

unreal pike
#

Send you full code

unreal pike
#

Passing a channel Id to the guilds resolve is suported?

#

Also do not spoonfeed code, #rules 5

dapper carbon
#

oops my bad

#

havent really tested but the idea is there. cache is kinda unreliable so fetching from guild to channel to message works

#

it's slower but more reliable

unreal pike
dapper carbon
#

something that i can read

#

thank you in advance

spare raven
#

channel is actually an array of [channelId, channel] since you iterate over the map's entries, if you don't need the keys you can iterate over values() instead

#

that said, trying to fetch a message from each channel can get quite API spammy, wherever you obtained the message id you should also save the channel id and fetch only from this channel

unreal pike
#

My bad