Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:NezuChan/nezu-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed Feb 2, 2024
2 parents c116b2d + c264511 commit 70ab041
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"gradient-string": "^2.0.2",
"ioredis": "^5.3.2",
"kearsarge": "^1.0.3",
"pino": "^8.17.2",
"pino": "^8.18.0",
"pino-pretty": "^10.3.1",
"prometheus-middleware": "^1.3.3",
"tslib": "^2.6.2",
Expand All @@ -61,12 +61,12 @@
},
"devDependencies": {
"@hazmi35/eslint-config": "^11.0.0",
"@swc/cli": "^0.3.5",
"@swc/cli": "^0.3.6",
"@swc/core": "^1.3.107",
"@types/amqplib": "^0.10.4",
"@types/dockerode": "^3.3.23",
"@types/gradient-string": "^1.1.5",
"@types/node": "^20.11.14",
"@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"@vladfrangu/async_event_emitter": "^2.2.4",
Expand Down
40 changes: 20 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions src/Listeners/Caches/Guilds/GuildCreateListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,24 @@ export class GuildCreateListener extends Listener {
}
}
await this.store.redis.incrby(GenKey(RedisKey.USER_KEY, RedisKey.COUNT), payload.data.d.members.length - alreadyExists);
payload.data.d.members = [];
}

if (stateChannels) {
for (const channel of payload.data.d.channels) {
await this.store.redis.set(GenKey(RedisKey.CHANNEL_KEY, channel.id, payload.data.d.id), JSON.stringify(channel));
}
payload.data.d.channels = [];
}

if (stateRoles) {
for (const role of payload.data.d.roles) {
await this.store.redis.set(GenKey(RedisKey.ROLE_KEY, role.id, payload.data.d.id), JSON.stringify(role));
}
payload.data.d.roles = [];
}

if (stateVoices) {
for (const voice of payload.data.d.voice_states) {
await this.store.redis.set(GenKey(RedisKey.VOICE_KEY, voice.user_id, payload.data.d.id), JSON.stringify(voice));
}
payload.data.d.voice_states = [];
}

if (stateEmojis) {
Expand All @@ -60,19 +56,27 @@ export class GuildCreateListener extends Listener {
await this.store.redis.set(GenKey(RedisKey.EMOJI_KEY, emoji.id, payload.data.d.id), JSON.stringify(emoji));
}
}
payload.data.d.emojis = [];
}

if (statePresences) {
for (const presence of payload.data.d.presences) {
await this.store.redis.set(GenKey(RedisKey.PRESENCE_KEY, presence.user.id, payload.data.d.id), JSON.stringify(presence));
}
payload.data.d.presences = [];
}

const key = GenKey(RedisKey.GUILD_KEY, payload.data.d.id);
const exists = await this.store.redis.exists(key);
await this.store.redis.set(key, JSON.stringify(payload.data.d));
await this.store.redis.set(key, JSON.stringify({
...payload.data.d,
members: [],
voice_states: [],
emojis: [],
presences: [],
channels: [],
stickers: [],
soundboard_sounds: [],
threads: []
}));

if (exists === 0) await this.store.redis.incr(GenKey(RedisKey.GUILD_KEY, RedisKey.COUNT));

Expand Down
10 changes: 9 additions & 1 deletion src/Listeners/Caches/Voices/VoiceStateUpdateListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ export class VoiceStateUpdateListener extends Listener {
if (stateVoices) {
if (payload.data.d.channel_id) {
const key = GenKey(RedisKey.VOICE_KEY, payload.data.d.user_id, payload.data.d.guild_id);
await this.store.redis.set(key, JSON.stringify(payload.data.d));
await this.store.redis.set(key, JSON.stringify({
...payload.data.d,
member: payload.data.d.member
? {
...payload.data.d.member,
roles: []
}
: null
}));
await this.store.redis.sadd(GenKey(RedisKey.VOICE_KEY, RedisKey.LIST, payload.data.d.guild_id), key);
} else {
const key = GenKey(RedisKey.VOICE_KEY, payload.data.d.user_id, payload.data.d.guild_id);
Expand Down

0 comments on commit 70ab041

Please sign in to comment.