mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Fix
This commit is contained in:
@@ -23,8 +23,7 @@ module.exports = class XiaoClient extends CommandClient {
|
|||||||
)
|
)
|
||||||
});
|
});
|
||||||
this.fonts = new FontManager(this);
|
this.fonts = new FontManager(this);
|
||||||
this.redis = Redis.db;
|
this.redis = new Redis(this);
|
||||||
Redis.start();
|
|
||||||
this.timers = new TimerManager(this);
|
this.timers = new TimerManager(this);
|
||||||
this.pokemon = new PokemonStore();
|
this.pokemon = new PokemonStore();
|
||||||
this.dispatchers = new Map();
|
this.dispatchers = new Map();
|
||||||
|
|||||||
+13
-15
@@ -1,22 +1,20 @@
|
|||||||
const Redis = require('ioredis');
|
const Redis = require('ioredis');
|
||||||
const { REDIS_HOST, REDIS_PASS } = process.env;
|
const { REDIS_HOST, REDIS_PASS } = process.env;
|
||||||
const redis = new Redis({
|
|
||||||
port: 6379,
|
|
||||||
host: REDIS_HOST,
|
|
||||||
enableReadyCheck: true,
|
|
||||||
password: REDIS_PASS,
|
|
||||||
db: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = class RedisClient {
|
module.exports = class RedisClient {
|
||||||
static get db() {
|
constructor(client, host = REDIS_HOST, pass = REDIS_PASS) {
|
||||||
return redis;
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
}
|
|
||||||
|
|
||||||
static start() {
|
this.db = new Redis({
|
||||||
redis.on('connect', () => console.info('[REDIS][CONNECT]: Connecting...'));
|
port: 6379,
|
||||||
redis.on('ready', () => console.info('[REDIS][READY]: Ready!'));
|
host,
|
||||||
redis.on('error', error => console.error(`[REDIS][ERROR]: Encountered error:\n${error}`));
|
enableReadyCheck: true,
|
||||||
redis.on('reconnecting', () => console.warn('[REDIS][RECONNECT]: Reconnecting...'));
|
password: pass,
|
||||||
|
db: 0
|
||||||
|
});
|
||||||
|
this.db.on('connect', () => this.client.logger.info('[REDIS] Connecting...'));
|
||||||
|
this.db.on('ready', () => this.client.logger.info('[REDIS] Ready!'));
|
||||||
|
this.db.on('error', error => this.client.logger.error(`[REDIS] Encountered error:\n${error}`));
|
||||||
|
this.db.on('reconnecting', () => this.client.logger.warn('[REDIS] Reconnecting...'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user