Skip to content

Commit

Permalink
fix: real-time refactor
Browse files Browse the repository at this point in the history
Signed-off-by: en3sis <[email protected]>
  • Loading branch information
en3sis committed Apr 28, 2024
1 parent 1fcbb5d commit ac1c2fc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/realtime/presence.realtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
{
Expand All @@ -16,14 +16,18 @@ 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)
},
)
.subscribe()

// 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',
{
Expand All @@ -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}`)

Expand Down

0 comments on commit ac1c2fc

Please sign in to comment.