redis onoff만들어서 쓸때만 .env에 on하기
This commit is contained in:
@@ -32,7 +32,7 @@ export class GuildPlayer {
|
||||
) {
|
||||
this.player.setGlobalVolume(50);
|
||||
this.player.on("start", (_data: TrackStartEvent) => {
|
||||
Redis.publishState("player_update", {
|
||||
Redis?.publishState("player_update", {
|
||||
guildId: this.guild.id,
|
||||
});
|
||||
});
|
||||
@@ -189,7 +189,7 @@ export class GuildPlayer {
|
||||
if (!this.isPlaying) return;
|
||||
if (!this.nowTrack) return;
|
||||
this.player.seekTo(num);
|
||||
Redis.publishState("player_update", { guildId: this.guild.id });
|
||||
Redis?.publishState("player_update", { guildId: this.guild.id });
|
||||
}
|
||||
|
||||
private async autoPlay() {
|
||||
@@ -244,8 +244,8 @@ export class GuildPlayer {
|
||||
}
|
||||
|
||||
public async setMsg(update: { player: boolean; queue: boolean; } = { player: true, queue: true }) {
|
||||
if (update.player) Redis.publishState("player_update", { guildId: this.guild.id });
|
||||
if (update.queue) Redis.publishState("queue_update", { guildId: this.guild.id });
|
||||
if (update.player) Redis?.publishState("player_update", { guildId: this.guild.id });
|
||||
if (update.queue) Redis?.publishState("queue_update", { guildId: this.guild.id });
|
||||
const { channel, msg, check } = await checkTextChannelAndMsg(this.guild, this.textChannel, this.msg);
|
||||
if (!check) return;
|
||||
this.textChannel = channel;
|
||||
|
||||
@@ -23,7 +23,12 @@ type SubAction =
|
||||
"queue_set" |
|
||||
"queue_remove";
|
||||
|
||||
export class RedisClient {
|
||||
export const RedisClient = () => {
|
||||
if (Config.redis.state) return new RedisClientClass();
|
||||
return null;
|
||||
}
|
||||
|
||||
class RedisClientClass {
|
||||
public pub: Redis = new Redis({ host: Config.redis.host, port: Config.redis.port });
|
||||
public sub: Redis = new Redis({ host: Config.redis.host, port: Config.redis.port });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user