Skip to content

Commit

Permalink
fix(Node): fix dataCache duplicate while reconnect by client
Browse files Browse the repository at this point in the history
  • Loading branch information
Fab1o0107 committed Dec 26, 2023
1 parent b747cbf commit 9fa59a7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,18 @@ export class Node {
const IDataCache = await this.manager.redis?.get(RedisKey.NodePlayers(this.name.toLowerCase()));
const dataCache = IDataCache ? (JSON.parse(IDataCache) as VoiceChannelOptions[]) : [];

dataCache.push({
guildId: options.guildId,
channelId: options.channelId,
shardId: options.shardId,
deaf: options.deaf ?? true,
mute: options.mute ?? false
});
if (dataCache.some(({ guildId }) => guildId !== options.guildId)) {
dataCache.push({
guildId: options.guildId,
channelId: options.channelId,
shardId: options.shardId,
deaf: options.deaf ?? true,
mute: options.mute ?? false
});

await this.manager.redis?.set(RedisKey.NodePlayers(this.name.toLowerCase()), JSON.stringify(dataCache));
}

await this.manager.redis?.set(RedisKey.NodePlayers(this.name.toLowerCase()), JSON.stringify(dataCache));
this.manager.players.set(player.guildId, player);

return player;
Expand Down

0 comments on commit 9fa59a7

Please sign in to comment.