dice-discord / commando-provider-keyv

SettingProvider for the Commando framework that uses Keyv

Home Page:https://commando-provider-keyv.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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')));

About

SettingProvider for the Commando framework that uses Keyv

https://commando-provider-keyv.netlify.com/

License:Apache License 2.0


Languages

Language:JavaScript 100.0%