refactor(tools): drop guild member-list tool and remove dirigent_ prefix from tool names
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
||||
import type { ChannelPolicy, DirigentConfig } from "../rules.js";
|
||||
|
||||
type DiscordControlAction = "channel-private-create" | "channel-private-update" | "member-list";
|
||||
type DiscordControlAction = "channel-private-create" | "channel-private-update";
|
||||
|
||||
const PERM_VIEW_CHANNEL = 1n << 10n; // 0x400
|
||||
const PERM_ADMINISTRATOR = 1n << 3n; // 0x8
|
||||
@@ -125,30 +125,6 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
const token = selected.token;
|
||||
|
||||
if (action === "member-list") {
|
||||
const guildId = String(params.guildId || "").trim();
|
||||
if (!guildId) return { content: [{ type: "text", text: "guildId is required" }], isError: true };
|
||||
const limit = Math.max(1, Math.min(1000, Number(params.limit || 1000)));
|
||||
const after = String(params.after || "").trim();
|
||||
const fieldsRaw = params.fields;
|
||||
const fields = Array.isArray(fieldsRaw) ? fieldsRaw.map(String) : typeof fieldsRaw === "string" ? fieldsRaw.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
||||
|
||||
const q = new URLSearchParams({ limit: String(limit) });
|
||||
if (after) q.set("after", after);
|
||||
const resp = await discordRequest(token, "GET", `/guilds/${guildId}/members?${q.toString()}`);
|
||||
if (!resp.ok) return { content: [{ type: "text", text: `discord action failed (${resp.status}): ${resp.text}` }], isError: true };
|
||||
|
||||
let members = Array.isArray(resp.json) ? resp.json : [];
|
||||
if (fields.length > 0) {
|
||||
members = members.map((m: any) => {
|
||||
const out: Record<string, unknown> = {};
|
||||
for (const f of fields) out[f] = m?.[f];
|
||||
return out;
|
||||
});
|
||||
}
|
||||
return { content: [{ type: "text", text: JSON.stringify({ ok: true, accountId: selected.accountId, members }, null, 2) }] };
|
||||
}
|
||||
|
||||
if (action === "channel-private-create") {
|
||||
const guildId = String(params.guildId || "").trim();
|
||||
const name = String(params.name || "").trim();
|
||||
@@ -220,7 +196,7 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_discord_channel_create",
|
||||
name: "discord_channel_create",
|
||||
description: "Create a private Discord channel with specific user/role permissions.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
@@ -250,7 +226,7 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_discord_channel_update",
|
||||
name: "discord_channel_update",
|
||||
description: "Update permissions on an existing private Discord channel.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
@@ -276,30 +252,7 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_discord_member_list",
|
||||
description: "List members of a Discord guild.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
accountId: { type: "string" },
|
||||
guildId: { type: "string" },
|
||||
limit: { type: "number" },
|
||||
after: { type: "string" },
|
||||
fields: { anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }] },
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
async execute(_id: string, params: Record<string, unknown>) {
|
||||
return executeDiscordAction("member-list", params);
|
||||
},
|
||||
},
|
||||
{ optional: false },
|
||||
);
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_policy_get",
|
||||
name: "policy_get",
|
||||
description: "Get all Dirigent channel policies.",
|
||||
parameters: { type: "object", additionalProperties: false, properties: {}, required: [] },
|
||||
async execute() {
|
||||
@@ -318,7 +271,7 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_policy_set",
|
||||
name: "policy_set",
|
||||
description: "Set or update a Dirigent channel policy.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
@@ -362,7 +315,7 @@ export function registerDirigentTools(deps: ToolDeps): void {
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "dirigent_policy_delete",
|
||||
name: "policy_delete",
|
||||
description: "Delete a Dirigent channel policy.",
|
||||
parameters: {
|
||||
type: "object",
|
||||
|
||||
Reference in New Issue
Block a user