Pārlūkot izejas kodu

Add logging for verify

ghorsington 4 gadi atpakaļ
vecāks
revīzija
6834db5fed
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      bot/src/rpc.ts

+ 9 - 1
bot/src/rpc.ts

@@ -56,7 +56,15 @@ const handler: ModuleRpcServer.ServiceHandlerFor<typeof NoctBotService> = {
         return { verified: await checkUser("check verified", userId, async (user, guild) => user.roles.cache.has(guild.verifiedRoleId)) };
     },
     async verifyUser({ userId }): Promise<{ ok: boolean }> {
-        return { ok: !(await checkUser("verify", userId, async (user, guild) => !(await tryDo(user.roles.add(guild.verifiedRoleId))).ok)) };
+        return { ok: !(await checkUser("verify", userId, async (user, guild) => {
+            const result = await tryDo(user.roles.add(guild.verifiedRoleId));
+            if (result.ok) {
+                logger.info("Verifying user %s#%s (%s) on guild %s", user.user.username, user.user.discriminator, user.user.id, guild.guildId);
+            } else {
+                logger.warn("Failed to verify user %s#%s (%s) on guild %s: %s", user.user.username, user.user.discriminator, user.user.id, guild.guildId, result.error);
+            }
+            return !result.ok;
+        }))};
     }
 };