UNPKG

coinsnitch

Version:

A lightweight Discord currency transfer detector for NovaGolds, LutexBits, and Credits.

186 lines (134 loc) โ€ข 4.75 kB
![Logo](https://i.postimg.cc/nLrvZDKY/Add-a-heading-2.png) <div align="center"> ![Discord](https://img.shields.io/discord/1006273962986188881?logo=discord&logoColor=%23fff&logoSize=auto&label=Discord&labelColor=%23505050&color=%235E6AE9&link=https%3A%2F%2Fdiscord.gg%2Fethical-programmer-s-1188398653530984539) ![NPM License](https://img.shields.io/npm/l/coinsnitch?color=5E6AE9&label=License) </div> # CoinSnitch **CoinSnitch** is a smart currency transfer listener for Discord bots, supporting multiple virtual currencies like NovaGolds, LutexBits, and standard Credits. It detects transfers in real-time by monitoring Discord channels or message updates. ``` โœจ Built for Discord.js v14 & v13 ``` --- ## ๐Ÿ”ฅ Features - ๐Ÿ’ฑ Supports Multiple Currency Types - ๐Ÿ‘€ Real-time Transfer Detection - ๐Ÿง  Smart Filtering per Currency - โš™๏ธ Modular & Scalable Design - ๐Ÿ’ฌ Works with `messageCreate` and `messageUpdate` - ๐Ÿ”Œ Lightweight & Easy to Integrate - ๐Ÿ” Fully Customizable Filters - ๐Ÿงช Fully Testable Functions - ๐ŸŒ Perfect for Economy Bots, Game Bots, and More --- ## ๐Ÿ“ฆ Installation ```bash npm install coinsnitch ``` --- ## ๐Ÿ’ก Usage Examples ### ๐ŸŽฏ `messageUpdate` Example โ€“ `watchLutexBits` ```js const { watchLutexBits } = require("coinsnitch"); client.on("messageCreate", async (message) => { const options = { client, channel: message.channel, userId: "USER_ID", amount: [5, 10], // Supports multiple amounts timeout: 60000 }; const result = await watchLutexBits(options); if (result) { await message.reply(`โœ… Successfully transferred $${result.amount}!`); } else { await message.reply("โŒ Transfer failed or timed out."); } }); ``` --- ### ๐ŸŽฏ `messageCreate` Example โ€“ `watchNovaGolds` ```js const { watchNovaGolds } = require("coinsnitch"); client.on("messageCreate", async (message) => { const options = { channel: message.channel, botId: "BOT_ID", userId: "USER_ID", amount: [5, 10, 20], // Pass single or multiple amounts timeout: 60000 }; const result = await watchNovaGolds(options); if (result) { await message.reply(`๐ŸŒŸ NovaGolds transfer of $${result.amount} confirmed!`); } else { await message.reply("โŒ No matching NovaGolds transfer detected."); } }); ``` --- ### ๐ŸŽฏ `messageCreate` Example โ€“ `watchCredits` ```js const { watchCredits } = require("coinsnitch"); client.on("messageCreate", async (message) => { const options = { channel: message.channel, botId: "BOT_ID", userId: "USER_ID", amount: 10, // Can also be an array like [10, 20] timeout: 60000 }; const result = await watchCredits(options); if (result) { await message.reply(`๐Ÿ’ฐ Credits transfer of $${result.amount} completed.`); } else { await message.reply("โŒ Credits transfer not found."); } }); ``` --- ## ๐Ÿ› ๏ธ API Reference Each watcher returns a Promise that resolves to an object or `false`. ### `watchNovaGolds(options)` | Option | Type | Required | Description | |-------------|------------------|----------|-------------| | `channel` | Channel | โœ… | The channel to monitor | | `botId` | string | โœ… | Bot ID expected to send the confirmation | | `userId` | string | โœ… | Target user ID receiving the transfer | | `amount` | number \| number[]| โœ… | Amount(s) to match | | `timeout` | number | โœ… | Timeout duration in milliseconds | #### Returns: ```ts Promise<{ message: Message, amount: number } | false> ``` ### `watchCredits(options)` โ€” Same as above ### `watchLutexBits(options)` โ€” Monitors `messageUpdate` events instead of new messages. --- ## ๐Ÿ“ Folder Structure ``` coin-snitch/ โ”œโ”€โ”€ filters/ โ”‚ โ”œโ”€โ”€ creditsFilter.js โ”‚ โ”œโ”€โ”€ lutexBitsFilter.js โ”‚ โ””โ”€โ”€ novaGoldsFilter.js โ”œโ”€โ”€ utils/ โ”‚ โ””โ”€โ”€ createMessageWatcher.js โ”œโ”€โ”€ watchers/ โ”‚ โ”œโ”€โ”€ watchCredits.js โ”‚ โ”œโ”€โ”€ watchLutexBits.js โ”‚ โ””โ”€โ”€ watchNovaGolds.js โ”œโ”€โ”€ index.js โ””โ”€โ”€ package.json ``` --- ## ๐Ÿ“Œ Supported Currencies - **๐Ÿ’ฐ Credits** - **๐ŸŒŸ NovaGolds** - **๐ŸงŠ LutexBits** - โœ… Easily extendable for other types --- ## ๐Ÿ“ฌ Feedback & Support If you have any feedback, ideas, or bugs to report: - ๐Ÿ’ฌ [Join our Discord](https://dsc.gg/enexus) --- ## ๐Ÿ“˜ License This project is licensed under the Apache License โ€” see the [`LICENSE`](./LICENSE) file for details.