Lines 149-189javascript
149const MESSAGE_CONTENT_LIMITED_FLAG = 1 << 18; // GATEWAY_MESSAGE_CONTENT_LIMITED (verified bots)
150async function checkMessageContentIntent(token) {
152 const { status, body } = await httpsGet("https://discord.com/api/v10/applications/@me", { Authorization: `Bot ${token}` });
153 if (status === 200) {
154 const app = JSON.parse(body);
155 const hasIntent = (app.flags & MESSAGE_CONTENT_FLAG) !== 0 ||
156 (app.flags & MESSAGE_CONTENT_LIMITED_FLAG) !== 0;
158 return { ok: true, botId: app.id };
159 return { ok: false, botId: app.id, reason: "MESSAGE_CONTENT intent not enabled." };
161 return { ok: false, botId: "", reason: `Unexpected HTTP ${status} from /applications/@me.` };
164 return { ok: false, botId: "", reason: `Network error: ${err instanceof Error ? err.message : String(err)}` };
167async function validateAnthropicKey(apiKey) {
168 // Dynamic import of @anthropic-ai/sdk (only available in usrcp-discord which has it as a dep)
170 const { default: Anthropic } = await import("@anthropic-ai/sdk");
171 const client = new Anthropic({ apiKey });
HighCopied Package Dependency Bridge
Package metadata claims a different repository identity while copied source loads a runtime dependency bridge.
dist/setup.jsView on unpkg · L169 172 await client.messages.create({
173 model: "claude-haiku-4-5",
175 messages: [{ role: "user", content: "hi" }],
180 const msg = err instanceof Error ? err.message : String(err);
181 if (msg.includes("401") || msg.includes("Unauthorized") || msg.includes("invalid x-api-key") || msg.includes("authentication")) {
182 return { ok: false, reason: "Invalid API key (401)." };
184 // Any other error (network, rate-limit) — pass through as valid (fail-fast is for auth only)
188function tryOpenUrl(url) {