Currently in the process of developing a discord bot with an election feature for my server's moderator.
All the necessary election data is being saved in an external JSON
file to ensure that if the bot crashes during an election, it can seamlessly resume from where it left off upon restarting without any user input. To achieve this, I am utilizing the npm package edit-json-file
to edit and read my JSON
.
Encountering an issue when retrieving a message object from the JSON
in order to create a reaction collector, resulting in the following error:
TypeError: electionData.get("message").createReactionCollector is not a function
The message object stored in my JSON
appears as follows:
{
"message": {
"channelID": "678347518907777062",
"deleted": false,
"id": "750965454297628754",
"type": "DEFAULT",
"content": "@everyone",
"authorID": "729286679822860309",
"pinned": false,
"tts": false,
"system": false,
"embeds": [
{
"type": "rich",
"title": "Election",
"description": "It's time to vote! \n\nš¦ for <@247283454440374274> \nš§ for <@235088799074484224> \n\n__*Warning:*__ *You* ***can't*** *remove or change your vote later.*",
"color": 15046144,
"timestamp": 1599114577345,
"fields": [],
"thumbnail": null,
"image": null,
"video": null,
"author": null,
"provider": null,
"files": []
}
],
"attachments": [],
"createdTimestamp": 1599114516568,
"editedTimestamp": null,
"webhookID": null,
"applicationID": null,
"activity": null,
"flags": 0,
"reference": null,
"guildID": "591947002066108424",
"cleanContent": "@everyone"
}
}
Attempted to cache the message by its id without success. How can I properly retrieve the message as an object from the JSON
?