Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

feat: display permission level in /query #707

Merged
merged 9 commits into from
Sep 7, 2023
4 changes: 3 additions & 1 deletion src/handlers/comment/handlers/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getWalletInfo } from "../../../adapters/supabase";
import { getBotContext, getLogger } from "../../../bindings";
import { getUserPermission } from "../../../helpers";
import { Payload } from "../../../types";

export const query = async (body: string) => {
Expand All @@ -22,13 +23,14 @@ export const query = async (body: string) => {
const regex = /^\/query\s+@([\w-]+)\s*$/;
const matches = body.match(regex);
const user = matches?.[1];
const permissionLevel = await getUserPermission(sender, context);

if (user) {
const walletInfo = await getWalletInfo(user, id?.toString());
if (!walletInfo?.address) {
return `Error retrieving multiplier and wallet address for @${user}`;
} else {
return `@${user}'s wallet address is ${walletInfo?.address} and multiplier is ${walletInfo?.multiplier}`;
return `@${user}'s wallet address is ${walletInfo?.address}, multiplier is ${walletInfo?.multiplier} and permission level is ${permissionLevel}`;
}
} else {
logger.error("Invalid body for query command");
Expand Down
Loading