A Facebook Messenger bot command that shares random Quranic verses with Arabic text, Bengali translations, English translations, and a randomly selected image.
Developed by CodeWithTanim
- Random Quranic Verses: Selects a random verse from a predefined collection of Quranic passages.
- Arabic Text: Includes the Arabic text of each stored verse.
- Bengali Translation: Shares Bengali translations to help Bengali-speaking users understand the verses.
- English Translation: Includes English translations alongside the Arabic and Bengali text.
- Verse References: Displays the associated Surah name and verse reference.
- Random Images: Selects one image at random from a collection of five configured image URLs.
- Combined Message and Image: Sends the selected verse and its image together in one Messenger message.
- Automatic Image Download: Downloads the selected image before attaching it to the message.
- Automatic File Cleanup: Attempts to delete the temporary image after sending the message.
- Simple Command Execution: Requires no arguments to generate a verse.
- Lightweight Implementation: Uses Node.js with asynchronous file and message handling.
- Node.js
- A compatible Facebook Messenger bot framework
axiosrequestfs-extra- A working bot session with permission to send messages and attachments
- An accessible
cachedirectory inside the command directory
Clone the repository or download the JavaScript command file.
git clone https://github.com/CodeWithTanim/quran.gitNavigate to your bot's command directory and place the file there with the following name:
quran.js
Install the required dependencies if they are not already installed:
npm install axios request fs-extraMake sure the following directory exists inside the command directory:
cache/
Restart your Messenger bot after installation.
Open a Messenger group where your bot is active and run the command using your configured prefix.
<prefix>quran
No additional arguments are required.
Each execution selects one verse from the stored collection and one image from the configured image list.
- The command stores a collection of Quranic passages with Arabic text, Bengali translations, English translations, and references.
- When a user executes the command, the bot randomly selects one passage.
- The bot randomly selects an image URL from the configured image list.
- The image is downloaded and saved temporarily as
cache/zac.jpg. - The bot sends the verse text and downloaded image together.
- After sending the message, the bot attempts to remove the temporary image file.
| Property | Value |
|---|---|
| Command Name | quran |
| Version | 1.0.0 |
| Author Credit | MSRTanim |
| Category | random-img |
| Permission | 0 as intended by the configuration |
| Cooldown | 0 seconds |
The exact permission behavior depends on your bot framework. The configuration uses hasPermision, which may be a typo if the framework expects hasPermssion.
| Component | Technology |
|---|---|
| Language | JavaScript |
| Runtime | Node.js |
| HTTP Requests | request |
| File Handling | fs-extra |
| Message Delivery | Messenger bot framework |
| Content Selection | JavaScript random selection |
- The command uses a predefined collection of verses rather than retrieving verses dynamically from a Quran API.
- The image URLs are hardcoded in the source code.
- Image downloads depend on the availability and accessibility of the configured URLs.
- The command uses a fixed temporary filename,
cache/zac.jpg. Concurrent executions could conflict if multiple requests run at the same time. - The image cleanup callback uses
fs.unlinkSync(). If the file is missing or cannot be deleted, this may cause an error. - Quranic text, verse references, and translations should be checked against reliable Quran sources before publication. Translation wording can vary between editions.
- The script imports
axiosbut does not use it in the provided implementation.
- Add more verified Quranic verses.
- Include Surah names and verse numbers in a consistent format.
- Add a command to retrieve a specific Surah and verse.
- Support multiple Bengali and English translation editions.
- Replace the deprecated
requestpackage with a maintained HTTP client. - Use unique temporary filenames to prevent conflicts.
- Improve error handling for failed image downloads and message delivery.
- Add an option to send the verse without an image.
- Add support for Quran recitation audio.
- Retrieve verified verse text from a trusted Quran data source.
GitHub: CodeWithTanim
Thank you for checking out this project. May the Quranic verses shared through this command inspire reflection, patience, and goodness.
Developed by CodeWithTanim
