From e02671ac66e6576e98422e510115aee6a05184bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= <laszlo@karolyi.hu>
Date: Sat, 2 Jan 2021 11:46:01 +0100
Subject: [PATCH] Fix presence status error, fix client init

---
 src/clientfactory.ts   | 6 +++---
 src/presencehandler.ts | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/clientfactory.ts b/src/clientfactory.ts
index b2a5bae..d93d7fc 100644
--- a/src/clientfactory.ts
+++ b/src/clientfactory.ts
@@ -43,7 +43,7 @@ export class DiscordClientFactory {
             fetchAllMembers: this.config.usePrivilegedIntents,
             messageCacheLifetime: 5,
             ws: {
-                intents: this.config.usePrivilegedIntents ? Intents.PRIVILEGED : Intents.NON_PRIVILEGED,
+                intents: this.config.usePrivilegedIntents ? Intents.ALL : Intents.NON_PRIVILEGED,
             },
         });
 
@@ -69,7 +69,7 @@ export class DiscordClientFactory {
             fetchAllMembers: false,
             messageCacheLifetime: 5,
             ws: {
-                intents: Intents.NON_PRIVILEGED,
+                intents: this.config.usePrivilegedIntents ? Intents.ALL : Intents.NON_PRIVILEGED,
             },
         });
 
@@ -102,7 +102,7 @@ export class DiscordClientFactory {
             fetchAllMembers: false,
             messageCacheLifetime: 5,
             ws: {
-                intents: Intents.NON_PRIVILEGED,
+                intents: this.config.usePrivilegedIntents ? Intents.ALL : Intents.NON_PRIVILEGED,
             },
         });
 
diff --git a/src/presencehandler.ts b/src/presencehandler.ts
index ebb7024..69bd263 100644
--- a/src/presencehandler.ts
+++ b/src/presencehandler.ts
@@ -144,7 +144,7 @@ export class PresenceHandler {
         const intent = this.bot.GetIntentFromDiscordMember(user);
         try {
             await intent.ensureRegistered();
-            await intent.underlyingClient.setPresenceStatus(status.Presence, status.StatusMsg);
+            await intent.underlyingClient.setPresenceStatus(status.Presence, status.StatusMsg || '');
         } catch (ex) {
             if (ex.errcode !== "M_FORBIDDEN") {
                 log.warn(`Could not update Matrix presence for ${user.id}`);
-- 
GitLab