icu-discord-db
v1.0.7
Published
Allows data storage on discord for free with multiple nodes and with AES-256-CBC encryption support
Readme
💾 IcuDB — Free Data Storage in Discord Channels
🌐 More of my projects: https://messi.icu
🐛 Easier way to contact me/suggest features or bugs: Discord Server
💡 Why I Made This
I wanted an easy, reliable, and encrypted way to store data inside Discord — no databases, no servers, just pure Discord.
Couldn’t find anything that fit my needs, so I made IcuDB.
📖 About
IcuDB lets you store data inside a Discord channel using messages as data nodes. When a message reaches the data size limit (≈25MB), a new node is automatically created — giving you a distributed yet unified datastore inside your server.
You can get, set, delete, and push data just like a regular database. Optionally, you can enable AES-256-CBC encryption for secure, symmetric encryption that’s also super fast.
⚙️ Features
- 🧠 Multiple-node storage (splits data across messages)
- 🔒 AES-256-CBC encryption support
- ⚡ Fast and efficient
- 📦 Built-in methods:
get– Retrieve dataset– Store datadelete/del– Remove datapush– Append to arrays
- 🪶 Auto-save support
- 🪄 Fully runs inside Discord — no external DB needed
🚀 Installation
npm install icu-discord-db🧰 Example Usage
Basic Setup
const IcuDB = require("icu-discord-db");
(async () => {
const db = await IcuDB.initialize({
client: "<your_bot_token>", // Can also be an existing Discord.Client
guildid: "<guild_id>",
channelid: "<channel_id>",
debug: true, // Optional
});
// Store data
await db.set("users.messi", { name: "King Messi", goals: 802 });
// Retrieve data
console.log(await db.get("users.messi"));
// -> { name: "King Messi", goals: 802 }
// Delete data
await db.delete("users.messi");
// Push to array
await db.set("scores", []);
await db.push("scores", 10);
await db.push("scores", 15);
console.log(await db.get("scores"));
// -> [10, 15]
})();With Encryption Enabled
const IcuDB = require("icu-discord-db");
// Generate encryption keys
const encryption = JSON.parse(IcuDB.generateEncryptionConfig("mysecretpass"));
(async () => {
const db = await IcuDB.initialize({
client: "<your_bot_token>",
guildid: "<guild_id>",
channelid: "<channel_id>",
debug: true, // Recommended when setting up project
encryption: encryption, // Add the generated config here
});
await db.set("private.tokens", ["abc123", "xyz789"]);
console.log(await db.get("private.tokens"));
// -> ["abc123", "xyz789"]
})();🔐 Encryption Details
IcuDB uses AES-256-CBC (Advanced Encryption Standard - Cipher Block Chaining). This means:
- Symmetric key encryption (same key for encrypt/decrypt)
- Strong and efficient for small to medium data payloads
- Can be generated dynamically with:
const IcuDB = require("icu-discord-db");
console.log(IcuDB.generateEncryptionConfig("yourpassphrase"));
// Copy the generated config and use in your project when initializing the database
/*
Example:
await IcuDB.initialize(
client: "<your_bot_token>",
guildid: "<guild_id>",
channelid: "<channel_id>",
debug: true,
encryption: {
"key": "6b4e6b4b2b673f7e6e5d486b2b457b73",
"iv": "2f5b482f4c345f435b2b484b5b456d3e"
}
)
*/Example output:
{
"key": "6b4e6b4b2b673f7e6e5d486b2b457b73",
"iv": "2f5b482f4c345f435b2b484b5b456d3e"
}🧩 API Reference
initialize(options)
Creates or connects to a Discord-based database.
Options:
| Option | Type | Required | Description |
|--------|------|-----------|-------------|
| client | discord.Client or string | ✅ | Discord client or token |
| guildid | string | ✅ | Guild ID |
| channelid | string | ✅ | Channel ID where data is stored |
| debug | boolean | ❌ | Logs debugging info, good when the app runs into issues and recommended to enable when setting up project |
| encryption | { key, iv } | ❌ | Enable AES-256-CBC encryption |
| autosave | boolean | ❌ | Enable auto-saving, defaults to true (each 3 seconds) |
| saveinterval | number | ❌ | Interval in seconds for auto-save (defaults to the value of 3) |
Returns:
A data handler with .get(), .set(), .delete(), and .push() methods.
generateEncryptionConfig(passphrase?)
Generates an AES key and IV for encryption.
Parameters:
passphrase(optional) — A string seed for key generation.
Returns: A JSON-formatted encryption configuration.
📜 License
MIT © Messi
