#How do you cache messages? Discord.js 13.0.0

8 messages · Page 1 of 1 (latest)

visual mist
#

I've made a reaction role command and an event to make sure they can still be reacted to after the bot has been turned off and on again. The only problem is I need to cache the messages. Right now I'm using client.channels.cache.get('channel').messages.fetch("message") to get the message in my ready.js file but it's not working and giving me this error

/home/runner/DevStudio-Helper-project/node_modules/discord.js/src/rest/RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Unknown Message
    at RequestHandler.execute (/home/runner/DevStudio-Helper-project/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/runner/DevStudio-Helper-project/node_modules/discord.js/src/rest/RequestHandler.js:51:14) {
  method: 'get',
  path: '/channels/1024696016122937384/messages/1036336682175307786',
  code: 10008,
  httpStatus: 404,
  requestData: { json: undefined, files: [] }```
green dust
#

• 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.

tepid mortar
#

If you get that error it means a message with that id doesn't exist (anymore) in that channel, so djs won't ever cache it

visual mist
#

They are still in the channel, and I've made sure I've put the correct channelid and messageid

tepid mortar
#

Discord disagrees

#

make sure they are both strings, and not numbers

visual mist
#

Yep that was the problem

#

Forgot to make them strings