From ac1c2fc08f74c88789ef1a22edd69c84b06792e3 Mon Sep 17 00:00:00 2001 From: en3sis <940170+en3sis@users.noreply.github.com> Date: Sun, 28 Apr 2024 14:38:30 +0200 Subject: [PATCH] fix: real-time refactor Signed-off-by: en3sis <940170+en3sis@users.noreply.github.com> --- src/realtime/presence.realtime.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/realtime/presence.realtime.ts b/src/realtime/presence.realtime.ts index 61e5efc..162f248 100644 --- a/src/realtime/presence.realtime.ts +++ b/src/realtime/presence.realtime.ts @@ -7,7 +7,7 @@ import supabase from '../libs/supabase' export const configsRealtime = () => { // Listen for changes in the configs table supabase - .channel('table-db-changes') + .channel('bot-configs-realtime') .on( 'postgres_changes', { @@ -16,6 +16,10 @@ export const configsRealtime = () => { table: 'configs', }, async (payload) => { + if (!!process.env.ISDEV) { + console.log('Guild plugin updated:', payload.new) + } + await setPresence(payload.new.activity_type, payload.new.activity_name) }, ) @@ -23,7 +27,7 @@ export const configsRealtime = () => { // Listen for changes in the guilds plugins table and delete the cached data supabase - .channel('table-db-changes') + .channel('guilds-plugins-realtime') .on( 'postgres_changes', { @@ -32,7 +36,10 @@ export const configsRealtime = () => { table: 'guilds_plugins', }, async (payload) => { - console.log('Guild plugin updated:', payload.new) + if (!!process.env.ISDEV) { + console.log('Guild plugin updated:', payload.new) + } + // INFO: Refresh the cache for the guild plugins deleteFromCache(`guildPlugins:${payload.new.owner}:${payload.new.name}`)