/commando-provider-keyv

SettingProvider for the Commando framework that uses Keyv

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Commando Provider Keyv

Build Status

A Keyv based SettingProvider for the Discord.js Commando framework.

Back-end Support

  • Redis
  • MongoDB
  • SQLite
  • PostgreSQL
  • MySQL
  • Third-party storage adapters (see Keyv docs)

Usage

In Memory

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

client.setProvider(new KeyvProvider(new Keyv()));

Redis

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

client.setProvider(new KeyvProvider(new Keyv('redis://user:pass@localhost:6379')));

MongoDB

Set the serialize and deserialize functions to do no transformations, since MongoDB can support storing raw JSON.

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

const settings = { serialize: data => data, deserialize: data => data };

client.setProvider(new KeyvProvider(new Keyv('mongodb://user:pass@localhost:27017/dbname', settings)));

SQLite

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

client.setProvider(new KeyvProvider(new Keyv('sqlite://path/to/dbname.sqlite')));

PostgreSQL

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

client.setProvider(new KeyvProvider(new Keyv('postgresql://user:pass@localhost:5432/dbname')));

MySQL

const { CommandoClient } = require('discord.js-commando');
const Keyv = require('keyv');
const KeyvProvider = require('commando-provider-keyv');

const client = new CommandoClient();

client.setProvider(new KeyvProvider(new Keyv('mysql://user:pass@localhost:3306/dbname')));