Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Message By ID: Discord.js

I am doing a report system for a discord bot and I want the player to report a specific message by the id so that the moderators can decide if it is offensive or not. I am struggling to find a way to get the message's text from the given id. Is there a possible way of doing this?

like image 549
NintendoZaedus Avatar asked Mar 23 '18 04:03

NintendoZaedus


People also ask

How do I find a Discord message using ID?

How do I find a discord message using ID? Add a search option in the search bar with the name: “ID”. This feature would allow user's who cannot code bots, or don't have bots that can fetch messages to find specific messages with IDs. If no message is found an error can be returned, etc.

How do you copy a chat ID in Discord?

If you want to export Discord chat messages, you won't find any built-in feature to do so. If you want to download your messages, you'll need to select, copy, and paste the messages manually, or use a tool like DiscordChatExporter to do it for you.

How do I find my Discord bot channel ID?

To get a Channel ID right click the channel and click on "Copy ID" then paste it into your Discord or on a text editor. Alternatively type the channel as a mention and place a backslash \ in front of the mention. It should look like this <#475182341782896651> and the number is the ID.


1 Answers

fetchMessage is no longer present in Discord.js starting in version 12, but you can use the fetch method of the MessageManager class from the messages property of the TextChannel class.

msg.channel.messages.fetch("701574160211771462")
  .then(message => console.log(message.content))
  .catch(console.error);
like image 134
Duncan Avatar answered Oct 04 '22 01:10

Duncan