Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* 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 */
// 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
},
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 }) },
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());
}
'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
*/
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
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;
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: {