How to use the tsubaki.promisifyAll function in tsubaki

To help you get started, weโ€™ve selected a few tsubaki examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dirigeants / komada-pieces / providers / nedb.js View on Github external
/* eslint-disable no-underscore-dangle */

const { resolve } = require("path");
const Datastore = require("nedb-core");
require("tsubaki").promisifyAll(Datastore.prototype);

let dataStores;
const fs = require("fs-nextra");

let baseDir;

exports.init = (client) => {
  dataStores = new client.methods.Collection();
  baseDir = resolve(client.clientBaseDir, "bwd", "provider", "nedb");
  return fs.ensureDir(baseDir).catch(err => client.emit("log", err, "error"));
};

const resolveQuery = query => (query instanceof Object ? query : { id: query });

/* Table methods */
github WeebDev / Commando / commands / weather / weather.js View on Github external
// Credit goes to that cutie ;//w//; https://github.com/kurisubrooks/midori

const Canvas = require('canvas');
const { Command } = require('discord.js-commando');
const path = require('path');
const request = require('request-promise');
const { promisifyAll } = require('tsubaki');

const fs = promisifyAll(require('fs'));

const { GOOGLE_API, WEATHER_API } = process.env;
const { version } = require('../../package');

module.exports = class WeatherCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'weather',
			aliases: ['w', 'โ˜', 'โ›…', 'โ›ˆ', '๐ŸŒค', '๐ŸŒฅ', '๐ŸŒฆ', '๐ŸŒง', '๐ŸŒจ', '๐ŸŒฉ', '๐ŸŒช'],
			group: 'weather',
			memberName: 'weather',
			description: 'Get the weather.',
			throttling: {
				usages: 1,
				duration: 30
			},
github brussell98 / WeatherMachine / Worker / WeatherMachine.js View on Github external
require("bluebird");
require('dotenv').config({ path: __dirname + '/../.env' });

const EventEmitter = require('eventemitter3');
// const { } = require('./Constants');
const { camelCaseEventName } = require('../utils');
const SnowTransfer = require('snowtransfer');
const RainCache = require('raincache');
const AmqpConnector = require('./AqmpConnector');
const promisifyAll = require('tsubaki').promisifyAll;
const fs = promisifyAll(require('fs'));

class WeatherMachine extends EventEmitter {
	constructor(options = { }) {
		super();

		if (options.disabledEvents)
			options.disabledEvents = new Set(options.disabledEvents);

		this.options = Object.assign({
			disabledEvents: null,
			camelCaseEvents: false,
			eventPath: __dirname + '/eventHandlers/'
		}, options);

		this.cache = new RainCache({
			storage: { default: new RainCache.Engines.RedisStorageEngine({ password: process.env.REDIS_PASS }) },
github spec-tacles / discord.js-redis / src / RedisInterface.js View on Github external
const redis = require('redis');
const tsubaki = require('tsubaki');

tsubaki.promisifyAll(redis.RedisClient.prototype);
tsubaki.promisifyAll(redis.Multi.prototype);

module.exports = class RedisInterface {
  constructor(options = {}) {
    this.client = redis.createClient(options);
  }

  init(client) {
    const q = this.client.multi();

    client.users.forEach(u => q.sadd('users', u.id));
    client.guilds.forEach(g => q.sadd('guilds', g.id));
    client.emojis.forEach(e => q.sadd('emojis', e.id));
    client.channels.forEach(c => q.sadd('channels', c.id));

    return this.client.flushallAsync().then(() => q.execAsync());
  }
github DasWolke / RainCache / src / storageEngine / RedisStorageEngine.js View on Github external
'use strict';
let BaseStorageEngine = require('./BaseStorageEngine');
let redis = require('redis');
const promisifyAll = require('tsubaki').promisifyAll;
promisifyAll(redis.RedisClient.prototype);
promisifyAll(redis.Multi.prototype);

/**
 * StorageEngine which uses redis as a datasource
 * @extends BaseStorageEngine
 */
class RedisStorageEngine extends BaseStorageEngine {
    /**
     * Create a new redis storage engine
     * @param {Object} options
     * @param {Boolean} [options.useHash=false] - whether hash objects should be used for storing data
     * @property {Redis} client - redis client
     * @property {Boolean} ready - whether this storage engine is ready for usage
     * @property {Boolean} useHash - whether hash objects should be used for storing data
     * @property {Object} options - options that are passed to the redis client
     */
github dirigeants / komada-pieces / providers / nedb-class.js View on Github external
const { resolve } = require("path");
const { Collection } = require("discord.js");
const { promisifyAll } = require("tsubaki");
const Datastore = require("nedb-core");

promisifyAll(Datastore.prototype);

class NeDB {
  /**
   * Creates an instance of the NeDB class
   * @param {string} [name="komada"] Name of the Datastore
   * @param {boolean} [persistent=true] Is Persistent?
   * @constructor NeDB
   */
  constructor(name = "komada", persistent = true) {
    this.name = name;
    this.persistent = persistent;
    this.db = null;
  }

  /**
   * Connects to the NeDB datastore and populates this.db
github WeebDev / Commando / structures / Redis.js View on Github external
const { promisifyAll } = require('tsubaki');
const redisClient = require('redis');
const winston = require('winston');

const { REDIS } = process.env;

promisifyAll(redisClient.RedisClient.prototype);
promisifyAll(redisClient.Multi.prototype);

const redis = redisClient.createClient({ host: REDIS, port: 6379 });

class Redis {
	static get db() {
		return redis;
	}

	static start() {
		redis.on('error', error => winston.error(`[REDIS]: Encountered error: \n${error}`))
			.on('reconnecting', () => winston.warn('[REDIS]: Reconnecting...'));
	}
}

module.exports = Redis;
github WeebDev / Commando / commands / social / profile.js View on Github external
const Canvas = require('canvas');
const { Command } = require('discord.js-commando');

const path = require('path');
const request = require('request-promise');

const { promisifyAll } = require('tsubaki');
const fs = promisifyAll(require('fs'));

const Bank = require('../../structures/currency/Bank');
const Currency = require('../../structures/currency/Currency');
const Experience = require('../../structures/currency/Experience');
const UserProfile = require('../../models/UserProfile');

module.exports = class ProfileCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'profile',
			aliases: ['p'],
			group: 'social',
			memberName: 'profile',
			description: 'Display your profile.',
			guildOnly: true,
			throttling: {

tsubaki

Promisify with native promises.

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular tsubaki functions