UNPKG

@getsolara/solara.canvas

Version:

Optional canvas and image manipulation functionality for @getsolara/solara.js

23 lines 1.2 kB
module.exports = { name: "$captchaKey", description: "Generates a random captcha key. Args: [length=6]", takesBrackets: true, execute: async (context, args) => { if (context.client.canvasInitialized === false) { return "[Error: $captchaKey requires canvas features (specifically canvafy) to be enabled. Ensure @getsolara/solara.canvas is installed.]"; } const length = args[0] ? parseInt(args[0], 10) : 6; if (isNaN(length) || length < 1 || length > 20) return "[Error: Invalid captcha key length for $captchaKey (1-20)]"; try { const canvafy = require("canvafy"); return canvafy.Util.captchaKey(length); } catch (e) { if (e.code === 'MODULE_NOT_FOUND' && e.message.includes('canvafy')) { console.error("Solara.canvas ($captchaKey): 'canvafy' module not found. This is a dependency of @getsolara/solara.canvas."); return "[Error: $captchaKey - canvafy module missing.]"; } console.error("Solara.canvas Error ($captchaKey):", e); return `[Error generating captcha key: ${e.message}]`; } } };