From 118a8c7e374a6ef772a49231865700c151ce959f Mon Sep 17 00:00:00 2001
From: jacob <jacoobes@sern.dev>
Date: Sat, 5 Oct 2024 12:51:58 -0500
Subject: [PATCH 1/2] fix: async presence

---
 src/core/presences.ts    | 5 ++---
 src/handlers/presence.ts | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/core/presences.ts b/src/core/presences.ts
index 3dbc9d64..b8cf4111 100644
--- a/src/core/presences.ts
+++ b/src/core/presences.ts
@@ -1,12 +1,11 @@
 import type { ActivitiesOptions } from "discord.js";
 import type { IntoDependencies } from "./ioc";
 import type { Emitter } from "./interfaces";
+import { Awaitable } from "../types/utility";
 
 type Status = 'online' | 'idle' | 'invisible' | 'dnd'
 type PresenceReduce = (previous: Presence.Result) => Presence.Result;
 
-
-
 export const Presence = {
     /**
      * A small wrapper to provide type inference.
@@ -50,7 +49,7 @@ export const Presence = {
 export declare namespace Presence {
     export type Config<T extends (keyof Dependencies)[]> = {
         inject?: [...T]
-        execute: (...v: IntoDependencies<T>) => Presence.Result;
+        execute: (...v: IntoDependencies<T>) => Awaitable<Presence.Result>;
 
     }
 
diff --git a/src/handlers/presence.ts b/src/handlers/presence.ts
index 2282e3d3..0a59b61f 100644
--- a/src/handlers/presence.ts
+++ b/src/handlers/presence.ts
@@ -1,4 +1,4 @@
-import { concatMap, from, interval, of, map, scan, startWith, fromEvent, take } from "rxjs"
+import { concatMap, from, interval, of, map, scan, startWith, fromEvent, take, mergeScan } from "rxjs"
 import { Presence  } from "../core/presences";
 import { Services } from "../core/ioc";
 import assert from "node:assert";
@@ -14,7 +14,7 @@ const parseConfig = async (conf: Promise<Presence.Result>) => {
             const src$ = typeof repeat === 'number' 
                 ? interval(repeat)
                 : fromEvent(...repeat);
-                return src$.pipe(scan(onRepeat, s), 
+                return src$.pipe(mergeScan(async (args) => onRepeat(args), s), 
                                  startWith(s));
         }
         return of(s).pipe(take(1));

From d779a79e0d0984095178cd8bf34df477fafb4915 Mon Sep 17 00:00:00 2001
From: jacob <jacoobes@sern.dev>
Date: Sat, 5 Oct 2024 12:57:58 -0500
Subject: [PATCH 2/2] fixes to typings

---
 src/core/presences.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/presences.ts b/src/core/presences.ts
index b8cf4111..defcdf0e 100644
--- a/src/core/presences.ts
+++ b/src/core/presences.ts
@@ -4,7 +4,7 @@ import type { Emitter } from "./interfaces";
 import { Awaitable } from "../types/utility";
 
 type Status = 'online' | 'idle' | 'invisible' | 'dnd'
-type PresenceReduce = (previous: Presence.Result) => Presence.Result;
+type PresenceReduce = (previous: Presence.Result) => Awaitable<Presence.Result>;
 
 export const Presence = {
     /**
@@ -59,7 +59,7 @@ export declare namespace Presence {
         activities?: ActivitiesOptions[];
         shardId?: number[];
         repeat?: number | [Emitter, string];
-        onRepeat?: (previous: Result) => Result; 
+        onRepeat?: PresenceReduce 
     }
 }