# discord-config-storage

> A prototype per-server configuration for discord.js

Latest version **1.0.3** (published 2020-06-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install discord-config-storage
pnpm add discord-config-storage
yarn add discord-config-storage
bun add discord-config-storage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-06-05 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | codejabo |
| Maintainers | codejabo |
| Keywords | discord.js, configuration, discord-config, per-server config |

## Links

- npm: https://www.npmjs.com/package/discord-config-storage
- npm.io page: https://npm.io/package/discord-config-storage

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-06-05
- 1.0.2 — 2020-06-02
- 1.0.1 — 2020-06-01
- 1.0.0 — 2020-06-01

## README

# discord-config-storage
This is a module that stores configuration and capable for pre-server config <br>
## [Support the Developer](https://www.paypal.me/codejabo)
## Usage
```js
const { DiscordConfigStorage } = require("discord-config-storage");
```
## Example
```js
const discord = require("discord.js");
const client = new discord.Client();

// Load the module
const { DiscordConfigStorage } = require("discord-config-storage");
let configStorage = new DiscordConfigStorage("./config.json"); // Takes 1 argument which is your config file

// Trigger once the bot join a guild
client.on("guildCreate", guild => {
    configStorage.data.addGuild(guild.id); // Takes 1 argument Guild ID
    // Random config that you can use
    configStorage.data.set(guild.id, "prefix", "?"); // Takes 3 arguments <guildID> <configName> <configValue>
});

// Trigger when a message has been sent
client.on("message", msg => {

    if(msg.author.bot)
        return;

    // To get a config for a guild use <config.storage.data.guild(guildID).configName>
    if(!msg.content.startsWith(configStorage.data.guild(msg.guild.id).prefix))
        return;
    
    msg.reply("Hello");

});


// Trigger once logged in
client.on("ready", () => {

    console.log(`Logged on as ${client.user.tag}`);

});

client.login("TOKEN");

```

## Data
```js
// Load the module
const { DiscordConfigStorage } = require("discord-config-storage");
let configStorage = new DiscordConfigStorage("./config.json"); // Takes 1 argument which is your config file

configStorage.data // Returns a ConfigData Object

/*

    ConfigData
    Methods:
        guild(guildID); // Returns Object
        set(guildID, configName, configValue); // No Return
        addGuild(guildID); // No return

*/

```

---
_Source: https://npm.io/package/discord-config-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
