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
10 changes: 8 additions & 2 deletions src/handlers/comment/handlers/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getWalletInfo } from "../../../adapters/supabase";
import { getAccessLevel, getWalletInfo } from "../../../adapters/supabase";
import { getBotContext, getLogger } from "../../../bindings";
import { Payload } from "../../../types";

Expand All @@ -22,13 +22,19 @@ export const query = async (body: string) => {
const regex = /^\/query\s+@([\w-]+)\s*$/;
const matches = body.match(regex);
const user = matches?.[1];
const repo = payload.repository;

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 access levels are
| access type | access level |
| multiplier | ${getAccessLevel(sender, repo.full_name, "multiplier")} |
| priority | ${getAccessLevel(sender, repo.full_name, "priority")} |
| time | ${getAccessLevel(sender, repo.full_name, "time")} |
| price | ${getAccessLevel(sender, repo.full_name, "price")} |`;
}
} else {
logger.error("Invalid body for query command");
Expand Down
Loading