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

Commit

Permalink
fix: properly save message cache
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed Feb 20, 2024
1 parent bd9c87a commit 4b6d1d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/Structures/VoiceState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class VoiceState extends Base<InferSelectModel<typeof voiceStates>> {
}

public get guildId(): string {
return this.data.guildId!;
return this.data.guildId;
}

public get channelId(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,6 @@ export class MessageCreateListener extends Listener {
}
});

if (stateMessages) {
await this.store.drizzle.insert(messages).values({
id: payload.data.d.id,
channelId: payload.data.d.channel_id,
content: payload.data.d.content,
applicationId: payload.data.d.application_id,
authorId: payload.data.d.author.id,
editedTimestamp: payload.data.d.edited_timestamp,
flags: payload.data.d.flags,
type: payload.data.d.type,
mentionEveryone: payload.data.d.mention_everyone,
pinned: payload.data.d.pinned,
position: payload.data.d.position,
timestamp: payload.data.d.timestamp,
tts: payload.data.d.tts,
webhookId: payload.data.d.webhook_id,
nonce: payload.data.d.nonce?.toString()
}).onConflictDoNothing({ target: messages.id });
}

if (payload.data.d.member.roles.length > 0) {
await this.store.drizzle.insert(memberRoles).values(payload.data.d.member.roles.map(role => ({
memberId: payload.data.d.author.id,
Expand All @@ -109,6 +89,26 @@ export class MessageCreateListener extends Listener {
}
}

if (stateMessages) {
await this.store.drizzle.insert(messages).values({
id: payload.data.d.id,
channelId: payload.data.d.channel_id,
content: payload.data.d.content,
applicationId: payload.data.d.application_id,
authorId: payload.data.d.author.id,
editedTimestamp: payload.data.d.edited_timestamp,
flags: payload.data.d.flags,
type: payload.data.d.type,
mentionEveryone: payload.data.d.mention_everyone,
pinned: payload.data.d.pinned,
position: payload.data.d.position,
timestamp: payload.data.d.timestamp,
tts: payload.data.d.tts,
webhookId: payload.data.d.webhook_id,
nonce: payload.data.d.nonce?.toString()
}).onConflictDoNothing({ target: messages.id });
}

await this.store.amqp.publish(RabbitMQ.GATEWAY_QUEUE_SEND, RoutingKey(clientId, payload.shardId), Buffer.from(JSON.stringify(payload.data)));
}
}

0 comments on commit 4b6d1d2

Please sign in to comment.